gov.sandia.cognition.text.term
Class AbstractTermIndex

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.text.term.AbstractTermIndex
All Implemented Interfaces:
TermIndex, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
DefaultTermIndex

public abstract class AbstractTermIndex
extends AbstractCloneableSerializable
implements TermIndex

An abstract implementation of the TermIndex class that handles a lot of the convenience method implementations.

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

Constructor Summary
AbstractTermIndex()
          Creates a new AbstractTermIndex.
 
Method Summary
 IndexedTerm add(Termable termable)
          Adds the given term to the index.
 void addAll(Iterable<? extends Termable> terms)
          Adds all of the given terms to the index, if they are not already part of it.
 int getIndex(Term term)
          Gets the index of the given term.
 int getIndex(Termable termable)
          Gets the index of the given term.
 IndexedTerm getIndexedTerm(Termable termable)
          Gets the index-term pair for the given term, if it is in the index.
 Term getTerm(int index)
          Gets the term associated with the given index.
 boolean hasIndex(int index)
          Determines if the term index contains the given index.
 boolean hasIndexedTerm(IndexedTerm indexedTerm)
          Determines if the given indexed term matches the term at the given index value in this term index.
 boolean hasTerm(Term term)
          Determines if the index contains the given term.
 boolean hasTerm(Termable termable)
          Determines if the index contains the given term.
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.text.term.TermIndex
add, getIndexedTerm, getIndexedTerm, getTermCount, getTerms
 

Constructor Detail

AbstractTermIndex

public AbstractTermIndex()
Creates a new AbstractTermIndex.

Method Detail

getIndexedTerm

public IndexedTerm getIndexedTerm(Termable termable)
Description copied from interface: TermIndex
Gets the index-term pair for the given term, if it is in the index. Otherwise, null is returned.

Specified by:
getIndexedTerm in interface TermIndex
Parameters:
termable - The term to get the index-term pair for.
Returns:
The index-term pair for the given term, if it is in the index. Otherwise, null.

hasIndexedTerm

public boolean hasIndexedTerm(IndexedTerm indexedTerm)
Description copied from interface: TermIndex
Determines if the given indexed term matches the term at the given index value in this term index.

Specified by:
hasIndexedTerm in interface TermIndex
Parameters:
indexedTerm - An index-term pair.
Returns:
True if the given index-term pair is an exact match for the term at the given index in this index. Otherwise, false.

hasTerm

public boolean hasTerm(Termable termable)
Description copied from interface: TermIndex
Determines if the index contains the given term.

Specified by:
hasTerm in interface TermIndex
Parameters:
termable - The term.
Returns:
True if the term is in the index and false otherwise.

hasTerm

public boolean hasTerm(Term term)
Description copied from interface: TermIndex
Determines if the index contains the given term.

Specified by:
hasTerm in interface TermIndex
Parameters:
term - The term.
Returns:
True if the term is in the index and false otherwise.

hasIndex

public boolean hasIndex(int index)
Description copied from interface: TermIndex
Determines if the term index contains the given index.

Specified by:
hasIndex in interface TermIndex
Parameters:
index - An index.
Returns:
True if if is a valid index. Otherwise, false.

getIndex

public int getIndex(Termable termable)
Description copied from interface: TermIndex
Gets the index of the given term. If it is not in the index, -1 is returned.

Specified by:
getIndex in interface TermIndex
Parameters:
termable - The term to get the index of.
Returns:
The index of the term, if is is in the index; otherwise, -1.

getIndex

public int getIndex(Term term)
Description copied from interface: TermIndex
Gets the index of the given term. If it is not in the index, -1 is returned.

Specified by:
getIndex in interface TermIndex
Parameters:
term - The term to get the index of.
Returns:
The index of the term, if is is in the index; otherwise, -1.

getTerm

public Term getTerm(int index)
Description copied from interface: TermIndex
Gets the term associated with the given index. If there is no term, null is returned.

Specified by:
getTerm in interface TermIndex
Parameters:
index - The index to get the term for.
Returns:
The term at the given index, if there is a term; otherwise, null.

add

public IndexedTerm add(Termable termable)
Description copied from interface: TermIndex
Adds the given term to the index. The returned value will be the index of that term and if it is not in the index already, it will be added.

Specified by:
add in interface TermIndex
Parameters:
termable - The term to add.
Returns:
The index of the term.

addAll

public void addAll(Iterable<? extends Termable> terms)
Description copied from interface: TermIndex
Adds all of the given terms to the index, if they are not already part of it.

Specified by:
addAll in interface TermIndex
Parameters:
terms - The terms to add to the index.