gov.usgs.earthquake.event
Class JsonUtil

java.lang.Object
  extended by gov.usgs.earthquake.event.JsonUtil

public class JsonUtil
extends java.lang.Object

Utility class for (safely) converting JSONSimple Objects to their types.


Constructor Summary
JsonUtil()
           
 
Method Summary
static java.math.BigDecimal getBigDecimal(java.lang.Object o)
          Convert Object to BigDecimal.
static java.util.Date getDate(java.lang.Object o)
          Convert Object to Date.
static java.lang.Integer getInteger(java.lang.Object o)
          Convert Object to Integer.
static org.json.simple.JSONArray getJsonArray(java.lang.Object o)
          Convert Object to JSONArray.
static org.json.simple.JSONObject getJsonObject(java.lang.Object o)
          Convert Object to JSONObject.
static java.lang.Long getLong(java.lang.Object o)
          Convert Object to Long.
static java.lang.String getString(java.lang.Object o)
          Convert Object to String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonUtil

public JsonUtil()
Method Detail

getJsonObject

public static org.json.simple.JSONObject getJsonObject(java.lang.Object o)
Convert Object to JSONObject.

Parameters:
o - object to convert.
Returns:
JSONObject, or null if not JSONObject.

getJsonArray

public static org.json.simple.JSONArray getJsonArray(java.lang.Object o)
Convert Object to JSONArray.

Parameters:
o - object to convert.
Returns:
JSONArray, or null if not JSONArray.

getBigDecimal

public static java.math.BigDecimal getBigDecimal(java.lang.Object o)
Convert Object to BigDecimal.

Parameters:
o - object to convert.
Returns:
BigDecimal, or null if not BigDecimal.

getString

public static java.lang.String getString(java.lang.Object o)
Convert Object to String.

Parameters:
o - object to convert.
Returns:
String, or null if not String.

getLong

public static java.lang.Long getLong(java.lang.Object o)
Convert Object to Long.

Parameters:
o - object to convert.
Returns:
Long, or null if not Long.

getInteger

public static java.lang.Integer getInteger(java.lang.Object o)
Convert Object to Integer.

Parameters:
o - object to convert.
Returns:
Integer, or null if not Long or Integer.

getDate

public static java.util.Date getDate(java.lang.Object o)
Convert Object to Date.

Parameters:
o - object to convert.
Returns:
Date, or null if not Long or Date.