Package com.oracle.coherence.io.json
Class JsonObject
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<String,Object>
-
- com.oracle.coherence.io.json.JsonObject
-
- All Implemented Interfaces:
ExternalizableLite,Versionable<Integer>,Externalizable,Serializable,Cloneable,Map<String,Object>
public class JsonObject extends LinkedHashMap<String,Object> implements Versionable<Integer>, Externalizable, ExternalizableLite
Extends LinkedHashMap that preserves the order of elements and adds support for POF serialization without fidelity loss in order to support JSON pass-through.- Since:
- 20.06
- Author:
- Aleks Seovic 2015.08.25
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJsonObject.SerializerPOF serializer for JsonObject.-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description protected intm_nVersionThe version of the type thisJsonObjectrepresents.
-
Constructor Summary
Constructors Constructor Description JsonObject()Construct a JsonObject.JsonObject(Map<String,?> map)Construct a JsonObject with the same mappings as the given map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)BigDecimalgetBigDecimal(String name)Obtain a BigDecimal value.BigIntegergetBigInteger(String name)Obtain a BigInteger value.booleangetBoolean(String name)Obtain a boolean value.bytegetByte(String name)Obtain a byte value.StringgetClassName()Returns the class name.doublegetDouble(String name)Obtain a double value.floatgetFloat(String name)Obtain a float value.intgetInt(String name)Obtain a int value.longgetLong(String name)Obtain a long value.NumbergetNumber(String name)Obtain a Number value.shortgetShort(String name)Obtain a short value.StringgetString(String name)Obtain a string value.intgetVersion()Returns the version of the associated type.IntegergetVersionIndicator()inthashCode()voidincrementVersion()booleanisVersioned()Returnstrueif the associated type is versioned.voidreadExternal(DataInput in)voidreadExternal(ObjectInput in)Initialize this object from the data in the passed ObjectInput stream.JsonObjectset(String name, Object value)Set the value for the given key.voidsetClassName(String className)Sets the class name.JsonObjectsetVersion(int version)Set the version of this object.StringtoString()voidwriteExternal(DataOutput out)voidwriteExternal(ObjectOutput out)Write this object's data to the passed ObjectOutput stream.-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Methods inherited from interface com.tangosol.util.Versionable
isVersioningEnabled
-
-
-
-
Method Detail
-
getString
public String getString(String name)
Obtain a string value.- Parameters:
name- the key of the value- Returns:
- the string value for the given key
-
getBoolean
public boolean getBoolean(String name)
Obtain a boolean value.- Parameters:
name- the key of the value- Returns:
- the boolean value for the given key
-
getNumber
public Number getNumber(String name)
Obtain a Number value.- Parameters:
name- the key of the value- Returns:
- the Number value for the given key
-
getByte
public byte getByte(String name)
Obtain a byte value.- Parameters:
name- the key of the value- Returns:
- the byte value for the given key
-
getShort
public short getShort(String name)
Obtain a short value.- Parameters:
name- the key of the value- Returns:
- the short value for the given key
-
getInt
public int getInt(String name)
Obtain a int value.- Parameters:
name- the key of the value- Returns:
- the int value for the given key
-
getLong
public long getLong(String name)
Obtain a long value.- Parameters:
name- the key of the value- Returns:
- the long value for the given key
-
getFloat
public float getFloat(String name)
Obtain a float value.- Parameters:
name- the key of the value- Returns:
- the float value for the given key
-
getDouble
public double getDouble(String name)
Obtain a double value.- Parameters:
name- the key of the value- Returns:
- the double value for the given key
-
getBigInteger
public BigInteger getBigInteger(String name)
Obtain a BigInteger value.- Parameters:
name- the key of the value- Returns:
- the BigInteger value for the given key
-
getBigDecimal
public BigDecimal getBigDecimal(String name)
Obtain a BigDecimal value.- Parameters:
name- the key of the value- Returns:
- the BigDecimal value for the given key
-
set
public JsonObject set(String name, Object value)
Set the value for the given key.- Parameters:
name- the key of te value to setvalue- the value to set- Returns:
- this
JsonObject
-
getClassName
public String getClassName()
Returns the class name.- Returns:
- the class name
-
setClassName
public void setClassName(String className)
Sets the class name.- Parameters:
className- the class name
-
getVersionIndicator
public Integer getVersionIndicator()
- Specified by:
getVersionIndicatorin interfaceVersionable<Integer>
-
incrementVersion
public void incrementVersion()
- Specified by:
incrementVersionin interfaceVersionable<Integer>
-
isVersioned
public boolean isVersioned()
Returnstrueif the associated type is versioned.- Returns:
trueif the associated type is versioned
-
getVersion
public int getVersion()
Returns the version of the associated type.- Returns:
- the version of this type or
0to indicate there is no version
-
setVersion
public JsonObject setVersion(int version)
Set the version of this object.- Parameters:
version- the version- Returns:
- this
JsonObject
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
toString
public String toString()
- Overrides:
toStringin classAbstractMap<String,Object>
-
readExternal
public void readExternal(ObjectInput in) throws IOException
Initialize this object from the data in the passed ObjectInput stream.- Specified by:
readExternalin interfaceExternalizable- Parameters:
in- the stream to read data from in order to restore the object- Throws:
IOException- if an I/O exception occurs
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
Write this object's data to the passed ObjectOutput stream.- Specified by:
writeExternalin interfaceExternalizable- Parameters:
out- the stream to write the object to- Throws:
IOException- if an I/O exception occurs
-
readExternal
public void readExternal(DataInput in) throws IOException
- Specified by:
readExternalin interfaceExternalizableLite- Throws:
IOException
-
writeExternal
public void writeExternal(DataOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizableLite- Throws:
IOException
-
-