|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface JSCData
Defines the contract for all data types to be used with Engine
,
Symbol
and SymbolTable
. It extends
com.dautelle.xml.Representable
to ensure that all data objects
can be serialized with their XML representation that has to be defined in
toXML
.
JSCData
objects should notify listeners about changes in the
underlying value via a JSCDataEvent
. There are several event
types defined in JSCDataEventTypes
for the most common
changes, but different types may be defined by extending this enumeration.
This is most preferably done by defining a static inner class for the
respective JSCData
implementation.
A further requirement for implementations of this interface is that all setter methods should copy mutable data before it is set and all getter methods should only return a copy of mutable objects. References should only be passed if the underlying objects are immutable, see (Joshua Bloch, "Effective Java", Item 13) .
Design Note:
Implementations of JSCData
should in general act as wrapper to
other types by providing additional functionality, like notification of
listeners. Implementations should provide basic adapter methods to modify the
underlying values, but the idea is, to keep them thin. For example the the
JSCNArray
class acts as a wrapper for double[][]
,
but it is not designed as a general purpose matrix class for linear algebra.
Instead this should be delegated to classes especially designed for these
purposes. The wrapper can provide accessor methods that get the underlying
value as instances of these special classes.
Usage Note:
To make sure that a JSCData
object can be deserialized from
its XML representation, every data class must also implement a public static
field with the respective implementation of javolution.xml.XmlFormat. See the
API documentation of this class for how to do this.
Method Summary | |
---|---|
void |
addJSCDataListener(JSCDataListener evtListener,
JSCDataEventTypes evtType)
Adds a listener that is notified when changes of type evtType occur in this object. |
void |
clear()
After applying this method, isEmpty returns
true . |
JSCData |
copy()
Gets a copy of the current object. |
java.lang.String |
display()
Gets a formatted string representing the value stored in this JSCData object. |
java.lang.Object |
getJSCProperty(JSCPropertyTypes type)
Gets the value for a property type. |
boolean |
isEmpty()
Gets whether this data object contains any data. |
boolean |
isEqual(JSCData other)
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 |
removeJSCDataListener(JSCDataListener evtListener)
Removes a JSCDataListener from all different listener
lists. |
void |
removeJSCProperty(JSCPropertyTypes type)
Removes the property value for type . |
void |
setJSCProperty(JSCPropertyTypes type,
java.lang.Object val)
Set the value for a property type. |
JSCTypes |
type()
Gets the type of the data object. |
java.lang.Object |
value()
Gets the value stored in this data object. |
Method Detail |
---|
java.lang.Object getJSCProperty(JSCPropertyTypes type)
type
- the property type
null
if the property has not been setvoid setJSCProperty(JSCPropertyTypes type, java.lang.Object val)
type
- the property typeval
- the associated property valuevoid removeJSCProperty(JSCPropertyTypes type)
type
.
type
- void addJSCDataListener(JSCDataListener evtListener, JSCDataEventTypes 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 tovoid clear()
isEmpty
returns
true
. Implementations should fire a
JSCDataEventTypes.EMPTY_STATE
event if the data object was
not empty before.
JSCData copy()
a.isEqual(a.copy())
- compares values
a.getName().equals(a.copy().getName())
- compares
name
JSCDataListeners
attached to the original object should
not be copied.
java.lang.String display()
JSCData
object.
boolean isEmpty()
true
if no data is containedboolean isEqual(JSCData other)
other
are
logically equal.
true
if considered equal according to the logic of
the representationjava.lang.String name()
JSCConstants
.
JSCConstants.isValidName(java.lang.String)
void removeJSCDataListener(JSCDataListener evtListener)
JSCDataListener
from all different listener
lists.
evtListener
- the listener object to be removedJSCTypes type()
JSCTypes
java.lang.Object value()
JSCType
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |