cc.plural.jsonij
Class ObjectImp<CS extends CharSequence,V extends Value>

java.lang.Object
  extended by cc.plural.jsonij.Value
      extended by cc.plural.jsonij.ObjectImp<CS,V>
All Implemented Interfaces:
Serializable, Comparable<Value>, Map<CS,V>
Direct Known Subclasses:
JSON.Object

public class ObjectImp<CS extends CharSequence,V extends Value>
extends Value
implements Map<CS,V>

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class cc.plural.jsonij.Value
Value.TYPE
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
protected  LinkedHashMap<CS,V> mapValue
          Holds the Mapping Values for the Object
protected  ArrayList<CS> valueOrder
          Holds the Key order so values can be extracted in the order they were added.
 
Fields inherited from class cc.plural.jsonij.Value
valueType
 
Constructor Summary
ObjectImp()
          Default Constructor
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<CS,V>> entrySet()
           
 V get(int i)
          Extracts a Value instance at an Index.
 V get(Object key)
           
protected  Value.TYPE internalType()
          Internal Method to find the internalType for the Object.
 boolean isEmpty()
           
 Set<CS> keySet()
           
 int nestedSize()
          Finds the nested elements under this Value.
 V put(CS key, V value)
           
 void putAll(Map<? extends CS,? extends V> m)
           
 V remove(Object key)
           
 V safeGet(Object key)
           
 int size()
          Retrieves the size of the Value.
 String toJSON()
          Converts the current Value into a JSON String that represents it.
 Collection<V> values()
           
 
Methods inherited from class cc.plural.jsonij.Value
compareTo, equals, get, getBoolean, getDouble, getInt, getNumber, getString, getValueType, has, hashCode, isNull, toString, type, valueKeySet
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

mapValue

protected LinkedHashMap<CS extends CharSequence,V extends Value> mapValue
Holds the Mapping Values for the Object


valueOrder

protected ArrayList<CS extends CharSequence> valueOrder
Holds the Key order so values can be extracted in the order they were added.

Constructor Detail

ObjectImp

public ObjectImp()
Default Constructor

Method Detail

internalType

protected Value.TYPE internalType()
Description copied from class: Value
Internal Method to find the internalType for the Object. Must be implemented and not return null.

Specified by:
internalType in class Value
Returns:
The internalType of this JSON Value.

clear

public void clear()
Specified by:
clear in interface Map<CS extends CharSequence,V extends Value>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<CS extends CharSequence,V extends Value>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<CS extends CharSequence,V extends Value>

entrySet

public Set<Map.Entry<CS,V>> entrySet()
Specified by:
entrySet in interface Map<CS extends CharSequence,V extends Value>

get

public V get(int i)
Description copied from class: Value
Extracts a Value instance at an Index. This method only returns values when the internalType is OBJECT or ARRAY. All other cases will return null.

Overrides:
get in class Value
Parameters:
i - The index to get the value for.
Returns:
Value The Value at the index or null.

get

public V get(Object key)
Specified by:
get in interface Map<CS extends CharSequence,V extends Value>

safeGet

public V safeGet(Object key)

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<CS extends CharSequence,V extends Value>

keySet

public Set<CS> keySet()
Specified by:
keySet in interface Map<CS extends CharSequence,V extends Value>

put

public V put(CS key,
             V value)
Specified by:
put in interface Map<CS extends CharSequence,V extends Value>

putAll

public void putAll(Map<? extends CS,? extends V> m)
Specified by:
putAll in interface Map<CS extends CharSequence,V extends Value>

remove

public V remove(Object key)
Specified by:
remove in interface Map<CS extends CharSequence,V extends Value>

size

public int size()
Description copied from class: Value
Retrieves the size of the Value. If string internalType, this will return the length of the String. If this internalType is an Array or an Object then it will return the number of elements in the Object. If this Value is not a String, Array or Object then this will return -1.

Specified by:
size in interface Map<CS extends CharSequence,V extends Value>
Overrides:
size in class Value
Returns:
size of the Value or -1 if this Value has no size.

values

public Collection<V> values()
Specified by:
values in interface Map<CS extends CharSequence,V extends Value>

nestedSize

public int nestedSize()
Description copied from class: Value
Finds the nested elements under this Value. This is effectively the count of all JSON Values attached to this Value. This number does not include this value itself.

Specified by:
nestedSize in class Value
Returns:
int The count of all Values attached to this Value.

toJSON

public String toJSON()
Description copied from class: Value
Converts the current Value into a JSON String that represents it.

Specified by:
toJSON in class Value
Returns:
The JSON Value as JSON String.


Copyright © 2012. All Rights Reserved.