Package org.drip.service.jsonparser
Class LexicalProcessor
java.lang.Object
org.drip.service.jsonparser.LexicalProcessor
public class LexicalProcessor
extends java.lang.Object
LexicalProcessor is an Adaptation of the JSONParser Class from the RFC4627 compliant JSON Simple
(https://code.google.com/p/json-simple/).
- Module = Computational Core Module
- Library = Computation Support
- Project = Environment, Product/Definition Containers, and Scenario/State Manipulation APIs
- Package = RFC4627 Compliant JSON Message Parser
- Author:
- Fang Yidong, Lakshmi Krishnamurthy
-
Field Summary
Fields Modifier and Type Field Description static int
S_END
Processor Finishedstatic int
S_IN_ARRAY
Processor Initialized with Arraystatic int
S_IN_ERROR
Processor In Errorstatic int
S_IN_FINISHED_VALUE
Processor Initialized with Valuestatic int
S_IN_OBJECT
Processor Initialized with Objectstatic int
S_IN_PAIR_VALUE
Processor Initialized with Value Pairstatic int
S_INIT
Processor Initializedstatic int
S_PASSED_PAIR_KEY
Processor Initialized with Key Pair -
Constructor Summary
Constructors Constructor Description LexicalProcessor()
-
Method Summary
Modifier and Type Method Description int
getPosition()
Retrieve the position of the beginning of the current token.java.lang.Object
parse(java.io.Reader in)
Parse from the Input Readerjava.lang.Object
parse(java.io.Reader in, ContainerFactory containerFactory)
Parse JSON text into java object from the input source.void
parse(java.io.Reader in, ContentHandler contentHandler)
Parse from the Input Reader using the specified Content Handlervoid
parse(java.io.Reader in, ContentHandler contentHandler, boolean isResume)
Stream processing of JSON text.java.lang.Object
parse(java.lang.String s)
Parse an Object from the Stringjava.lang.Object
parse(java.lang.String s, ContainerFactory containerFactory)
Parse the JSON Stringvoid
parse(java.lang.String s, ContentHandler contentHandler)
Parse the String using the specified Content Handlervoid
parse(java.lang.String s, ContentHandler contentHandler, boolean isResume)
Parse the String using the specified Content Handlervoid
reset()
Reset the parser to the initial state without resetting the underlying reader.void
reset(java.io.Reader in)
Reset the parser to the initial state with a new character reader.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
S_INIT
public static final int S_INITProcessor Initialized- See Also:
- Constant Field Values
-
S_IN_FINISHED_VALUE
public static final int S_IN_FINISHED_VALUEProcessor Initialized with Value- See Also:
- Constant Field Values
-
S_IN_OBJECT
public static final int S_IN_OBJECTProcessor Initialized with Object- See Also:
- Constant Field Values
-
S_IN_ARRAY
public static final int S_IN_ARRAYProcessor Initialized with Array- See Also:
- Constant Field Values
-
S_PASSED_PAIR_KEY
public static final int S_PASSED_PAIR_KEYProcessor Initialized with Key Pair- See Also:
- Constant Field Values
-
S_IN_PAIR_VALUE
public static final int S_IN_PAIR_VALUEProcessor Initialized with Value Pair- See Also:
- Constant Field Values
-
S_END
public static final int S_ENDProcessor Finished- See Also:
- Constant Field Values
-
S_IN_ERROR
public static final int S_IN_ERRORProcessor In Error- See Also:
- Constant Field Values
-
-
Constructor Details
-
LexicalProcessor
public LexicalProcessor()
-
-
Method Details
-
reset
public void reset()Reset the parser to the initial state without resetting the underlying reader. -
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.
-
getPosition
public int getPosition()Retrieve the position of the beginning of the current token.- Returns:
- The position of the beginning of the current token.
-
parse
Parse an Object from the String- Parameters:
s
- Input String- Returns:
- The Parsed Object
- Throws:
ParseException
- Thrown if the Parsing cannot be completed
-
parse
public java.lang.Object parse(java.lang.String s, ContainerFactory containerFactory) throws ParseExceptionParse the JSON String- Parameters:
s
- The StringcontainerFactory
- The Container Factory- Returns:
- The JSON Object
- Throws:
ParseException
- Thrown if the Inputs are Invalid
-
parse
Parse from the Input Reader- Parameters:
in
- The Input Reader- Returns:
- The Parsed Object
- Throws:
java.io.IOException
- Thrown if the IOException is encounteredParseException
- Thrown if the Inputs are Invalid
-
parse
public java.lang.Object parse(java.io.Reader in, ContainerFactory containerFactory) throws java.io.IOException, ParseExceptionParse JSON text into java object from the input source.- Parameters:
in
- The Input ReadercontainerFactory
- - Use this factory to createyour 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
- Thrown if the Inputs are InvalidParseException
- Thrown if the Inputs are Invalid
-
parse
Parse the String using the specified Content Handler- Parameters:
s
- Input StringcontentHandler
- The Content Handler- Throws:
ParseException
- Thrown if Parser Exception encountered
-
parse
public void parse(java.lang.String s, ContentHandler contentHandler, boolean isResume) throws ParseExceptionParse the String using the specified Content Handler- Parameters:
s
- Input StringcontentHandler
- The Content HandlerisResume
- TRUE - Resume from where it was left- Throws:
ParseException
- Thrown if Parser Exception encountered
-
parse
public void parse(java.io.Reader in, ContentHandler contentHandler) throws java.io.IOException, ParseExceptionParse from the Input Reader using the specified Content Handler- Parameters:
in
- Input ReadercontentHandler
- The Content Handler- Throws:
java.io.IOException
- Thrown if the IOException is encounteredParseException
- Thrown if Parser Exception encountered
-
parse
public void parse(java.io.Reader in, ContentHandler contentHandler, boolean isResume) throws java.io.IOException, ParseExceptionStream processing of JSON text.- Parameters:
in
- The Input ReadercontentHandler
- The Content Handler InstanceisResume
- - Indicates if it continues previous parsing operation. If set to true, resume parsing the old stream, and parameter 'in' will be ignored. If this method is called for the first time in this instance, isResume will be ignored.- Throws:
java.io.IOException
- Thrown if the Inputs are InvalidParseException
- Thrown if the Inputs are Invalid- See Also:
ContentHandler
-