net.sf.okapi.common
Class Event

java.lang.Object
  extended by net.sf.okapi.common.Event

public class Event
extends java.lang.Object

Represents an event generated by a filter that implements IFilter.


Field Summary
static Event END_BATCH_EVENT
           
static Event NOOP_EVENT
           
 
Constructor Summary
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
 DocumentPart getDocumentPart()
          Convenience method returns the IResource as a DocumentPart.
 Ending getEndGroup()
          Convenience method returns the IResource as a Ending.
 Ending getEnding()
          Convenience method returns the Ending resource.
 EventType getEventType()
          Gets the type of this event.
 MultiEvent getMultiEvent()
          Convenience method returns the IResource as a MultiEvent.
 PipelineParameters getPipelineParameters()
          Convenience method returns the IResource as a PipelineParameters.
 RawDocument getRawDocument()
          Convenience method returns the IResource as a RawDocument.
 IResource getResource()
          Gets the resource associated to this event.
 StartDocument getStartDocument()
          Convenience method returns the IResource as a StartDocument.
 StartGroup getStartGroup()
          Convenience method returns the IResource as a StartGroup.
 ITextUnit getTextUnit()
          Convenience method returns the IResource as a ITextUnit.
 boolean isDocumentPart()
          Convenience method to tell if this Event carries a DocumentPart
 boolean isEndGroup()
          Convenience method to tell if this Event carries a group Ending
 boolean isMultiEvent()
          Convenience method to tell if this Event is a MULTI_EVENT
 boolean isNoop()
           
 boolean isPipelineParametersEvent()
          Indicates if this event carries a PipelineParameters resource.
 boolean isRawDocument()
          Convenience method to tell if this Event carries a RawDocument
 boolean isStartDocument()
          Convenience method to tell if this Event carries a StartDocument
 boolean isStartGroup()
          Convenience method to tell if this Event carries a StartGroup
 boolean isTextUnit()
          Convenience method to tell if this Event carries a ITextUnit
 void setResource(IResource resource)
          Sets the resource associated to this event.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

END_BATCH_EVENT

public static final Event END_BATCH_EVENT

NOOP_EVENT

public static final Event NOOP_EVENT
Constructor Detail

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.


isTextUnit

public boolean isTextUnit()
Convenience method to tell if this Event carries a ITextUnit

Returns:
true if ITextUnit, false otherwise

isDocumentPart

public boolean isDocumentPart()
Convenience method to tell if this Event carries a DocumentPart

Returns:
true if DocumentPart, false otherwise

isStartGroup

public boolean isStartGroup()
Convenience method to tell if this Event carries a StartGroup

Returns:
true if StartGroup, false otherwise

isEndGroup

public boolean isEndGroup()
Convenience method to tell if this Event carries a group Ending

Returns:
true if group Ending, false otherwise

isRawDocument

public boolean isRawDocument()
Convenience method to tell if this Event carries a RawDocument

Returns:
true if RawDocument, false otherwise

isStartDocument

public boolean isStartDocument()
Convenience method to tell if this Event carries a StartDocument

Returns:
true if StartDocument, false otherwise

isMultiEvent

public boolean isMultiEvent()
Convenience method to tell if this Event is a MULTI_EVENT

Returns:
true if MultiEvent, false otherwise

getTextUnit

public ITextUnit getTextUnit()
Convenience method returns the IResource as a ITextUnit. The caller should confirm the Event type using isTextUnit before calling this method.

Returns:
the ITextUnit
Throws:
OkapiUnexpectedResourceTypeException - if the IResource is not a ITextUnit

getDocumentPart

public DocumentPart getDocumentPart()
Convenience method returns the IResource as a DocumentPart. The caller should confirm the Event type using isDocumentPart before calling this method.

Returns:
the DocumentPart
Throws:
OkapiUnexpectedResourceTypeException - if the IResource is not a DocumentPart

getStartGroup

public StartGroup getStartGroup()
Convenience method returns the IResource as a StartGroup. The caller should confirm the Event type using isStartGroup before calling this method.

Returns:
the StartGroup
Throws:
OkapiUnexpectedResourceTypeException - if the IResource is not a StartGroup

getEndGroup

public Ending getEndGroup()
Convenience method returns the IResource as a Ending. The caller should confirm the Event type using isEndGroup before calling this method.

Returns:
the Ending
Throws:
OkapiUnexpectedResourceTypeException - if the IResource is not a Ending

getEnding

public Ending getEnding()
Convenience method returns the Ending resource.

Returns:
the Ending resource.

getRawDocument

public RawDocument getRawDocument()
Convenience method returns the IResource as a RawDocument. The caller should confirm the Event type using isRawDocument before calling this method.

Returns:
the RawDocument
Throws:
OkapiUnexpectedResourceTypeException - if the IResource is not a RawDocument

getStartDocument

public StartDocument getStartDocument()
Convenience method returns the IResource as a StartDocument. The caller should confirm the Event type using isStartDocument before calling this method.

Returns:
the RawDocument
Throws:
OkapiUnexpectedResourceTypeException - if the IResource is not a RawDocument

getMultiEvent

public MultiEvent getMultiEvent()
Convenience method returns the IResource as a MultiEvent. The caller should confirm the EventType using isMultiEvent before calling this method.

Returns:
the RawDocument
Throws:
OkapiUnexpectedResourceTypeException - if the IResource is not a RawDocument

isPipelineParametersEvent

public boolean isPipelineParametersEvent()
Indicates if this event carries a PipelineParameters resource.

Returns:
true if this event carries a PipelineParameters resource, false otherwise.

getPipelineParameters

public PipelineParameters getPipelineParameters()
Convenience method returns the IResource as a PipelineParameters.

Returns:
the PipelineParameters
Throws:
OkapiUnexpectedResourceTypeException - if the IResource is not a PipelineParameters

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isNoop

public boolean isNoop()