com.novell.sentinel.json
Class JSONUtils

java.lang.Object
  extended by com.novell.sentinel.json.JSONUtils

public class JSONUtils
extends Object

Utility class for creating and reading JSON data.


Nested Class Summary
static class JSONUtils.JSONNumberValueException
           
static class JSONUtils.JSONValueException
           
 
Field Summary
static char ARRAY_END
           
static char ARRAY_START
           
static char ESCAPE
           
static String FALSE
           
static String NULL
           
static char OBJECT_END
           
static char OBJECT_START
           
static char PAIR_SEPARATOR
           
static char STRING_DELIMITER
           
static String TRUE
           
static char VALUE_SEPARATOR
           
 
Constructor Summary
JSONUtils()
           
 
Method Summary
static boolean booleanFromJSON(String jsonValue)
           
static Boolean booleanObjectFromJSON(String jsonValue)
           
static char charFromJSON(String jsonValue)
           
static Character charObjectFromJSON(String jsonValue)
           
static Date dateFromISOString(String value)
           
static Date dateFromJSON(String jsonValue)
           
static String formatDate(Date value)
           
static JSONDateHandler getDateHandler()
           
static int intFromJSON(String jsonValue)
           
static Integer intObjectFromJSON(String jsonValue)
           
static long longFromJSON(String jsonValue)
           
static Long longObjectFromJSON(String jsonValue)
           
static void setDateHandler(JSONDateHandler handler)
          Set the environment-dependent implementation of JSONDateHandler for use in serializing and parsing Date values.
static short shortFromJSON(String jsonValue)
           
static Short shortObjectFromJSON(String jsonValue)
           
static String stringFromJSON(String jsonValue)
           
static String toJSON(boolean value)
           
static String toJSON(Boolean value)
           
static String toJSON(boolean[] array)
           
static String toJSON(Boolean[] array)
           
static String toJSON(char value)
           
static String toJSON(Character value)
           
static String toJSON(Date value)
           
static String toJSON(int value)
           
static String toJSON(Integer value)
           
static String toJSON(long value)
           
static String toJSON(Long value)
           
static String toJSON(short value)
           
static String toJSON(Short value)
           
static String toJSON(String value)
           
static String toJSON(String name, String jsonValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL

public static final String NULL
See Also:
Constant Field Values

TRUE

public static final String TRUE
See Also:
Constant Field Values

FALSE

public static final String FALSE
See Also:
Constant Field Values

OBJECT_START

public static final char OBJECT_START
See Also:
Constant Field Values

OBJECT_END

public static final char OBJECT_END
See Also:
Constant Field Values

ARRAY_START

public static final char ARRAY_START
See Also:
Constant Field Values

ARRAY_END

public static final char ARRAY_END
See Also:
Constant Field Values

PAIR_SEPARATOR

public static final char PAIR_SEPARATOR
See Also:
Constant Field Values

VALUE_SEPARATOR

public static final char VALUE_SEPARATOR
See Also:
Constant Field Values

STRING_DELIMITER

public static final char STRING_DELIMITER
See Also:
Constant Field Values

ESCAPE

public static final char ESCAPE
See Also:
Constant Field Values
Constructor Detail

JSONUtils

public JSONUtils()
Method Detail

setDateHandler

public static void setDateHandler(JSONDateHandler handler)
Set the environment-dependent implementation of JSONDateHandler for use in serializing and parsing Date values.

This method should only be called once at start up of the module using the JSONUtils class.

Parameters:
handler - The implementation.

getDateHandler

public static JSONDateHandler getDateHandler()

toJSON

public static String toJSON(String name,
                            String jsonValue)

toJSON

public static String toJSON(String value)

toJSON

public static String toJSON(boolean value)

toJSON

public static String toJSON(Boolean value)

toJSON

public static String toJSON(short value)

toJSON

public static String toJSON(Short value)

toJSON

public static String toJSON(char value)

toJSON

public static String toJSON(Character value)

toJSON

public static String toJSON(int value)

toJSON

public static String toJSON(Integer value)

toJSON

public static String toJSON(long value)

toJSON

public static String toJSON(Long value)

formatDate

public static String formatDate(Date value)

toJSON

public static String toJSON(Date value)

toJSON

public static String toJSON(boolean[] array)

toJSON

public static String toJSON(Boolean[] array)

stringFromJSON

public static String stringFromJSON(String jsonValue)
                             throws JSONUtils.JSONValueException
Throws:
JSONUtils.JSONValueException

booleanFromJSON

public static boolean booleanFromJSON(String jsonValue)
                               throws JSONUtils.JSONValueException
Throws:
JSONUtils.JSONValueException

booleanObjectFromJSON

public static Boolean booleanObjectFromJSON(String jsonValue)
                                     throws JSONUtils.JSONValueException
Throws:
JSONUtils.JSONValueException

shortFromJSON

public static short shortFromJSON(String jsonValue)
                           throws JSONUtils.JSONValueException
Throws:
JSONUtils.JSONValueException

shortObjectFromJSON

public static Short shortObjectFromJSON(String jsonValue)
                                 throws JSONUtils.JSONValueException
Throws:
JSONUtils.JSONValueException

charFromJSON

public static char charFromJSON(String jsonValue)
                         throws JSONUtils.JSONValueException
Throws:
JSONUtils.JSONValueException

charObjectFromJSON

public static Character charObjectFromJSON(String jsonValue)
                                    throws JSONUtils.JSONValueException
Throws:
JSONUtils.JSONValueException

intFromJSON

public static int intFromJSON(String jsonValue)
                       throws JSONUtils.JSONValueException
Throws:
JSONUtils.JSONValueException

intObjectFromJSON

public static Integer intObjectFromJSON(String jsonValue)
                                 throws JSONUtils.JSONValueException
Throws:
JSONUtils.JSONValueException

longFromJSON

public static long longFromJSON(String jsonValue)
                         throws JSONUtils.JSONValueException
Throws:
JSONUtils.JSONValueException

longObjectFromJSON

public static Long longObjectFromJSON(String jsonValue)
                               throws JSONUtils.JSONValueException
Throws:
JSONUtils.JSONValueException

dateFromISOString

public static Date dateFromISOString(String value)
                              throws JSONUtils.JSONValueException
Throws:
JSONUtils.JSONValueException

dateFromJSON

public static Date dateFromJSON(String jsonValue)
                         throws JSONUtils.JSONValueException
Throws:
JSONUtils.JSONValueException