org.biojava.bio.seq.io
Class NameTokenization

java.lang.Object
  extended by org.biojava.utils.Unchangeable
      extended by org.biojava.bio.seq.io.WordTokenization
          extended by org.biojava.bio.seq.io.NameTokenization
All Implemented Interfaces:
java.io.Serializable, Annotatable, SymbolTokenization, Changeable

public class NameTokenization
extends WordTokenization

Simple implementation of SymbolTokenization which uses the `name' field of the symbols. This class works with any non-cross-product FiniteAlphabet, and doesn't need any extra data to be provided.

Since:
1.2
Author:
Thomas Down
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.biojava.bio.seq.io.SymbolTokenization
SymbolTokenization.TokenType
 
Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
Annotatable.AnnotationForwarder
 
Field Summary
 
Fields inherited from interface org.biojava.bio.seq.io.SymbolTokenization
CHARACTER, FIXEDWIDTH, SEPARATED, UNKNOWN
 
Fields inherited from interface org.biojava.bio.Annotatable
ANNOTATION
 
Constructor Summary
NameTokenization(FiniteAlphabet fab)
          Construct a new NameTokenization, defaulting to case-insensitive.
NameTokenization(FiniteAlphabet fab, boolean caseSensitive)
           
 
Method Summary
protected  void finalize()
           
protected  java.util.Map getNameToSymbol()
           
 Symbol parseToken(java.lang.String token)
          Returns the symbol for a single token.
 java.lang.String tokenizeSymbol(Symbol s)
          Return a token representing a single symbol.
 
Methods inherited from class org.biojava.bio.seq.io.WordTokenization
getAlphabet, getAnnotation, getTokenType, parseStream, parseString, splitString, tokenizeSymbolList
 
Methods inherited from class org.biojava.utils.Unchangeable
addChangeListener, addChangeListener, addForwarder, getForwarders, getListeners, isUnchanging, removeChangeListener, removeChangeListener, removeForwarder
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
 

Constructor Detail

NameTokenization

public NameTokenization(FiniteAlphabet fab,
                        boolean caseSensitive)

NameTokenization

public NameTokenization(FiniteAlphabet fab)
Construct a new NameTokenization, defaulting to case-insensitive.

Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getNameToSymbol

protected java.util.Map getNameToSymbol()

parseToken

public Symbol parseToken(java.lang.String token)
                  throws IllegalSymbolException
Description copied from interface: SymbolTokenization
Returns the symbol for a single token.

The Symbol will be a member of the alphabet. If the token is not recognized as mapping to a symbol, an exception will be thrown.

Parameters:
token - the token to retrieve a Symbol for
Returns:
the Symbol for that token
Throws:
IllegalSymbolException - if there is no Symbol for the token

tokenizeSymbol

public java.lang.String tokenizeSymbol(Symbol s)
                                throws IllegalSymbolException
Description copied from interface: SymbolTokenization
Return a token representing a single symbol.

Parameters:
s - The symbol
Throws:
IllegalSymbolException - if the symbol isn't recognized.