gov.sandia.cognition.text.term
Class DefaultIndexedTerm

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.text.term.DefaultIndexedTerm
All Implemented Interfaces:
IndexedTerm, Termable, CloneableSerializable, Serializable, Cloneable

public class DefaultIndexedTerm
extends AbstractCloneableSerializable
implements IndexedTerm

Default implementation of the IndexedTerm interface. It just stores the index and the term.

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

Field Summary
static int DEFAULT_INDEX
          The default index is -1.
protected  int index
          The index of the term.
protected  Term term
          The term.
 
Constructor Summary
DefaultIndexedTerm()
          Creates a new DefaultIndexedTerm with default values.
DefaultIndexedTerm(int index, Term term)
          Creates a new DefaultIndexedTerm with the given index and term.
 
Method Summary
 Term asTerm()
          Get the term for the object.
 DefaultIndexedTerm clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 boolean equals(DefaultIndexedTerm other)
          Determines if this object is equal to the given object.
 boolean equals(Object other)
           
 int getIndex()
          Gets the index associated with the term.
 Term getTerm()
          Gets the term associated with the index.
 int hashCode()
           
protected  void setIndex(int index)
          Sets the index of the term.
protected  void setTerm(Term term)
          Sets the term.
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_INDEX

public static final int DEFAULT_INDEX
The default index is -1.

See Also:
Constant Field Values

index

protected int index
The index of the term.


term

protected Term term
The term.

Constructor Detail

DefaultIndexedTerm

public DefaultIndexedTerm()
Creates a new DefaultIndexedTerm with default values.


DefaultIndexedTerm

public DefaultIndexedTerm(int index,
                          Term term)
Creates a new DefaultIndexedTerm with the given index and term.

Parameters:
index - The index of the term.
term - The term.
Method Detail

clone

public DefaultIndexedTerm clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A clone of this object.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

equals

public boolean equals(DefaultIndexedTerm other)
Determines if this object is equal to the given object. They are equal if they have equal indices and terms.

Parameters:
other - Another object.
Returns:
True if the this is equal to the given object. Otherwise, false.

asTerm

public Term asTerm()
Description copied from interface: Termable
Get the term for the object. This can be either a representation of the object as a term or a term that is part of the object.

Specified by:
asTerm in interface Termable
Returns:
The term representation of the object.

getIndex

public int getIndex()
Description copied from interface: IndexedTerm
Gets the index associated with the term.

Specified by:
getIndex in interface IndexedTerm
Returns:
The index.

setIndex

protected void setIndex(int index)
Sets the index of the term.

Parameters:
index - The index of the term.

getTerm

public Term getTerm()
Description copied from interface: IndexedTerm
Gets the term associated with the index.

Specified by:
getTerm in interface IndexedTerm
Returns:
The term.

setTerm

protected void setTerm(Term term)
Sets the term.

Parameters:
term - The term.

toString

public String toString()
Overrides:
toString in class Object