Package net.sf.okapi.common
Class Event
- java.lang.Object
-
- net.sf.okapi.common.Event
-
public class Event extends Object
Represents an event generated by a filter that implements IFilter.
-
-
Constructor Summary
Constructors Constructor Description Event()
Event(EventType filterEventType)
Creates a new event without any associated resource.Event(EventType filterEventType, IResource resource)
Creates a new event with an associated resource.Event(EventType filterEventType, IResource resource, ISkeleton skeleton)
Creates a new event with an associated resource and a skeleton object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Event
createEndBatchEvent()
Convenience method that creates anEventType.END_BATCH
eventstatic Event
createEndBatchItemEvent()
Convenience method that creates anEventType.END_BATCH_ITEM
eventstatic Event
createNoopEvent()
Convenience method that creates anEventType.NO_OP
eventstatic Event
createStartBatchEvent()
Convenience method that creates anEventType.START_BATCH
eventstatic Event
createStartBatchItemEvent()
Convenience method that creates anEventType.START_BATCH_ITEM
eventDocumentPart
getDocumentPart()
Convenience method returns theIResource
as aDocumentPart
.Ending
getEndGroup()
Ending
getEnding()
Convenience method returns the Ending resource.EndSubfilter
getEndSubfilter()
Convenience method returns theIResource
as aEndSubfilter
.EventType
getEventType()
Gets the type of this event.MultiEvent
getMultiEvent()
Convenience method returns theIResource
as aMultiEvent
.PipelineParameters
getPipelineParameters()
Convenience method returns theIResource
as aPipelineParameters
.RawDocument
getRawDocument()
Convenience method returns theIResource
as aRawDocument
.IResource
getResource()
Gets the resource associated to this event.StartDocument
getStartDocument()
Convenience method returns theIResource
as aStartDocument
.StartGroup
getStartGroup()
Convenience method returns theIResource
as aStartGroup
.StartSubDocument
getStartSubDocument()
Convenience method returns theIResource
as aStartSubDocument
.StartSubfilter
getStartSubfilter()
Convenience method returns theIResource
as aStartSubfilter
.ITextUnit
getTextUnit()
boolean
isDocumentPart()
Convenience method to tell if this Event carries aDocumentPart
boolean
isEndDocument()
Convenience method to tell if this Event carries a documentEnding
boolean
isEndGroup()
Convenience method to tell if this Event carries a groupEnding
boolean
isEndSubDocument()
Convenience method to tell if this Event carries a sub-documentEnding
boolean
isEndSubfilter()
Convenience method to tell if this Event is a SubFilter Groupboolean
isMultiEvent()
Convenience method to tell if this Event is a MULTI_EVENTboolean
isNoop()
boolean
isPipelineParametersEvent()
Indicates if this event carries aPipelineParameters
resource.boolean
isRawDocument()
Convenience method to tell if this Event carries aRawDocument
boolean
isStartBatchItem()
Convenience method to tell if this Event is START_BATCH_ITEMboolean
isStartDocument()
Convenience method to tell if this Event carries aStartDocument
boolean
isStartGroup()
Convenience method to tell if this Event carries aStartGroup
boolean
isStartSubDocument()
Convenience method to tell if this Event carries aStartSubDocument
boolean
isStartSubfilter()
Convenience method to tell if this Event is a SubFilter Groupboolean
isTextUnit()
Convenience method to tell if this Event carries aITextUnit
void
setEventType(EventType filterEventType)
void
setResource(IResource resource)
Sets the resource associated to this event.String
toString()
-
-
-
Constructor Detail
-
Event
public Event()
-
Event
public Event(EventType filterEventType)
Creates a new event without any associated resource. Used for filter events that have no resources such as START and FINISH.- Parameters:
filterEventType
- the type of event to create.
-
Event
public Event(EventType filterEventType, IResource resource)
Creates a new event with an associated resource.- Parameters:
filterEventType
- the type of event to create.resource
- the resource to associate to the event.
-
Event
public Event(EventType filterEventType, IResource resource, ISkeleton skeleton)
Creates a new event with an associated resource and a skeleton object.- Parameters:
filterEventType
- the type of event to create.resource
- the resource to associate to the event.skeleton
- the skeleton to associate to the event.
-
-
Method Detail
-
getEventType
public EventType getEventType()
Gets the type of this event.- Returns:
- the type of this event.
-
getResource
public IResource getResource()
Gets the resource associated to this event.- Returns:
- the resource associated to this event, or null if there is none.
-
setResource
public void setResource(IResource resource)
Sets the resource associated to this event.- Parameters:
resource
- the new resource.
-
setEventType
public void setEventType(EventType filterEventType)
-
isTextUnit
public boolean isTextUnit()
Convenience method to tell if this Event carries aITextUnit
- Returns:
- true if
ITextUnit
, false otherwise
-
isDocumentPart
public boolean isDocumentPart()
Convenience method to tell if this Event carries aDocumentPart
- Returns:
- true if
DocumentPart
, false otherwise
-
isStartGroup
public boolean isStartGroup()
Convenience method to tell if this Event carries aStartGroup
- Returns:
- true if
StartGroup
, false otherwise
-
isEndGroup
public boolean isEndGroup()
Convenience method to tell if this Event carries a groupEnding
- Returns:
- true if group
Ending
, false otherwise
-
isRawDocument
public boolean isRawDocument()
Convenience method to tell if this Event carries aRawDocument
- Returns:
- true if
RawDocument
, false otherwise
-
isStartDocument
public boolean isStartDocument()
Convenience method to tell if this Event carries aStartDocument
- Returns:
- true if
StartDocument
, false otherwise
-
isEndDocument
public boolean isEndDocument()
Convenience method to tell if this Event carries a documentEnding
- Returns:
- true if document
Ending
, false otherwise
-
isStartBatchItem
public boolean isStartBatchItem()
Convenience method to tell if this Event is START_BATCH_ITEM- Returns:
- true if START_BATCH_ITEM, false otherwise
-
isStartSubDocument
public boolean isStartSubDocument()
Convenience method to tell if this Event carries aStartSubDocument
- Returns:
- true if
StartSubDocument
, false otherwise
-
isEndSubDocument
public boolean isEndSubDocument()
Convenience method to tell if this Event carries a sub-documentEnding
- Returns:
- true if sub-document
Ending
, false otherwise
-
isMultiEvent
public boolean isMultiEvent()
Convenience method to tell if this Event is a MULTI_EVENT- Returns:
- true if
MultiEvent
, false otherwise
-
isStartSubfilter
public boolean isStartSubfilter()
Convenience method to tell if this Event is a SubFilter Group- Returns:
- true if
StartSubfilter
, false otherwise
-
isEndSubfilter
public boolean isEndSubfilter()
Convenience method to tell if this Event is a SubFilter Group- Returns:
- true if
StartSubfilter
, false otherwise
-
getTextUnit
public ITextUnit getTextUnit()
Convenience method returns theIResource
as aITextUnit
. The caller should confirm theEvent
type using isTextUnit before calling this method.- Returns:
- the
ITextUnit
- Throws:
OkapiUnexpectedResourceTypeException
- if theIResource
is not aITextUnit
-
getDocumentPart
public DocumentPart getDocumentPart()
Convenience method returns theIResource
as aDocumentPart
. The caller should confirm theEvent
type using isDocumentPart before calling this method.- Returns:
- the
DocumentPart
- Throws:
OkapiUnexpectedResourceTypeException
- if theIResource
is not aDocumentPart
-
getStartGroup
public StartGroup getStartGroup()
Convenience method returns theIResource
as aStartGroup
. The caller should confirm theEvent
type using isStartGroup before calling this method.- Returns:
- the
StartGroup
- Throws:
OkapiUnexpectedResourceTypeException
- if theIResource
is not aStartGroup
-
getEndGroup
public Ending getEndGroup()
Convenience method returns theIResource
as aEnding
. The caller should confirm theEvent
type using isEndGroup before calling this method.- Returns:
- the
Ending
- Throws:
OkapiUnexpectedResourceTypeException
- if theIResource
is not aEnding
-
getEnding
public Ending getEnding()
Convenience method returns the Ending resource.- Returns:
- the Ending resource.
-
getRawDocument
public RawDocument getRawDocument()
Convenience method returns theIResource
as aRawDocument
. The caller should confirm theEvent
type using isRawDocument before calling this method.- Returns:
- the
RawDocument
- Throws:
OkapiUnexpectedResourceTypeException
- if theIResource
is not aRawDocument
-
getStartSubDocument
public StartSubDocument getStartSubDocument()
Convenience method returns theIResource
as aStartSubDocument
. The caller should confirm theEvent
type using isStartSubDocument before calling this method.- Returns:
- the
StartSubDocument
- Throws:
OkapiUnexpectedResourceTypeException
- if theIResource
is not aStartSubDocument
-
getStartDocument
public StartDocument getStartDocument()
Convenience method returns theIResource
as aStartDocument
. The caller should confirm theEvent
type using isStartDocument before calling this method.- Returns:
- the
StartDocument
- Throws:
OkapiUnexpectedResourceTypeException
- if theIResource
is not aStartDocument
-
getStartSubfilter
public StartSubfilter getStartSubfilter()
Convenience method returns theIResource
as aStartSubfilter
. The caller should confirm theEvent
type using isStartSubfilter before calling this method.- Returns:
- the
StartSubfilter
- Throws:
OkapiUnexpectedResourceTypeException
- if theIResource
is not aStartSubfilter
-
getEndSubfilter
public EndSubfilter getEndSubfilter()
Convenience method returns theIResource
as aEndSubfilter
. The caller should confirm theEvent
type using isEndSubfilter before calling this method.- Returns:
- the
EndSubfilter
- Throws:
OkapiUnexpectedResourceTypeException
- if theIResource
is not aEndSubfilter
-
getMultiEvent
public MultiEvent getMultiEvent()
Convenience method returns theIResource
as aMultiEvent
. The caller should confirm theEventType
using isMultiEvent before calling this method.- Returns:
- the
MultiEvent
- Throws:
OkapiUnexpectedResourceTypeException
- if theIResource
is not aMultiEvent
-
isPipelineParametersEvent
public boolean isPipelineParametersEvent()
Indicates if this event carries aPipelineParameters
resource.- Returns:
- true if this event carries a
PipelineParameters
resource, false otherwise.
-
getPipelineParameters
public PipelineParameters getPipelineParameters()
Convenience method returns theIResource
as aPipelineParameters
.- Returns:
- the
PipelineParameters
- Throws:
OkapiUnexpectedResourceTypeException
- if theIResource
is not aPipelineParameters
-
isNoop
public boolean isNoop()
-
createEndBatchEvent
public static final Event createEndBatchEvent()
Convenience method that creates anEventType.END_BATCH
event
-
createEndBatchItemEvent
public static final Event createEndBatchItemEvent()
Convenience method that creates anEventType.END_BATCH_ITEM
event
-
createNoopEvent
public static final Event createNoopEvent()
Convenience method that creates anEventType.NO_OP
event
-
createStartBatchEvent
public static final Event createStartBatchEvent()
Convenience method that creates anEventType.START_BATCH
event
-
createStartBatchItemEvent
public static final Event createStartBatchItemEvent()
Convenience method that creates anEventType.START_BATCH_ITEM
event
-
-