com.languagecomputer.api.text
Class DefaultEvent

java.lang.Object
  extended by com.languagecomputer.api.text.DefaultText
      extended by com.languagecomputer.api.text.DefaultEvent
All Implemented Interfaces:
Event, Text

public class DefaultEvent
extends DefaultText
implements Event

Default implementation of an Event.

Since:
1.0
Author:
Kirk Roberts
See Also:
DefaultText

Field Summary
 
Fields inherited from interface com.languagecomputer.api.text.Event
TYPE
 
Constructor Summary
DefaultEvent()
          Creates a new DefaultEvent.
 
Method Summary
 void addRole(String roleName, Text text)
          Adds a role instance to this Event.
 Set<String> getAvailableRoles()
          Returns the set role types that are available for this Event instance.
 Collection<Text> getRoles(String roleName)
          Returns the Text of the roles instances for this Event with the given roleName.
 String getType()
          Returns the type of this Event.
 void setAnnotationType(AnnotationType annType)
          Not necessary: defaults to Event.TYPE.
 void setType(String type)
          Sets the type of this Event.
 String toString()
          Returns a String representation of a DefaultEvent.
 
Methods inherited from class com.languagecomputer.api.text.DefaultText
getAnnotationType, getCongruentAnnotations, getDocument, getDocumentID, getEndCharOffset, getIntersectingAnnotations, getRawString, getStartCharOffset, getSubAnnotations, getSuperAnnotations, setDocument, setEndCharOffset, setRawString, setStartCharOffset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.languagecomputer.api.text.Text
getAnnotationType, getCongruentAnnotations, getDocument, getDocumentID, getEndCharOffset, getIntersectingAnnotations, getRawString, getStartCharOffset, getSubAnnotations, getSuperAnnotations
 

Constructor Detail

DefaultEvent

public DefaultEvent()
Creates a new DefaultEvent.

Method Detail

setAnnotationType

public void setAnnotationType(AnnotationType annType)
Not necessary: defaults to Event.TYPE.

Overrides:
setAnnotationType in class DefaultText
Parameters:
annType - AnnotationType to use for this DefaultEvent.
See Also:
Text.getAnnotationType(), AnnotationType

setType

public void setType(String type)
Sets the type of this Event.

Parameters:
type - Name for this type of DefaultEvent.
See Also:
Event.getType()

getType

public String getType()
Returns the type of this Event.

Specified by:
getType in interface Event
Returns:
This Event's type (or name).

addRole

public void addRole(String roleName,
                    Text text)
Adds a role instance to this Event. If the Text is null, then the role name will be added but the text will be ignored.

Parameters:
roleName - Name for this new role instance.
text - Text span for this new role instance.
Throws:
IllegalArgumentException - If the roleName is null.
See Also:
getAvailableRoles(), getRoles(String)

getAvailableRoles

public Set<String> getAvailableRoles()
Returns the set role types that are available for this Event instance. There may be more types of roles for this type of event, but this method will only return the types of roles that it knows about. Furthermore, it is not guaranteed that all available roles have an instance of that role attached to this Event. In other words, if a system knows all the possible role names, it may return them here even if not all the roles are found within this Event, but the caller should also be able to handle the case where this Event only knows about the role names based on what roles objects are actually attached to it.

Specified by:
getAvailableRoles in interface Event
Returns:
A Set of role names that are known to this Event instance.

getRoles

public Collection<Text> getRoles(String roleName)
Returns the Text of the roles instances for this Event with the given roleName. For many roles, this will be a singleton Collection, but having multiple roles of the same type is supported as well.

Specified by:
getRoles in interface Event
Parameters:
roleName - Name of the role to get the instances of.
Returns:
A Collection of Texts for all the roles associated with this Event with the given roleName, or an empty Collection if none exist.

toString

public String toString()
Returns a String representation of a DefaultEvent.

Overrides:
toString in class DefaultText


Copyright © 2009. All Rights Reserved.