public class GSObject
extends java.lang.Object
implements java.io.Serializable
| Modifier | Constructor and Description |
|---|---|
|
GSObject() |
protected |
GSObject(org.json.JSONObject jo)
Construct a GSObject from a JSONObject - used internally
|
|
GSObject(java.lang.String json)
Construct a GSObject from a JSON string.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all of the entries from this object.
|
GSObject |
clone()
Returns a deep copy of the object.
|
boolean |
containsKey(java.lang.String key)
Returns true if this object contains a mapping for the specified key.
|
java.lang.Object |
get(java.lang.String key) |
java.lang.Object |
get(java.lang.String key,
java.lang.Object defaultValue) |
GSArray |
getArray(java.lang.String key)
Returns the GSArray value to which the specified key is mapped.
|
GSArray |
getArray(java.lang.String key,
GSArray defaultValue)
Returns the GSArray value to which the specified key is mapped, or the defaultValue if this object contains no mapping for the key.
|
boolean |
getBool(java.lang.String key)
Returns the boolean value to which the specified key is mapped.
|
boolean |
getBool(java.lang.String key,
boolean defaultValue)
Returns the boolean value to which the specified key is mapped, or the defaultValue if this object contains no mapping for the key.
|
double |
getDouble(java.lang.String key)
Returns the double value to which the specified key is mapped.
|
double |
getDouble(java.lang.String key,
double defaultValue)
Returns the double value to which the specified key is mapped, or the defaultValue if this object contains no mapping for the key.
|
int |
getInt(java.lang.String key)
Returns the int value to which the specified key is mapped.
|
int |
getInt(java.lang.String key,
int defaultValue)
Returns the int value to which the specified key is mapped, or the defaultValue if this object contains no mapping for the key.
|
java.lang.String[] |
getKeys()
Returns a String array containing the keys in this object.
|
long |
getLong(java.lang.String key)
Returns the long value to which the specified key is mapped.
|
long |
getLong(java.lang.String key,
long defaultValue)
Returns the long value to which the specified key is mapped, or the defaultValue if this object contains no mapping for the key.
|
protected java.util.TreeMap<java.lang.String,java.lang.Object> |
getMap() |
GSObject |
getObject(java.lang.String key)
Returns the GSObject value to which the specified key is mapped.
|
GSObject |
getObject(java.lang.String key,
GSObject defaultValue)
Returns the GSobject value to which the specified key is mapped, or the defaultValue if this object contains no mapping for the key.
|
java.lang.String |
getString(java.lang.String key)
Returns the String value to which the specified key is mapped.
|
java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue)
Returns the String value to which the specified key is mapped, or the defaultValue if this object contains no mapping for the key.
|
void |
parseQueryString(java.lang.String qs)
Parses parameters from a query string into this object.
|
void |
parseURL(java.lang.String url)
Parses parameters from a URL string into this object
|
void |
put(java.lang.String key,
boolean value)
Associates the specified value with the specified key in this object.
|
void |
put(java.lang.String key,
double value)
Associates the specified value with the specified key in this object.
|
void |
put(java.lang.String key,
GSArray value)
Associates the specified value with the specified key in this object.
|
void |
put(java.lang.String key,
GSObject value)
Associates the specified value with the specified key in this object.
|
void |
put(java.lang.String key,
int value)
Associates the specified value with the specified key in this object.
|
void |
put(java.lang.String key,
long value)
Associates the specified value with the specified key in this object.
|
void |
put(java.lang.String key,
java.lang.Object value) |
void |
put(java.lang.String key,
java.lang.String value)
Associates the specified value with the specified key in this object.
|
void |
remove(java.lang.String key)
Removes the key (and its corresponding value) from this object.
|
protected org.json.JSONObject |
toJsonObject() |
java.lang.String |
toJsonString()
Returns the object's content as a JSON string.
|
java.lang.String |
toString()
Returns the object's content as a JSON string.
|
public GSObject()
public GSObject(java.lang.String json)
throws java.lang.Exception
json - the JSON formatted stringjava.lang.Exception - if unable to parse the JSON stringprotected GSObject(org.json.JSONObject jo)
throws java.lang.Exception
jo - the JSON object to parsejava.lang.Exception - if unable to parse JSONpublic void put(java.lang.String key,
java.lang.String value)
key - key with which the specified value is to be associatedvalue - a string value to be associated with the specified keypublic void put(java.lang.String key,
int value)
key - key with which the specified value is to be associatedvalue - a int value to be associated with the specified keypublic void put(java.lang.String key,
long value)
key - key with which the specified value is to be associatedvalue - a long value to be associated with the specified keypublic void put(java.lang.String key,
double value)
key - key with which the specified value is to be associatedvalue - a double value to be associated with the specified keypublic void put(java.lang.String key,
boolean value)
key - key with which the specified value is to be associatedvalue - a boolean value to be associated with the specified keypublic void put(java.lang.String key,
GSObject value)
key - key with which the specified value is to be associatedvalue - a GSObject value to be associated with the specified keypublic void put(java.lang.String key,
GSArray value)
key - key with which the specified value is to be associatedvalue - a GSArray value to be associated with the specified keypublic void put(java.lang.String key,
java.lang.Object value)
public boolean getBool(java.lang.String key,
boolean defaultValue)
key - the key whose associated value is to be returneddefaultValue - the boolean value to be returned if this object doesn't contain the specified key.public boolean getBool(java.lang.String key)
throws GSKeyNotFoundException,
java.lang.NullPointerException,
java.io.InvalidClassException
key - the key whose associated value is to be returnedGSKeyNotFoundException - if this object contains no mapping for the specifiedjava.lang.NullPointerExceptionjava.io.InvalidClassExceptionpublic int getInt(java.lang.String key,
int defaultValue)
key - the key whose associated value is to be returneddefaultValue - the int value to be returned if this object doesn't contain the specified key.public int getInt(java.lang.String key)
throws GSKeyNotFoundException,
java.lang.NullPointerException,
java.io.InvalidClassException
key - the key whose associated value is to be returnedGSKeyNotFoundException - if this object contains no mapping for the specifiedjava.lang.NullPointerExceptionjava.io.InvalidClassExceptionpublic long getLong(java.lang.String key,
long defaultValue)
key - the key whose associated value is to be returneddefaultValue - the long value to be returned if this object doesn't contain the specified key.public long getLong(java.lang.String key)
throws GSKeyNotFoundException,
java.lang.NullPointerException,
java.io.InvalidClassException
key - the key whose associated value is to be returnedGSKeyNotFoundException - if this object contains no mapping for the specifiedjava.lang.NullPointerExceptionjava.io.InvalidClassExceptionpublic double getDouble(java.lang.String key,
double defaultValue)
key - the key whose associated value is to be returneddefaultValue - the long value to be returned if this object doesn't contain the specified key.public double getDouble(java.lang.String key)
throws GSKeyNotFoundException,
java.lang.NullPointerException,
java.io.InvalidClassException
key - the key whose associated value is to be returnedGSKeyNotFoundException - if this object contains no mapping for the specifiedjava.lang.NullPointerExceptionjava.io.InvalidClassExceptionpublic java.lang.String getString(java.lang.String key,
java.lang.String defaultValue)
key - the key whose associated value is to be returneddefaultValue - the String value to be returned if this object doesn't contain the specified key.public java.lang.String getString(java.lang.String key)
throws GSKeyNotFoundException
key - the key whose associated value is to be returnedGSKeyNotFoundException - if this object contains no mapping for the specifiedpublic GSObject getObject(java.lang.String key, GSObject defaultValue)
key - the key whose associated value is to be returneddefaultValue - the GSObject value to be returned if this object doesn't contain the specified key.public GSObject getObject(java.lang.String key) throws GSKeyNotFoundException
key - the key whose associated value is to be returnedGSKeyNotFoundException - if this object contains no mapping for the specifiedpublic GSArray getArray(java.lang.String key, GSArray defaultValue)
key - the key whose associated value is to be returneddefaultValue - the GSArrayvalue to be returned if this object doesn't contain the specified key.public GSArray getArray(java.lang.String key) throws GSKeyNotFoundException
key - the key whose associated value is to be returnedGSKeyNotFoundException - if this object contains no mapping for the specified keypublic java.lang.Object get(java.lang.String key,
java.lang.Object defaultValue)
public java.lang.Object get(java.lang.String key)
throws GSKeyNotFoundException
GSKeyNotFoundExceptionpublic void parseURL(java.lang.String url)
url - the URL string to parsepublic void parseQueryString(java.lang.String qs)
qs - the query string to parsepublic boolean containsKey(java.lang.String key)
key - key whose presence in this map is to be testedpublic void remove(java.lang.String key)
key - the key that needs to be removed.public void clear()
public java.lang.String[] getKeys()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toJsonString()
public GSObject clone()
clone in class java.lang.Objectprotected java.util.TreeMap<java.lang.String,java.lang.Object> getMap()
protected org.json.JSONObject toJsonObject()
throws org.json.JSONException
org.json.JSONException