org.expasy.jpl.commons.collection.symbol
Class AlphabetImpl<T>

java.lang.Object
  extended by org.expasy.jpl.commons.collection.symbol.AlphabetImpl<T>
Type Parameters:
T - the symbol type.
All Implemented Interfaces:
Serializable, Alphabet<T>, AlphabetView<T>

public final class AlphabetImpl<T>
extends Object
implements Alphabet<T>, AlphabetView<T>

An alphabet is a finite set of symbols.

Version:
1.0
Author:
nikitin
See Also:
Serialized Form

Field Summary
protected  Map<Character,TreeView<? extends Symbol<T>>> map
          mapping letter -> symbol tree
protected  Symbol.SymbolType<T> type
          the type of alphabet defined by its symbol type
 
Method Summary
static
<T> AlphabetImpl<T>
fromSymbols(Symbol.SymbolType<T> type, TreeView<? extends Symbol<T>> tree)
          Create an alphabet from the tree of symbols (mapping name -> symbol tree).
 Set<Character> getLetters()
          
 String getRegEx()
          
 Set<Symbol<T>> getSymbolLeaves()
           
 int getSymbolNumber()
           
 Symbol.SymbolType<T> getSymbolType()
           
 boolean hasSymbol(char name)
           
 boolean isTerminalSymbol(Symbol<T> symbol)
           
 Symbol<T> lookupSymbol(char name)
           
 TreeView<? extends Symbol<T>> lookupSymbolNode(char name)
           
static
<T> AlphabetImpl<T>
newInstance(Symbol.SymbolType<T> type)
           
 void registerAllSymbolNodes(TreeView<? extends Symbol<T>> symbolNode)
          Add all nodes including the given tree root in the symbol table
 void registerSymbolNode(TreeView<? extends Symbol<T>> symbolNode)
          Add the given node in the symbol table
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

map

protected Map<Character,TreeView<? extends Symbol<T>>> map
mapping letter -> symbol tree


type

protected Symbol.SymbolType<T> type
the type of alphabet defined by its symbol type

Method Detail

newInstance

public static <T> AlphabetImpl<T> newInstance(Symbol.SymbolType<T> type)

fromSymbols

public static <T> AlphabetImpl<T> fromSymbols(Symbol.SymbolType<T> type,
                                              TreeView<? extends Symbol<T>> tree)
Create an alphabet from the tree of symbols (mapping name -> symbol tree).

Returns:
an alphabet over molecules.

getSymbolType

public final Symbol.SymbolType<T> getSymbolType()

getSymbolLeaves

public final Set<Symbol<T>> getSymbolLeaves()

getLetters

public Set<Character> getLetters()

Specified by:
getLetters in interface AlphabetView<T>
Returns:
the set of letters.

getRegEx

public String getRegEx()

Specified by:
getRegEx in interface AlphabetView<T>
Returns:
the pattern that match this alphabet

registerSymbolNode

public final void registerSymbolNode(TreeView<? extends Symbol<T>> symbolNode)
Description copied from interface: Alphabet
Add the given node in the symbol table

Specified by:
registerSymbolNode in interface Alphabet<T>

registerAllSymbolNodes

public final void registerAllSymbolNodes(TreeView<? extends Symbol<T>> symbolNode)
Description copied from interface: Alphabet
Add all nodes including the given tree root in the symbol table

Specified by:
registerAllSymbolNodes in interface Alphabet<T>

lookupSymbolNode

public final TreeView<? extends Symbol<T>> lookupSymbolNode(char name)
Specified by:
lookupSymbolNode in interface AlphabetView<T>
Returns:
a tree node over symbol of type T

lookupSymbol

public final Symbol<T> lookupSymbol(char name)
Specified by:
lookupSymbol in interface AlphabetView<T>
Returns:
a symbol of type T

getSymbolNumber

public final int getSymbolNumber()
Specified by:
getSymbolNumber in interface AlphabetView<T>
Returns:
the number of symbols

hasSymbol

public boolean hasSymbol(char name)
Specified by:
hasSymbol in interface AlphabetView<T>
Returns:
true if symbol exists

isTerminalSymbol

public boolean isTerminalSymbol(Symbol<T> symbol)

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2012 Swiss Institute of Bioinformatics. All rights reserved.