SMILA 1.0 API documentation

org.eclipse.smila.datamodel.impl
Class AnyMapImpl

java.lang.Object
  extended by org.eclipse.smila.datamodel.impl.AbstractAny
      extended by org.eclipse.smila.datamodel.impl.AnyMapImpl
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<Any>, java.util.Map<java.lang.String,Any>, Any, AnyMap

public final class AnyMapImpl
extends AbstractAny
implements AnyMap

Class implementing AnyMap.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.smila.datamodel.Any
Any.ValueType
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class org.eclipse.smila.datamodel.impl.AbstractAny
_valueType
 
Method Summary
 void add(java.lang.String key, Any value)
          Adds the given value to the mapped entry of the given key.
 AnyMap asMap()
          returns this Any as an AnyMap object or throws an InvalidValueTypeException.
 void clear()
          
 boolean containsKey(java.lang.Object key)
          
 boolean containsValue(java.lang.Object value)
          
 java.util.Set<java.util.Map.Entry<java.lang.String,Any>> entrySet()
          
 boolean equals(java.lang.Object obj)
          
 Any get(java.lang.Object key)
          
 java.lang.Boolean getBooleanValue(java.lang.String key)
          
 java.util.Date getDateTimeValue(java.lang.String key)
          
 java.util.Date getDateValue(java.lang.String key)
          
 java.lang.Double getDoubleValue(java.lang.String key)
          
 java.lang.Long getLongValue(java.lang.String key)
          
 AnyMap getMap(java.lang.String key)
          
 AnyMap getMap(java.lang.String key, boolean create)
          Gets the map and optionally creates one under the given key if not present.
 AnySeq getSeq(java.lang.String key)
          
 AnySeq getSeq(java.lang.String key, boolean create)
          Gets the seq and optionally creates one under the given key if not present.
 java.lang.String getStringValue(java.lang.String key)
          
 Value getValue(java.lang.String key)
          
 int hashCode()
          
 boolean isEmpty()
          
 java.util.Iterator<Any> iterator()
          
 java.util.Set<java.lang.String> keySet()
          
 Any put(java.lang.String key, Any value)
          
 Any put(java.lang.String key, java.lang.Boolean value)
          
 Any put(java.lang.String key, java.lang.Number value)
          Long, Integer, Short and Byte values will be converted to Value object of type LONG, all others to Value object of type DOUBLE.
 Any put(java.lang.String key, java.lang.String value)
          
 void putAll(java.util.Map<? extends java.lang.String,? extends Any> map)
          
 Any remove(java.lang.Object key)
          
 int size()
          
 java.lang.String toString()
          
 java.util.Collection<Any> values()
          
 
Methods inherited from class org.eclipse.smila.datamodel.impl.AbstractAny
asSeq, asValue, getFactory, getValueType, isBoolean, isDate, isDateTime, isDouble, isLong, isMap, isNumber, isSeq, isString, isValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.smila.datamodel.Any
asSeq, asValue, getFactory, getValueType, isBoolean, isDate, isDateTime, isDouble, isLong, isMap, isNumber, isSeq, isString, isValue
 

Method Detail

add

public void add(java.lang.String key,
                Any value)
Adds the given value to the mapped entry of the given key. If there's no mapping yet, the new value is added as Seq with one value. If the key is currently mapped to a Value/Map, the Value/Map is converted to a Seq containing the Value/Map and the Seq is added. If the key is currently mapped to a Seq, new value is added to that Seq.

Specified by:
add in interface AnyMap
Parameters:
key - The key
value - the Any to add

clear

public void clear()

Specified by:
clear in interface java.util.Map<java.lang.String,Any>

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface java.util.Map<java.lang.String,Any>
Specified by:
isEmpty in interface Any
Returns:
true, if the Any does not have content. For Value: returns always false.

keySet

public java.util.Set<java.lang.String> keySet()

Specified by:
keySet in interface java.util.Map<java.lang.String,Any>

put

public Any put(java.lang.String key,
               java.lang.String value)

Specified by:
put in interface AnyMap
Parameters:
key - The key
value - String value, must not be null.
Returns:
the previous value or null

put

public Any put(java.lang.String key,
               java.lang.Number value)
Long, Integer, Short and Byte values will be converted to Value object of type LONG, all others to Value object of type DOUBLE.

Specified by:
put in interface AnyMap
Parameters:
key - The key
value - Number value, will be converted, must not be null.
Returns:
the previous value or null

put

public Any put(java.lang.String key,
               java.lang.Boolean value)

Specified by:
put in interface AnyMap
Parameters:
key - The key
value - Boolean value, must not be null.
Returns:
the previous value or null

put

public Any put(java.lang.String key,
               Any value)

Specified by:
put in interface java.util.Map<java.lang.String,Any>
Specified by:
put in interface AnyMap
Parameters:
key - The key
value - Any value, must not be null.
Returns:
the previous value or null

size

public int size()

Specified by:
size in interface java.util.Map<java.lang.String,Any>
Specified by:
size in interface Any
Returns:
size of Any. For Value this is always 1.

values

public java.util.Collection<Any> values()

Specified by:
values in interface java.util.Map<java.lang.String,Any>

iterator

public java.util.Iterator<Any> iterator()

Specified by:
iterator in interface java.lang.Iterable<Any>
Specified by:
iterator in interface Any
Returns:
iterator over elements. For Value, this return an iterator about the value itself. For AnyMap it returns an iterator on the values.

getMap

public AnyMap getMap(java.lang.String key)

Specified by:
getMap in interface AnyMap
Parameters:
key - The key
Returns:
The AnyMap matching the key, an InvalidValueTypeException is thrown if the value is not of type AnyMap, or null

getSeq

public AnySeq getSeq(java.lang.String key)

Specified by:
getSeq in interface AnyMap
Parameters:
key - The key
Returns:
The AnySeq matching to this key, an InvalidValueTypeException is thrown if the value is not of type, or null

getValue

public Value getValue(java.lang.String key)

Specified by:
getValue in interface AnyMap
Parameters:
key - the key
Returns:
The value matching to this key, an InvalidValueTypeException is thrown if the value is no value type

getStringValue

public java.lang.String getStringValue(java.lang.String key)

Specified by:
getStringValue in interface AnyMap
Parameters:
key - the key
Returns:
The string representation of the attribute value

getDoubleValue

public java.lang.Double getDoubleValue(java.lang.String key)

Specified by:
getDoubleValue in interface AnyMap
Parameters:
key - The key
Returns:
The double value matching to this key, an InvalidValueTypeException is thrown if the value is not of type double

getLongValue

public java.lang.Long getLongValue(java.lang.String key)

Specified by:
getLongValue in interface AnyMap
Parameters:
key - The key
Returns:
The long value matching to this key, an InvalidValueTypeException is thrown if the value is not of type long

getBooleanValue

public java.lang.Boolean getBooleanValue(java.lang.String key)

Specified by:
getBooleanValue in interface AnyMap
Parameters:
key - The key
Returns:
The boolean value matching to this key, an InvalidValueTypeException is thrown if the value is not of type boolean

getDateValue

public java.util.Date getDateValue(java.lang.String key)

Specified by:
getDateValue in interface AnyMap
Parameters:
key - The key
Returns:
The date value matching to this key, an InvalidValueTypeException is thrown if the value is not of type date

getDateTimeValue

public java.util.Date getDateTimeValue(java.lang.String key)

Specified by:
getDateTimeValue in interface AnyMap
Parameters:
key - The key
Returns:
The date time value matching to this key, an InvalidValueTypeException is thrown if the value is not of type date time

hashCode

public int hashCode()

Specified by:
hashCode in interface java.util.Map<java.lang.String,Any>
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)

Specified by:
equals in interface java.util.Map<java.lang.String,Any>
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

containsKey

public boolean containsKey(java.lang.Object key)

Specified by:
containsKey in interface java.util.Map<java.lang.String,Any>

containsValue

public boolean containsValue(java.lang.Object value)

Specified by:
containsValue in interface java.util.Map<java.lang.String,Any>

get

public Any get(java.lang.Object key)

Specified by:
get in interface java.util.Map<java.lang.String,Any>

putAll

public void putAll(java.util.Map<? extends java.lang.String,? extends Any> map)

Specified by:
putAll in interface java.util.Map<java.lang.String,Any>

remove

public Any remove(java.lang.Object key)

Specified by:
remove in interface java.util.Map<java.lang.String,Any>

entrySet

public java.util.Set<java.util.Map.Entry<java.lang.String,Any>> entrySet()

Specified by:
entrySet in interface java.util.Map<java.lang.String,Any>

asMap

public AnyMap asMap()
returns this Any as an AnyMap object or throws an InvalidValueTypeException.

Specified by:
asMap in interface Any
Overrides:
asMap in class AbstractAny
See Also:
AbstractAny.asMap()

getMap

public AnyMap getMap(java.lang.String key,
                     boolean create)
Gets the map and optionally creates one under the given key if not present.

Specified by:
getMap in interface AnyMap
Parameters:
key - The key
create - if true and the key is not yet used, create a new map. else just return null.
Returns:
The AnyMap matching the key, an InvalidValueTypeException is thrown if the value is not of type AnyMap
See Also:
AnyMap.getMap(java.lang.String, boolean)

getSeq

public AnySeq getSeq(java.lang.String key,
                     boolean create)
Gets the seq and optionally creates one under the given key if not present.

Specified by:
getSeq in interface AnyMap
Parameters:
key - The key
create - the create
Returns:
The AnySeq matching the key, an InvalidValueTypeException is thrown if the value is not of type AnyMap
See Also:
AnyMap.getSeq(java.lang.String, boolean)

SMILA 1.0 API documentation