gov.sandia.cognition.text.token
Class DefaultToken

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.text.AbstractOccurrenceInText<Term>
          extended by gov.sandia.cognition.text.token.DefaultToken
All Implemented Interfaces:
OccurrenceInText<Term>, Termable, TermOccurrence, Token, CloneableSerializable, Serializable, Cloneable

public class DefaultToken
extends AbstractOccurrenceInText<Term>
implements Token

A default implementation of the Token interface. It just stores the text of the token as a String.

Since:
3.0
Author:
Justin Basilico
See Also:
Serialized Form

Field Summary
 
Fields inherited from class gov.sandia.cognition.text.AbstractOccurrenceInText
DEFAULT_LENGTH, DEFAULT_START, length, start
 
Constructor Summary
DefaultToken()
          Creates a new Token.
DefaultToken(String text, int start)
          Creates a new Token with the given text.
DefaultToken(String text, int start, int length)
          Creates a new Token with the given text, start, and length.
 
Method Summary
 DefaultTerm asTerm()
          Tokens always are treated as DefaultTerm objects that contain the text of the Token.
 DefaultTerm getData()
          Gets the data that occurred in the text.
 DefaultTerm getTerm()
          Gets the term that occurred in the text.
 String getText()
          Gets the text of the token.
 void setText(String text)
          Sets the text of the token.
 String toString()
          The text of the token.
 
Methods inherited from class gov.sandia.cognition.text.AbstractOccurrenceInText
getLength, getStart, setLength, setStart
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.text.OccurrenceInText
getLength, getStart
 

Constructor Detail

DefaultToken

public DefaultToken()
Creates a new Token. The text defaults to null.


DefaultToken

public DefaultToken(String text,
                    int start)
Creates a new Token with the given text. The length is assumed to be the length of the text.

Parameters:
text - The text of the token.
start - The starting point of the token in its source.

DefaultToken

public DefaultToken(String text,
                    int start,
                    int length)
Creates a new Token with the given text, start, and length.

Parameters:
text - The text of the token.
start - The starting point of the token in its source.
length - The length of the token in the source.
Method Detail

getData

public DefaultTerm getData()
Description copied from interface: OccurrenceInText
Gets the data that occurred in the text.

Specified by:
getData in interface OccurrenceInText<Term>
Returns:
The data that occurred.

asTerm

public DefaultTerm asTerm()
Description copied from interface: Token
Tokens always are treated as DefaultTerm objects that contain the text of the Token.

Specified by:
asTerm in interface Termable
Specified by:
asTerm in interface Token
Returns:
A DefaultTerm containing the text of the token.

getTerm

public DefaultTerm getTerm()
Description copied from interface: TermOccurrence
Gets the term that occurred in the text.

Specified by:
getTerm in interface TermOccurrence
Returns:
The term that occurred in the text.

getText

public String getText()
Description copied from interface: Token
Gets the text of the token.

Specified by:
getText in interface Token
Returns:
The text of the token.

setText

public void setText(String text)
Sets the text of the token.

Parameters:
text - The text of the token.

toString

public String toString()
The text of the token.

Overrides:
toString in class Object
Returns:
The text of the token.