|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jstatcom.model.AbstractJSCData com.jstatcom.model.JSCMap
public final class JSCMap
An object wrapper that conforms to the JSCData
interface. This
class acts like an ordered map where the keys are string values and the
values are one of
String, String[], Integer, int[], int[][], Double, double[], double[][], Boolean, boolean[]
.
On read/write access all array values are copied to prevent external
references to them. The JSCMap
was inspired by the list
datatype in the R statistics language. It can be used as an input and return
parameter in calls the the RStatEngine
.
A JSCMap
is empty, if there are no keys stored.
Usage Note:
Whenever the value of this data object changes (by adding, removing
elements), registered JSCDataListeners
are notified via a
JSCDataEvent
. In case of value changes, the event objects
contain an array with the keys before and after the change, but not the
values itself.
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<JSCMap> |
JSCMap_XML
XML format field for (de)serialization. |
Constructor Summary | |
---|---|
JSCMap()
Creates an empty JSCMap with a default name. |
|
JSCMap(java.lang.String name)
Creates an empty JSCMap . |
Method Summary | |
---|---|
void |
clear()
Clears this data object. |
boolean |
containsKey(java.lang.String key)
Checks whether key is contained. |
JSCMap |
copy()
Gets a copy of the current object. |
java.lang.String |
display()
Default implementation that gets a string representing the value stored in this JSCData object. |
java.lang.Object |
get(java.lang.String key)
Gets the element belonging to key and returns the
underying value or null otherwise. |
java.util.Map<java.lang.String,java.lang.Object> |
getAll()
Gets a deep copy of the map holding all key value pairs. |
boolean |
isEmpty()
Gets whether this is empty. |
boolean |
isEqual(JSCData o)
Checks whether both objects contain the same keys only. |
java.lang.String |
name()
Gets the name of the data object. |
void |
put(java.lang.String key,
java.lang.Object val)
Copy-on-write adds a new key value pair, where val must be
of one . |
java.lang.Object |
remove(java.lang.String key)
Removes the element belonging to key and returns the
underying value. |
int |
size()
|
JSCTypes |
type()
Gets the type of this JSCData object. |
java.lang.Object |
value()
Gets the underlying value, which is stored as a Map<String, Object> . |
Methods inherited from class com.jstatcom.model.AbstractJSCData |
---|
addJSCDataListener, 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<JSCMap> JSCMap_XML
Constructor Detail |
---|
public JSCMap(java.lang.String name)
JSCMap
.
name
- the identifier of that object
java.lang.IllegalArgumentException
- if name
is not valid or
if (name == null)
JSCConstants.isValidName(java.lang.String)
public JSCMap()
JSCMap
with a default name.
Method Detail |
---|
public void clear()
this
data object. Fires:
JSCDataEventTypes.EMPTY_STATE
event
JSCDataEventTypes.VALUE_CHANGED
event
isEmpty
returns true
.
public JSCMap copy()
JSCData
a.isEqual(a.copy())
- compares values
a.getName().equals(a.copy().getName())
- compares
name
JSCDataListeners
attached to the original object should
not be copied.
JSCData
public boolean isEmpty()
this
is empty. If this method returns
true
, then value
returns an empty
Map
.
true
if emptypublic boolean isEqual(JSCData o)
true
if considered equal according to the logic of
the representationJSCData
public java.lang.String name()
JSCData
JSCConstants
.
JSCData
public void put(java.lang.String key, java.lang.Object val)
val
must be
of one . Fires a JSCDataEvent
of type:
JSCDataEventTypes.VALUE_CHANGED
if a new key is added
that was not there before or if an existing key ist overwritten, no
matter whether the new object is logically equivalent or not
JSCDataEventTypes.EMPTY_STATE
if this was empty
before
key
- must be non null
, otherwise arbitraryval
- value, must be one of
String, String[], Integer, int[], int[][], Double, double[], double[][], Boolean, boolean[]
java.lang.IllegalArgumentException
- if (key == null)
or if val
has
a class that is not supportedpublic java.lang.Object remove(java.lang.String key)
key
and returns the
underying value. The following events are fired:
JSCDataEventTypes.VALUE_CHANGED
if key
exists
JSCDataEventTypes.EMPTY_STATE
if this is empty
afterwards but nonempty before calling this method
key
- must be non null
, otherwise arbitrary
key
, may be null
if it was set to null
or if key
did
not exist
java.lang.IllegalArgumentException
- if (key == null)
public java.lang.Object get(java.lang.String key)
key
and returns the
underying value or null
otherwise.
key
- must be non null
, otherwise arbitrary
key
, may be null
if it was set to null
or if key
does not exist
java.lang.IllegalArgumentException
- if (key == null)
public java.util.Map<java.lang.String,java.lang.Object> getAll()
public boolean containsKey(java.lang.String key)
key
is contained.
key
- to check for
true
if contained, false
otherwise
java.lang.IllegalArgumentException
- if (key == null)
public int size()
public JSCTypes type()
JSCData
object.
JSCTypes.MAP
JSCTypes
public java.lang.Object value()
Map<String, Object>
.
this
is emptypublic java.lang.String display()
AbstractJSCData
JSCData
object.
display
in interface JSCData
display
in class AbstractJSCData
isEmpty == true
, otherwise
value().toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |