com.languagecomputer.api.text
Class DefaultAttribute

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

public class DefaultAttribute
extends DefaultText
implements Attribute

Default implementation of an Attribute.

Since:
1.0
Author:
Kirk Roberts

Field Summary
 
Fields inherited from interface com.languagecomputer.api.text.Attribute
TYPE
 
Constructor Summary
DefaultAttribute()
          Creates a new DefaultAttribute.
 
Method Summary
 void addRole(String roleName, Text text)
          Adds a role instance to this Attribute.
 Set<String> getAvailableRoles()
          Returns the set role types that are available for this Attribute instance.
 Collection<Text> getRoles(String roleName)
          Returns the Text of the role instances for this Attribute with the given roleName.
 String getType()
          Returns the type of this Attribute.
 void setAnnotationType(AnnotationType annType)
          Not necessary: defaults to Attribute.TYPE.
 void setType(String type)
          Sets the type of this Attribute.
 String toString()
          Returns a String representation of a DefaultAttribute.
 
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

DefaultAttribute

public DefaultAttribute()
Creates a new DefaultAttribute.

Method Detail

setAnnotationType

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

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

setType

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

Parameters:
type - Name for this type of DefaultAttribute.
See Also:
Attribute.getType()

getType

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

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

addRole

public void addRole(String roleName,
                    Text text)
Adds a role instance to this Attribute. 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 Attribute instance. There may be more types of roles for this type of attribute, 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 Attribute. 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 Attribute, but the caller should also be able to handle the case where this Attribute only knows about the role names based on what roles objects are actually attached to it.

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

getRoles

public Collection<Text> getRoles(String roleName)
Returns the Text of the role instances for this Attribute 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 Attribute
Parameters:
roleName - The name of the role to get the instances of.
Returns:
A Collection of Texts for all the roles instances associated with this Attribute with the given roleName, or an empty Collection if none exist.

toString

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

Overrides:
toString in class DefaultText


Copyright © 2009. All Rights Reserved.