net.sourceforge.chaperon.model.symbol
Class SymbolList

java.lang.Object
  extended bynet.sourceforge.chaperon.model.symbol.SymbolList
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, SymbolCollection

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

This class represents a list of symbols.

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

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

Constructor Detail

SymbolList

public SymbolList()
Creates a empty list of symbols.

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 list.

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

removeSymbol

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

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

setSymbol

public void setSymbol(int index,
                      Symbol symbol)
Replace a symbol 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 list 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 the list.

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

isEmpty

public boolean isEmpty()
If this list is empty.

Specified by:
isEmpty in interface SymbolCollection
Returns:
True, if the list 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.

clear

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

Specified by:
clear in interface SymbolCollection

getTerminals

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

Returns:
Set of terminal symbols.

getNonterminals

public SymbolSet getNonterminals()
Return all used non terminal symbols in this list.

Returns:
Set of nonterminal symbols.

equals

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

Specified by:
equals in interface SymbolCollection
Parameters:
o - Another object.
Returns:
True, if both lists contains the same symbols.

toString

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

Specified by:
toString in interface SymbolCollection
Returns:
String representation of the list.

clone

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

Returns:
Clone of this list.
Throws:
java.lang.CloneNotSupportedException - If a exception occurs during the cloning.


Copyright ? 2003 Chaperon project. All Rights Reserved.