org.quickconnectfamily.json
Class JSONParser

java.lang.Object
  extended by org.quickconnectfamily.json.JSONParser

public class JSONParser
extends java.lang.Object

Parser for JSON text. Please note that JSONParser used independently is NOT thread-safe. Use the JSONInputStream with the JSONStreamProtector and is is thread safe.

Author:
FangYidong. Greatly modified by Lee S. Barney

Field Summary
static int FIRST_JSON_CHAR_TYPE_UNSET
           
static int S_END
           
static int S_IN_ARRAY
           
static int S_IN_ERROR
           
static int S_IN_FINISHED_VALUE
           
static int S_IN_OBJECT
           
static int S_IN_PAIR_VALUE
           
static int S_INIT
           
static int S_PASSED_PAIR_KEY
           
 
Constructor Summary
JSONParser(java.io.Reader in)
           
 
Method Summary
 void closeReader()
           
 int getPosition()
           
 java.lang.Object parse()
           
 java.lang.Object parse(ContainerFactory containerFactory)
          Parse JSON text into java object from the input source.
 void reset()
           
 void reset(java.io.Reader in)
          Reset the parser to the initial state with a new character reader.
 void setFirstCharType(int firstCharType)
          Reset the parser to the initial state without resetting the underlying reader.
 void setNumUnmatchedCharTypeCount(int numUnmatchedCharTypeCount)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

S_INIT

public static final int S_INIT
See Also:
Constant Field Values

S_IN_FINISHED_VALUE

public static final int S_IN_FINISHED_VALUE
See Also:
Constant Field Values

S_IN_OBJECT

public static final int S_IN_OBJECT
See Also:
Constant Field Values

S_IN_ARRAY

public static final int S_IN_ARRAY
See Also:
Constant Field Values

S_PASSED_PAIR_KEY

public static final int S_PASSED_PAIR_KEY
See Also:
Constant Field Values

S_IN_PAIR_VALUE

public static final int S_IN_PAIR_VALUE
See Also:
Constant Field Values

S_END

public static final int S_END
See Also:
Constant Field Values

S_IN_ERROR

public static final int S_IN_ERROR
See Also:
Constant Field Values

FIRST_JSON_CHAR_TYPE_UNSET

public static final int FIRST_JSON_CHAR_TYPE_UNSET
See Also:
Constant Field Values
Constructor Detail

JSONParser

public JSONParser(java.io.Reader in)
Method Detail

setFirstCharType

public void setFirstCharType(int firstCharType)
Reset the parser to the initial state without resetting the underlying reader.


closeReader

public void closeReader()
                 throws java.io.IOException
Throws:
java.io.IOException

setNumUnmatchedCharTypeCount

public void setNumUnmatchedCharTypeCount(int numUnmatchedCharTypeCount)

reset

public void reset()

reset

public void reset(java.io.Reader in)
Reset the parser to the initial state with a new character reader.

Parameters:
in - - The new character reader.
Throws:
java.io.IOException
ParseException

getPosition

public int getPosition()
Returns:
The position of the beginning of the current token.

parse

public java.lang.Object parse()
                       throws java.io.IOException,
                              ParseException
Throws:
java.io.IOException
ParseException

parse

public java.lang.Object parse(ContainerFactory containerFactory)
                       throws java.io.IOException,
                              ParseException
Parse JSON text into java object from the input source.

Parameters:
in -
containerFactory - - Use this factory to create your own JSON object and JSON array containers.
Returns:
Instance of the following: org.json.simple.JSONObject, org.json.simple.JSONArray, java.lang.String, java.lang.Number, java.lang.Boolean, null
Throws:
java.io.IOException
ParseException