|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jstatcom.model.Symbol
public class Symbol
The Symbol class represents a variable with a certain type and
name. After initialization it is only possible to store references to
JSCData objects of type. Two symbols are
considered equal if their names are equal, independent of the case.
SymbolListener can savely use Symbol objects to
obtain notification about changes in the underlying JSCData
within the Swing EventDispatchingThread. This is not ensured
if they register themselves as listeners directly to JSCData
objects.
This class is thread-save. All access to mutable data is synchronized.
Subclasses might add new accessor methods for newly declared
JSCData types. The main functionality of a symbol should not
be changed, therefore all methods are declared final.
| Field Summary | |
|---|---|
java.lang.String |
name
Identifier of this symbol. |
java.lang.String |
NAME
Upper case identifier of this symbol. |
static javolution.xml.XmlFormat<Symbol> |
Symbol_XML
XML format field for (de)serialization. |
JSCTypes |
type
Type of this symbol. |
| Constructor Summary | |
|---|---|
Symbol(JSCData data)
Creates a Symbol with data.getName a
reference to data. |
|
Symbol(JSCTypeDef def)
Creates a Symbol with an empty object of the given type. |
|
Symbol(java.lang.String name,
JSCData data)
Creates a Symbol with name and a reference
to data. |
|
| Method Summary | |
|---|---|
void |
addSymbolListener(SymbolListener evtListener)
Convenience method that adds a listener that is notified when changes of type VALUE_CHANGED occur in this object. |
void |
addSymbolListener(SymbolListener evtListener,
SymbolEventTypes evtType)
Adds a listener that is notified when changes of type evtType occur in this object. |
void |
clear()
Clears the underlying JSCData object. |
int |
compareTo(java.lang.Object obj)
Compares two Symbol objects by their uppercase names. |
static void |
copySymbol(Symbol source,
Symbol target)
Moves data and listeners from one symbol to the other. |
java.lang.String |
display()
Displays the underlying JSCData object. |
boolean |
equals(java.lang.Object obj)
Returns true if obj is a
Symbol and has the same name as this, without regarding
the case. |
java.lang.String |
getDescription()
Gets the description of this symbol. |
JSCData |
getJSCData()
Gets a reference to the underlying data object. |
JSCDate |
getJSCDate()
Gets the data as an instance of JSCDate. |
JSCDRange |
getJSCDRange()
Gets the data as an instance of JSCDRange. |
JSCInt |
getJSCInt()
Gets the data as an instance of JSCInt. |
JSCNArray |
getJSCNArray()
Gets the data as an instance of JSCNArray. |
JSCNumber |
getJSCNumber()
Gets the data as an instance of JSCNumber. |
JSCSArray |
getJSCSArray()
Gets the data as an instance of JSCSArray. |
JSCString |
getJSCString()
Gets the data as an instance of JSCString. |
JSCVoid |
getJSCVoid()
Gets the data as an instance of JSCVoid. |
java.util.List |
getListenersForType(SymbolEventTypes evtType)
Gets a list with all registered listeners for evtType. |
int |
hashCode()
Generates a hash code for the receiver. |
boolean |
isEmpty()
Gets whether the underlying JSCData object is empty. |
void |
removeAllSymbolListeners()
Removes all SymbolListener objects from this symbol. |
void |
removeSymbolListener(SymbolListener evtListener)
Removes evtListener from all listener lists. |
void |
setDescription(java.lang.String newDescription)
Sets the description for this symbol. |
void |
setJSCData(JSCData newData)
Sets the reference of this symbol to a new data object. |
java.lang.String |
toString()
Returns a string that represents the value of this object. |
void |
valueChanged(JSCDataEvent evt)
Transforms evt to the respective SymbolEvent
and dispatches it to the SymbolListeners. |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final java.lang.String name
public final java.lang.String NAME
public final JSCTypes type
public static final javolution.xml.XmlFormat<Symbol> Symbol_XML
| Constructor Detail |
|---|
public Symbol(JSCData data)
Symbol with data.getName a
reference to data. The type of this Symbol
is set to data.type.
data - the JSCData object for this Symbol
java.lang.IllegalArgumentException - if (data == null)
public Symbol(java.lang.String name,
JSCData data)
Symbol with name and a reference
to data. The type of this Symbol is set to
data.type.
name - the identifier of the symbol, must satisfy conventions for
variable names defined in JSCConstantsdata - the JSCData object for this Symbol
java.lang.IllegalArgumentException - if (name == null || data == null) or if
name is not validJSCConstants.isValidName(java.lang.String)public Symbol(JSCTypeDef def)
Symbol with an empty object of the given type.
def - the type definition
java.lang.NullPointerException - if (def == null)JSCConstants.isValidName(java.lang.String)| Method Detail |
|---|
public final void addSymbolListener(SymbolListener evtListener)
VALUE_CHANGED occur in this object. All other events
that are fired by this object are not dispatched to
evtListener. This is most common for
SymbolListeners.
evtListener - the listener object that gets notified when an event of type
evtType gets fired
java.lang.IllegalArgumentException - if (evtListener == null)
public final void addSymbolListener(SymbolListener evtListener,
SymbolEventTypes evtType)
evtType occur in this object. All other events that are
fired by this object are not dispatched to evtListener.
evtListener - the listener object that gets notified when an event of type
evtType gets firedevtType - the type of event that evtListener wants to
listen to
java.lang.IllegalArgumentException - if (evtListener == null || evtType == null)public final void clear()
JSCData object. This fires a
EMPTY_STATE and VAL_CHANGED event, if the
data was not empty before.
public final java.lang.String display()
JSCData object.
public final int compareTo(java.lang.Object obj)
Symbol objects by their uppercase names.
compareTo in interface java.lang.Comparableobj - the symbol to be compared, must another Symbol
java.lang.IllegalArgumentException - if (!(obj instanceof Symbol))public final boolean equals(java.lang.Object obj)
true if obj is a
Symbol and has the same name as this, without regarding
the case. This is to ensure that there is only one Symbol
of a given name in a SymbolTable.
equals in class java.lang.Objectobj - the object to compare with
true if these object are equal, false
otherwise.public final java.lang.String getDescription()
"" if no description has
been setpublic final JSCData getJSCData()
Usage note:
The returned data is a reference to the underlying JSCData
object only until a new data object has been set to this symbol. It
should be used read only. Changes that should not affect this symbol must
be made on a copy of the returned object.
JSCData object of type typepublic final JSCDate getJSCDate()
JSCDate.
Usage note:
The returned data is a reference to the underlying JSCData
object only until a new data object has been set to this symbol. It
should be used read only. Changes that should not affect this symbol must
be made on a copy of the returned object.
JSCDate
java.lang.RuntimeException - if (type != JSCTypes.DATE)public final JSCDRange getJSCDRange()
JSCDRange.
Usage note:
The returned data is a reference to the underlying JSCData
object only until a new data object has been set to this symbol. It
should be used read only. Changes that should not affect this symbol must
be made on a copy of the returned object.
JSCDRange
java.lang.RuntimeException - if (type != JSCTypes.DRANGE)public final JSCNArray getJSCNArray()
JSCNArray. If the data is
an instance of JSCNumber or JSCInt a new
1x1 JSCNArray with the single element is returned or an
empty JSCNArray.
Usage note:
The returned data is a reference to the underlying JSCData
object only until a new data object has been set to this symbol. It
should be used read only. Changes that should not affect this symbol must
be made on a copy of the returned object.
JSCNArray
java.lang.RuntimeException - if (type != JSCTypes.NARRAY &&
type != JSCTypes.INT && type != JSCTypes.NUMBER)public final JSCNumber getJSCNumber()
JSCNumber. If the data is
of type INT a new JSCNumber with the
element is returned.
Usage note:
The returned data is a reference to the underlying JSCData
object only until a new data object has been set to this symbol. It
should be used read only. Changes that should not affect this symbol must
be made on a copy of the returned object.
JSCNumber
java.lang.RuntimeException - if (type != JSCTypes.NUMBER && type != JSCTypes.INT)public final JSCInt getJSCInt()
JSCInt.
Usage note:
The returned data is a reference to the underlying JSCData
object only until a new data object has been set to this symbol. It
should be used read only. Changes that should not affect this symbol must
be made on a copy of the returned object.
JSCInt
java.lang.RuntimeException - if (type != JSCTypes.INT)public final JSCSArray getJSCSArray()
JSCSArray. If the data is
an instance of JSCString, a new 1x1
JSCSArray with the single element is returned or an empty
JSCSArray.
Usage note:
The returned data is a reference to the underlying JSCData
object only until a new data object has been set to this symbol. It
should be used read only. Changes that should not affect this symbol must
be made on a copy of the returned object.
JSCSArray
java.lang.RuntimeException - if (type != JSCTypes.SARRAY && type != JSCTypes.STRING)public final JSCString getJSCString()
JSCString. If the data is
an instance of JSCSArray, a JSCString with
the 0:0 element is returned or an empty JSCString.
Usage note:
The returned data is a reference to the underlying JSCData
object only until a new data object has been set to this symbol. It
should be used read only. Changes that should not affect this symbol must
be made on a copy of the returned object.
JSCString
java.lang.RuntimeException - if (type != JSCTypes.STRING && type != JSCTypes.SARRAY)public final JSCVoid getJSCVoid()
JSCVoid.
Usage note:
The returned data is a reference to the underlying JSCData
object only until a new data object has been set to this symbol. It
should be used read only. Changes that should not affect this symbol must
be made on a copy of the returned object.
JSCVoid
java.lang.RuntimeException - if (type != JSCTypes.VOID)public final int hashCode()
hashCode in class java.lang.Objectpublic final boolean isEmpty()
JSCData object is empty.
true if empty, false otherwisepublic void removeAllSymbolListeners()
SymbolListener objects from this symbol.
public final void removeSymbolListener(SymbolListener evtListener)
evtListener from all listener lists.
evtListener - the listener to removepublic java.util.List getListenersForType(SymbolEventTypes evtType)
evtType.
evtType - the event type
evtTypepublic final void setDescription(java.lang.String newDescription)
newDescription - a descriptive string
java.lang.IllegalArgumentException - if description contains / * or * /public final void setJSCData(JSCData newData)
SymbolListener objects are notified via the events:
SymbolEventTypes.REF_CHANGED
SymbolEventTypes.VAL_CHANGED only
if (!newData.isEqual(oldData))
REF_CHANGED event is necessary for tables that listen
to changes in a certain Symbol. They need to change their
model data to newData, otherwise they would continue to
listen to changes in the old data object.
This symbol is removed from the listener list of the previous data object.
newData - reference to the new data object, which must be of type
type
java.lang.IllegalArgumentException - if (newData == null) or
if (newData.type() != type)public final java.lang.String toString()
toString in class java.lang.Objectpublic final void valueChanged(JSCDataEvent evt)
evt to the respective SymbolEvent
and dispatches it to the SymbolListeners.
valueChanged in interface JSCDataListenerevt - the data event
public static void copySymbol(Symbol source,
Symbol target)
if (source == target).
source - to copy fromtarget - to copy to
java.lang.IllegalArgumentException - if an argument is null
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||