net.sourceforge.chaperon.model.symbol
Class SymbolSet

java.lang.Object
  extended by net.sourceforge.chaperon.model.symbol.SymbolSet
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, SymbolCollection

public class SymbolSet
extends java.lang.Object
implements SymbolCollection, java.io.Serializable, java.lang.Cloneable

This class represents a set of symbols, which means that this set dosn't contains duplett of symbols.

Version:
CVS $Id: SymbolSet.java,v 1.8 2003/12/09 19:55:53 benedikta Exp $
Author:
Stephan Michels
See Also:
Serialized Form

Constructor Summary
SymbolSet()
           
 
Method Summary
 boolean addSymbol(Symbol symbol)
           
 boolean addSymbol(SymbolCollection collection)
           
 void clear()
          Removes all symbols from this set.
 java.lang.Object clone()
          Create a clone of this set of symbols
 boolean contains(java.lang.String name)
          If the list contains a symbol, given by the name of the symbol.
 boolean contains(Symbol symbol)
          If the list contains a symbol
 boolean contains(SymbolCollection collection)
           
 boolean equals(java.lang.Object o)
          Compares to another set of symbols.
 SymbolSet getNonterminals()
          Return all used nonterminal symbols in this set.
 Symbol getSymbol(int index)
          Return a symbol giving by an index.
 Symbol getSymbol(java.lang.String name)
          Returns a symbol from this set given by the name of the symbol.
 int getSymbolCount()
          Returns the count of symbols in this set
 SymbolSet getTerminals()
          Return all used terminal symbols in this set.
 int indexOf(java.lang.String name)
          Return the index of a symbol, given by the name of the Symbol.
 int indexOf(Symbol symbol)
          Return the index of a symbol.
 boolean isEmpty()
          If this set is empty.
 void removeSymbol(int index)
          Removes a symbol by an index from this set.
 void removeSymbol(Symbol symbol)
          Removes a symbol from this set.
 void setSymbol(int index, Symbol symbol)
          Replace a symbol given by an index.
 java.lang.String toString()
          Return a string representation of the set.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SymbolSet

public SymbolSet()
Method Detail

addSymbol

public boolean addSymbol(Symbol symbol)
Specified by:
addSymbol in interface SymbolCollection

addSymbol

public boolean addSymbol(SymbolCollection collection)
Specified by:
addSymbol in interface SymbolCollection

removeSymbol

public void removeSymbol(int index)
Removes a symbol by an index from this set.

Specified by:
removeSymbol in interface SymbolCollection
Parameters:
index - Index of the symbol.

removeSymbol

public void removeSymbol(Symbol symbol)
Removes a symbol from this set.

Specified by:
removeSymbol in interface SymbolCollection
Parameters:
symbol - Symbol, which should be removed.

setSymbol

public void setSymbol(int index,
                      Symbol symbol)
Replace a symbol given by an index.

Specified by:
setSymbol in interface SymbolCollection
Parameters:
index - The index, at which the symbol be inserted.
symbol - Symbol.

getSymbol

public Symbol getSymbol(int index)
Return a symbol giving by an index.

Specified by:
getSymbol in interface SymbolCollection
Parameters:
index - Index of the symbol.
Returns:
Symbol.

getSymbol

public Symbol getSymbol(java.lang.String name)
Returns a symbol from this set given by the name of the symbol.

Specified by:
getSymbol in interface SymbolCollection
Parameters:
name - Name of the symbol.
Returns:
Symbol.

getSymbolCount

public int getSymbolCount()
Returns the count of symbols in this set

Specified by:
getSymbolCount in interface SymbolCollection
Returns:
Count of symbols.

isEmpty

public boolean isEmpty()
If this set is empty.

Specified by:
isEmpty in interface SymbolCollection
Returns:
True, if the set is empty.

indexOf

public int indexOf(Symbol symbol)
Return the index of a symbol.

Specified by:
indexOf in interface SymbolCollection
Parameters:
symbol - Symbol.
Returns:
Index of this symbol.

indexOf

public int indexOf(java.lang.String name)
Return the index of a symbol, given by the name of the Symbol.

Specified by:
indexOf in interface SymbolCollection
Parameters:
name - Name of symbol.
Returns:
Index of this symbol.

contains

public boolean contains(Symbol symbol)
If the list contains a symbol

Specified by:
contains in interface SymbolCollection
Parameters:
symbol - Symbol
Returns:
True, if the list contains the symbol

contains

public boolean contains(java.lang.String name)
If the list contains a symbol, given by the name of the symbol.

Specified by:
contains in interface SymbolCollection
Parameters:
name - Name of the symbol.
Returns:
True, if the list contains the symbol.

contains

public boolean contains(SymbolCollection collection)

clear

public void clear()
Removes all symbols from this set.

Specified by:
clear in interface SymbolCollection

getTerminals

public SymbolSet getTerminals()
Return all used terminal symbols in this set.

Returns:
List of terminal symbols.

getNonterminals

public SymbolSet getNonterminals()
Return all used nonterminal symbols in this set.

Returns:
List of nonterminal symbols.

equals

public boolean equals(java.lang.Object o)
Compares to another set of symbols.

Specified by:
equals in interface SymbolCollection
Overrides:
equals in class java.lang.Object
Parameters:
o - Another object.
Returns:
True, if both sets contains the same symbols.

toString

public java.lang.String toString()
Return a string representation of the set.

Specified by:
toString in interface SymbolCollection
Overrides:
toString in class java.lang.Object
Returns:
String representation of the set.

clone

public java.lang.Object clone()
Create a clone of this set of symbols

Overrides:
clone in class java.lang.Object
Returns:
Clone of this set.
Throws:
java.lang.CloneNotSupportedException - If a exception occurs during the cloning.


Copyright ? 2003 Chaperon project. All Rights Reserved.