torero.model
Class SymbolMap

java.lang.Object
  |
  +--torero.model.SymbolMap
All Implemented Interfaces:
Serializable

public class SymbolMap
extends Object
implements Serializable

The SymbolMap is a collection used for creation and lookup of Symbols for a specific grammar. It ensures the uniqueness of the Symbols defined in it.

See Also:
Serialized Form

Constructor Summary
SymbolMap()
           
 
Method Summary
 boolean contains(String symname)
          Returns true if a Symbol with that name exists.
 Epsilon getEpsilon()
          Returns the Epsilon Symbol of this SymbolMap.
 Iterator getSymbolIterator()
          Returns all Symbols in this SymbolMap as Iterator.
 Collection getSymbols()
          Returns all Symbols in this SymbolMap as Collection.
 int getSymbolSize()
          Returns the number of Symbols in this SymbolMap.
 Nonterm obtainNonterm(String name)
          If a Nonterm with the given name already exists it's given back - otherwhise a new one is created and given back.
 Symbol obtainSymbol(String name)
          If a Nonterm with the given name already exists it's given back - otherwhise a new one is created and given back.
 Token obtainToken(String name, String word)
          If a token with the given name already exists its given back - otherwhise a new one is created and given back.
 String toString()
          Returns String representation for this Symbol.
protected  void updateEntry(Symbol symbol, String oldname)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SymbolMap

public SymbolMap()
Method Detail

getEpsilon

public Epsilon getEpsilon()
Returns the Epsilon Symbol of this SymbolMap.
Returns:
returns the Epsilon Symbol of this SymbolMap

obtainToken

public Token obtainToken(String name,
                         String word)
If a token with the given name already exists its given back - otherwhise a new one is created and given back. If a NonTerm with the given name already exists null is returned.
Parameters:
name - takes the Name of the token that should be obtained.
word - takes the word expression the (new) token should have.
Returns:
a Token or null

contains

public boolean contains(String symname)
Returns true if a Symbol with that name exists.
Returns:
returns true if a Symbol with that name exists

obtainNonterm

public Nonterm obtainNonterm(String name)
If a Nonterm with the given name already exists it's given back - otherwhise a new one is created and given back. If a Token with the given name already exists null is returned.
Parameters:
name - takes the Name of the Nonterm that should be obtained.
Returns:
a Nonterm or null

obtainSymbol

public Symbol obtainSymbol(String name)
If a Nonterm with the given name already exists it's given back - otherwhise a new one is created and given back. If a Token with the given name already exists it's returned.
Parameters:
name - takes the Name of the Symbol that should be obtained.
Returns:
an existing Token or a new Nonterm as Symbol

toString

public String toString()
Returns String representation for this Symbol.
Overrides:
toString in class Object
Returns:
the String representation for this Symbol

getSymbolIterator

public Iterator getSymbolIterator()
Returns all Symbols in this SymbolMap as Iterator.
Returns:
returns all Symbols in this SymbolMap as Iterator

getSymbolSize

public int getSymbolSize()
Returns the number of Symbols in this SymbolMap.
Returns:
returns the number of Symbols in this SymbolMap

getSymbols

public Collection getSymbols()
Returns all Symbols in this SymbolMap as Collection.
Returns:
returns all Symbols in this SymbolMap as Collection.

updateEntry

protected void updateEntry(Symbol symbol,
                           String oldname)