|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jstatcom.model.SymbolTable
public class SymbolTable
This class contains a sorted collection of Symbol
objects that
can easily be accessed.
This class is thread-save. All access to mutable data is synchronized.
Field Summary | |
---|---|
java.lang.String |
NAME
Identifier of this table (always upper case). |
static javolution.xml.XmlFormat<SymbolTable> |
SymbolTable_XML
XML format field for (de)serialization. |
Constructor Summary | |
---|---|
SymbolTable(java.lang.String name)
Creates an empty symbol table with name , and no parent. |
|
SymbolTable(java.lang.String name,
boolean addToTree)
Creates an empty symbol table with name , and no parent. |
|
SymbolTable(java.lang.String name,
SymbolTable parentTable)
Creates an empty symbol table with name and a parent
table. |
|
SymbolTable(java.lang.String name,
SymbolTable parentTable,
boolean addToTree)
Creates an empty symbol table with name and a parent
table. |
Method Summary | |
---|---|
void |
clear()
Removes all elements from this collection. |
boolean |
contains(java.lang.String symbolName)
Gets whether this symbol table contains a symbol with name symbolName . |
Symbol |
get(JSCTypeDef def)
Gets the symbol with def.name . |
JSCData |
getJSCData(JSCTypeDef def)
Gets the JSCData stored in the symbol with given
def.name . |
java.lang.String |
getName()
Gets the name of this symbol table. |
SymbolTable |
getParentTable()
Gets the symbol table that is referenced as a parent of this table. |
Symbol |
getSymbol(java.lang.String name)
Gets the symbol with the given name or null
if none is contained with the given name. |
SymbolTableTreeNode |
getSymbolTableNode()
Gets the symbol table node that represents this table in a SymbolTree . |
boolean |
isEmpty()
Gets whether this list is empty. |
java.util.Iterator |
iterator()
Gets an Iterator for the symbols stored in this
collection. |
boolean |
remove(java.lang.String name)
Removes the symbol with name from this collection. |
void |
set(JSCData data)
Adds a new JSCData object to the collection. |
void |
set(JSCData[] data)
Adds an array of JSCData objects to the collection. |
void |
set(java.lang.String symbolName,
JSCData data)
Adds a new JSCData object to the collection. |
void |
setSymbol(Symbol symbol)
Puts a new symbol into the collection. |
void |
setSymbolTable(SymbolTable table)
Sets the contents of table to this symbol table by
applying the following rules:
if a symbol is only part of table but not of
this , then a new symbol with the same name is created in
this table and the reference to the underlying JSCData
instance is copied
if table and this contain symbols with
the same name, then the reference to the underlying JSCData
instance is copied from the symbol of the argument table to this table
all symbols that are part of this table but not of the argument
table are left untouched
This operation does not change the argument symbol table, but by copying
references its symbols might be affected by operations on this table
afterwards. |
void |
setSymbolTableNode(SymbolTableTreeNode node)
Sets the symbol table node that represents this table in a SymbolTree . |
int |
size()
Gets the number of stored symbols in this collection. |
java.lang.String |
toString()
Returns a string that represents the value of this object. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final java.lang.String NAME
public static final javolution.xml.XmlFormat<SymbolTable> SymbolTable_XML
Constructor Detail |
---|
public SymbolTable(java.lang.String name)
name
, and no parent.
It will be added to the symbol tree.
name
- the identifier of that SymbolTable
public SymbolTable(java.lang.String name, boolean addToTree)
name
, and no parent.
It can optionally be added to the symbol tree.
name
- the identifier of that SymbolTable
addToTree
- if true
then this table will be added to the
symbol tree, otherwise it will not be addedpublic SymbolTable(java.lang.String name, SymbolTable parentTable)
name
and a parent
table. It will be added to the symbol tree.
name
- the identifier of that SymbolTable
parentTable
- the parent table, will be parent node in symbol treepublic SymbolTable(java.lang.String name, SymbolTable parentTable, boolean addToTree)
name
and a parent
table. It can optionally be added to the symbol tree.
name
- the identifier of that SymbolTable
parentTable
- the parent table, will be parent node in symbol treeaddToTree
- if true
then this table will be added to the
symbol tree, otherwise it will not be addedMethod Detail |
---|
public final void set(JSCData[] data)
JSCData
objects to the collection.
data
- the JSCData
array to put
java.lang.IllegalArgumentException
- if (data == null)
data[i].getName()
but with
a different type already existspublic final void set(JSCData data)
JSCData
object to the collection. If a symbol
with the same name as data
is already contained,
data
will be set for that symbol. If no symbol of
data.getName()
is contained, then a new symbol will be
created and added.
data
- the JSCData
object to put
java.lang.IllegalArgumentException
- if (data == null)
data.getName()
but with a
different type already existspublic final void set(java.lang.String symbolName, JSCData data)
JSCData
object to the collection. If a symbol
with the name symbolName
is already contained,
data
will be set for that symbol. If no symbol of
symbolName
is contained, then a new symbol will be created
and added.
symbolName
- the name of the symbol to be createddata
- the JSCData
object to put
java.lang.IllegalArgumentException
- if (data == null || symbolName == null)
symbolName
but with a
different type already exists symbolName
is not a valid name as
defined in JSCConstants
public final void setSymbol(Symbol symbol)
symbol
- the Symbol
object to put
java.lang.IllegalArgumentException
- if (symbol == null)
public final void clear()
Usage Note:
Removing a symbol from the SymbolTable
does not affect any
SymbolListeners
attached to that symbol. They are still
notified about changes in the removed symbol and not informed if a new
symbol with name
is added. You might consider calling
removeAllSymbolListeners
before that symbol is removed if
this is not what you want.
public final boolean contains(java.lang.String symbolName)
symbolName
.
symbolName
- the name of the symbol to check for
true
if contained, false
otherwisepublic final Symbol getSymbol(java.lang.String name)
name
or null
if none is contained with the given name.
Usage Note:
Pleae notice the difference to the typesave get
method.
This does not create a new symbol if it is not contained yet, because it
is not known, which type the new symbol should have.
name
- the identifier for the symbol
java.lang.IllegalArgumentException
- if (name == null)
public final Symbol get(JSCTypeDef def)
def.name
. If a symbol with that name
does not yet exist an empty symbol of the given type is created, added
and returned.
def
- the type definition for the symbol
java.lang.IllegalArgumentException
- if (def == null)
java.lang.RuntimeException
- if the retrieved symbol has a different typepublic final JSCData getJSCData(JSCTypeDef def)
JSCData
stored in the symbol with given
def.name
. If a symbol with that name does not yet exist,
a symbol of the given type is created, added and an empty
JSCData
object is returned.
Instead of calling this method, one of the convenience methods for
special JSCDataTypes
can be used.
def
- the type definition for the symbol
JSCData
that was stored or a new empty data
object
java.lang.IllegalArgumentException
- if (def == null)
java.lang.RuntimeException
- if the retrieved symbol has a different typepublic final java.lang.String getName()
public final boolean isEmpty()
true
if no elements are contained,
false
otherwisepublic final java.util.Iterator iterator()
Iterator
for the symbols stored in this
collection. The iterator is guaranteed to walk through all stored symbols
in alphabetical order, starting with the lowest.
Usage Note:
Clients must deal with synchronization while traversing this iterator,
because this
can change during that operation. The
simplest way is to lock this symbol table during the entire traversal. If
clients can make sure that no other threads access this symbol table
during traversal, locking can be ommitted.
Iterator
for all symbolspublic final boolean remove(java.lang.String name)
name
from this collection. The
case of the name makes no difference.
Usage Note:
Removing a symbol from the SymbolTable
does not affect any
SymbolListeners
attached to that symbol. They are still
notified about changes in the removed symbol and not informed if a new
symbol with name
is added. You might consider calling
removeAllSymbolListeners
before that symbol is removed if
this is not what you want.
name
- the identifier for the symbol to remove.
true
if this list contained the specified element
java.lang.IllegalArgumentException
- if (name == null)
Symbol.equals(java.lang.Object)
public final int size()
public final java.lang.String toString()
toString
in class java.lang.Object
public final SymbolTable getParentTable()
public void setSymbolTableNode(SymbolTableTreeNode node)
SymbolTree
.
node
- to representthis tablepublic SymbolTableTreeNode getSymbolTableNode()
SymbolTree
.
public void setSymbolTable(SymbolTable table)
table
to this symbol table by
applying the following rules:
table
but not of
this
, then a new symbol with the same name is created in
this table and the reference to the underlying JSCData
instance is copied
table
and this
contain symbols with
the same name, then the reference to the underlying JSCData
instance is copied from the symbol of the argument table to this table
This operation does not change the argument symbol table, but by copying references its symbols might be affected by operations on this table afterwards.
This method does not copy any listeners from table
to
this
. Listeners of this table are not changed by this
operation, except that they are notified via events in case of relevant
changes.
table
- the symbol table from which symbol are copied to this table
java.lang.IllegalArgumentException
- if (table == null)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |