|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jstatcom.model.AbstractJSCData
com.jstatcom.model.JSCVoid
public final class JSCVoid
An object wrapper that conforms to the JSCData interface.
Arbitrary objects can be stored. This class is meant to store special purpose
objects that are not easily generalized. It can be used to easily pass
references to those objects via the symbol table.
Because nothing is known about the underlying value except that it is an
Object, no special purpose methods are provided.
Example:
An example usage would be to store an object that represents the state of a
certain model, say ModelState. This state object could be
immutable and this wrapper notifies listeners whenever a new
ModelState has been set. JSCVoid makes it also
possible to assign a Symbol for that state object and to store
it in a SymbolTable.
Usage Note:
Instances can only be (de)serialized, if the stored value is itself XML
serializable, see javolution.xml.XmlFormat.
Comparisons between the stored values rely on the equals
method of Object. If a logical check for equality is
preferred to a pure reference check, then the class of the value object
should overwrite equal (and hashCode to keep
the contract).
Whenever the value of this data object changes (by setting a new object),
registered JSCDataListeners are notified via a
JSCDataEvent. If not otherwise stated, the event objects
always contain the values before the change and after the change.
This class is thread-safe. All access to mutable data is synchronized. All events are fired outside the synchronized blocks.
| Field Summary | |
|---|---|
static javolution.xml.XmlFormat<JSCVoid> |
JSCVoid_XML
XML format field for (de)serialization. |
| Constructor Summary | |
|---|---|
JSCVoid()
Creates an empty JSCVoid with a default name. |
|
JSCVoid(java.lang.String name)
Creates an empty JSCVoid. |
|
JSCVoid(java.lang.String name,
java.lang.Object value)
Creates a JSCVoid from value. |
|
| Method Summary | |
|---|---|
void |
clear()
Clears this data object. |
JSCVoid |
copy()
Gets a copy of the current object. |
boolean |
isEmpty()
Gets whether this is empty. |
boolean |
isEqual(JSCData o)
Gets whether the values of this data object and other are
logically equal. |
java.lang.String |
name()
Gets the name of the data object. |
void |
setVal(java.lang.Object newValue)
Sets the value of this to newValue. |
JSCTypes |
type()
Gets the type of this JSCData object. |
java.lang.Object |
value()
Gets the underlying value, which is stored as an Object. |
| Methods inherited from class com.jstatcom.model.AbstractJSCData |
|---|
addJSCDataListener, display, getJSCProperty, removeJSCDataListener, removeJSCProperty, setJSCProperty, toString |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final javolution.xml.XmlFormat<JSCVoid> JSCVoid_XML
| Constructor Detail |
|---|
public JSCVoid(java.lang.String name)
JSCVoid.
name - the identifier of that object
java.lang.IllegalArgumentException - if name is not valid or
if (name == null)JSCConstants.isValidName(java.lang.String)public JSCVoid()
JSCVoid with a default name.
public JSCVoid(java.lang.String name,
java.lang.Object value)
JSCVoid from value.
name - the identifier of that objectvalue - the Object to be used as value
java.lang.IllegalArgumentException - if name is not valid or
if (name == null)JSCConstants.isValidName(java.lang.String)| Method Detail |
|---|
public void clear()
this data object. Fires:
JSCDataEventTypes.EMPTY_STATE event
JSCDataEventTypes.VALUE_CHANGED event
isEmpty returns true.
public JSCVoid copy()
JSCDataa.isEqual(a.copy())- compares values
a.getName().equals(a.copy().getName())- compares
name
JSCDataListeners attached to the original object should
not be copied.
JSCDatapublic boolean isEmpty()
this is empty. If this method returns
true, then value returns null.
true if emptypublic boolean isEqual(JSCData o)
JSCDataother are
logically equal.
true if considered equal according to the logic of
the representationJSCDatapublic java.lang.String name()
JSCDataJSCConstants.
JSCDatapublic void setVal(java.lang.Object newValue)
newValue. Fires a
JSCDataEvent of type:
JSCDataEventTypes.VALUE_CHANGED if
!newValue.equals(value())
JSCDataEventTypes.EMPTY_STATE if
newValue != null and this was empty before
JSCDataEventTypes.EMPTY_STATE if
newValue == null and this was not empty before
newValue - the new valuepublic JSCTypes type()
JSCData object.
JSCTypes.VOIDJSCTypespublic java.lang.Object value()
Object.
null if this is
empty
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||