ccc.plugins.s11n.json
Class JsonImpl

java.lang.Object
  extended by ccc.plugins.s11n.json.JsonImpl
All Implemented Interfaces:
Json, java.io.Serializable

public class JsonImpl
extends java.lang.Object
implements java.io.Serializable, Json

Default implementation of the Json interface.

Author:
Civic Computing Ltd.
See Also:
Serialized Form

Constructor Summary
JsonImpl()
          Constructor.
JsonImpl(Jsonable jsonable)
          Constructor.
JsonImpl(org.json.JSONObject detail)
          Constructor.
JsonImpl(java.util.Map<java.lang.String,java.lang.String> map)
          Constructor.
JsonImpl(java.lang.String detail)
          Constructor.
 
Method Summary
 Json create()
          Create a new Json object.
 java.math.BigDecimal getBigDecimal(java.lang.String key)
          Accessor.
 java.lang.Boolean getBool(java.lang.String key)
          Accessor.
 java.util.Collection<Json> getCollection(java.lang.String key)
          Accessor.
 java.util.Date getDate(java.lang.String key)
          Accessor.
 java.lang.String getDetail()
          Get the internal state of the snapshot.
 java.util.UUID getId(java.lang.String key)
          Accessor.
 java.lang.Integer getInt(java.lang.String key)
          Accessor.
 Json getJson(java.lang.String string)
          Accessor.
 java.lang.Long getLong(java.lang.String key)
          Accessor.
 java.lang.String getString(java.lang.String key)
          Accessor.
 java.util.Map<java.lang.String,java.lang.String> getStringMap(java.lang.String key)
          Accessor.
 java.util.Collection<java.lang.String> getStrings(java.lang.String key)
          Accessor.
 void set(java.lang.String key, java.math.BigDecimal value)
          Mutator.
 void set(java.lang.String key, java.lang.Boolean value)
          Mutator.
 void set(java.lang.String key, java.util.Collection<? extends Jsonable> snapshots)
          Mutator.
 void set(java.lang.String key, java.util.Date date)
          Mutator.
 void set(java.lang.String key, Json value)
          Mutator.
 void set(java.lang.String key, Jsonable value)
          Mutator.
 void set(java.lang.String key, java.lang.Long value)
          Mutator.
 void set(java.lang.String key, java.util.Map<java.lang.String,java.lang.String> value)
          Mutator.
 void set(java.lang.String key, java.lang.String value)
          Mutator.
 void set(java.lang.String key, java.util.UUID value)
          Mutator.
 void setJsons(java.lang.String key, java.util.Collection<? extends Json> snapshots)
          
 void setStrings(java.lang.String key, java.util.Collection<java.lang.String> value)
          Mutator.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JsonImpl

public JsonImpl(java.lang.String detail)
Constructor.

Parameters:
detail - The snapshot's detail.

JsonImpl

public JsonImpl()
Constructor.


JsonImpl

public JsonImpl(org.json.JSONObject detail)
Constructor.

Parameters:
detail - The JSON object this snapshot wraps.

JsonImpl

public JsonImpl(Jsonable jsonable)
Constructor.

Parameters:
jsonable - The object to convert to JSON.

JsonImpl

public JsonImpl(java.util.Map<java.lang.String,java.lang.String> map)
Constructor.

Parameters:
map - The map to convert into a snapshot.
Method Detail

getDetail

public java.lang.String getDetail()
Get the internal state of the snapshot.

Returns:
The snapshot's state, as JSON a string.

set

public void set(java.lang.String key,
                java.lang.String value)
Mutator.

Specified by:
set in interface Json
Parameters:
key - The key.
value - The value, as a string.

set

public void set(java.lang.String key,
                java.util.Collection<? extends Jsonable> snapshots)
Mutator.

Specified by:
set in interface Json
Parameters:
key - The key.
snapshots - The value, as a collection of Jsonable objects.

setStrings

public void setStrings(java.lang.String key,
                       java.util.Collection<java.lang.String> value)
Mutator.

Specified by:
setStrings in interface Json
Parameters:
key - The key.
value - The value, as a collection of strings.

set

public void set(java.lang.String key,
                java.lang.Boolean value)
Mutator.

Specified by:
set in interface Json
Parameters:
key - The key.
value - The value, as a boolean.

set

public void set(java.lang.String key,
                java.util.Date date)
Mutator.

Specified by:
set in interface Json
Parameters:
key - The key.
date - The value, as a date.

set

public void set(java.lang.String key,
                java.util.UUID value)
Mutator.

Specified by:
set in interface Json
Parameters:
key - The key.
value - The value, as an ID.

set

public void set(java.lang.String key,
                java.lang.Long value)
Mutator.

Specified by:
set in interface Json
Parameters:
key - The key.
value - The value, as a long.

set

public void set(java.lang.String key,
                java.math.BigDecimal value)
Mutator.

Specified by:
set in interface Json
Parameters:
key - The key.
value - The value, as a decimal.

set

public void set(java.lang.String key,
                java.util.Map<java.lang.String,java.lang.String> value)
Mutator.

Specified by:
set in interface Json
Parameters:
key - The key.
value - The value, as a map of strings.

set

public void set(java.lang.String key,
                Jsonable value)
Mutator.

Specified by:
set in interface Json
Parameters:
key - The key.
value - The value, as a Jsonable object.

getString

public java.lang.String getString(java.lang.String key)
Accessor.

Specified by:
getString in interface Json
Parameters:
key - The key for the value.
Returns:
The value, as a string.

getCollection

public java.util.Collection<Json> getCollection(java.lang.String key)
Accessor.

Specified by:
getCollection in interface Json
Parameters:
key - The key for the value.
Returns:
The value, as a collection of snapshots.

getDate

public java.util.Date getDate(java.lang.String key)
Accessor.

Specified by:
getDate in interface Json
Parameters:
key - The key for the value.
Returns:
The value, as a Date.

getBool

public java.lang.Boolean getBool(java.lang.String key)
Accessor.

Specified by:
getBool in interface Json
Parameters:
key - The key for the value.
Returns:
The value, as a boolean.

getId

public java.util.UUID getId(java.lang.String key)
Accessor.

Specified by:
getId in interface Json
Parameters:
key - The key for the value.
Returns:
The value, as an ID.

getInt

public java.lang.Integer getInt(java.lang.String key)
Accessor.

Specified by:
getInt in interface Json
Parameters:
key - The key for the value.
Returns:
The value, as an int.

getBigDecimal

public java.math.BigDecimal getBigDecimal(java.lang.String key)
Accessor.

Specified by:
getBigDecimal in interface Json
Parameters:
key - The key for the value.
Returns:
The value, as a decimal.

getJson

public Json getJson(java.lang.String string)
Accessor.

Specified by:
getJson in interface Json
Parameters:
string - The key for the value.
Returns:
The value, as a JSON object.

getStrings

public java.util.Collection<java.lang.String> getStrings(java.lang.String key)
Accessor.

Specified by:
getStrings in interface Json
Parameters:
key - The key for the value.
Returns:
The value, as a collection of strings.

getLong

public java.lang.Long getLong(java.lang.String key)
Accessor.

Specified by:
getLong in interface Json
Parameters:
key - The key for the value.
Returns:
The value, as a long.

getStringMap

public java.util.Map<java.lang.String,java.lang.String> getStringMap(java.lang.String key)
Accessor.

Specified by:
getStringMap in interface Json
Parameters:
key - The key for the value.
Returns:
The value, as a map of strings.

create

public Json create()
Create a new Json object.

Specified by:
create in interface Json
Returns:
The new object.

set

public void set(java.lang.String key,
                Json value)
Mutator.

Specified by:
set in interface Json
Parameters:
key - The key.
value - The value, as a Json.

setJsons

public void setJsons(java.lang.String key,
                     java.util.Collection<? extends Json> snapshots)

Specified by:
setJsons in interface Json

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object


Copyright © 2010. All Rights Reserved.