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/).

Author:
Fang Yidong, Lakshmi Krishnamurthy
  • Field Summary

    Fields
    Modifier and Type Field Description
    static int S_END
    Processor Finished
    static int S_IN_ARRAY
    Processor Initialized with Array
    static int S_IN_ERROR
    Processor In Error
    static int S_IN_FINISHED_VALUE
    Processor Initialized with Value
    static int S_IN_OBJECT
    Processor Initialized with Object
    static int S_IN_PAIR_VALUE
    Processor Initialized with Value Pair
    static int S_INIT
    Processor Initialized
    static 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 Reader
    java.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 Handler
    void 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 String
    java.lang.Object parse​(java.lang.String s, ContainerFactory containerFactory)
    Parse the JSON String
    void parse​(java.lang.String s, ContentHandler contentHandler)
    Parse the String using the specified Content Handler
    void parse​(java.lang.String s, ContentHandler contentHandler, boolean isResume)
    Parse the String using the specified Content Handler
    void 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_INIT
      Processor Initialized
      See Also:
      Constant Field Values
    • S_IN_FINISHED_VALUE

      public static final int S_IN_FINISHED_VALUE
      Processor Initialized with Value
      See Also:
      Constant Field Values
    • S_IN_OBJECT

      public static final int S_IN_OBJECT
      Processor Initialized with Object
      See Also:
      Constant Field Values
    • S_IN_ARRAY

      public static final int S_IN_ARRAY
      Processor Initialized with Array
      See Also:
      Constant Field Values
    • S_PASSED_PAIR_KEY

      public static final int S_PASSED_PAIR_KEY
      Processor Initialized with Key Pair
      See Also:
      Constant Field Values
    • S_IN_PAIR_VALUE

      public static final int S_IN_PAIR_VALUE
      Processor Initialized with Value Pair
      See Also:
      Constant Field Values
    • S_END

      public static final int S_END
      Processor Finished
      See Also:
      Constant Field Values
    • S_IN_ERROR

      public static final int S_IN_ERROR
      Processor 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

      public java.lang.Object parse​(java.lang.String s) throws ParseException
      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 ParseException
      Parse the JSON String
      Parameters:
      s - The String
      containerFactory - The Container Factory
      Returns:
      The JSON Object
      Throws:
      ParseException - Thrown if the Inputs are Invalid
    • parse

      public java.lang.Object parse​(java.io.Reader in) throws java.io.IOException, ParseException
      Parse from the Input Reader
      Parameters:
      in - The Input Reader
      Returns:
      The Parsed Object
      Throws:
      java.io.IOException - Thrown if the IOException is encountered
      ParseException - Thrown if the Inputs are Invalid
    • parse

      public java.lang.Object parse​(java.io.Reader in, ContainerFactory containerFactory) throws java.io.IOException, ParseException
      Parse JSON text into java object from the input source.
      Parameters:
      in - The Input Reader
      containerFactory - - 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 Invalid
      ParseException - Thrown if the Inputs are Invalid
    • parse

      public void parse​(java.lang.String s, ContentHandler contentHandler) throws ParseException
      Parse the String using the specified Content Handler
      Parameters:
      s - Input String
      contentHandler - The Content Handler
      Throws:
      ParseException - Thrown if Parser Exception encountered
    • parse

      public void parse​(java.lang.String s, ContentHandler contentHandler, boolean isResume) throws ParseException
      Parse the String using the specified Content Handler
      Parameters:
      s - Input String
      contentHandler - The Content Handler
      isResume - 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, ParseException
      Parse from the Input Reader using the specified Content Handler
      Parameters:
      in - Input Reader
      contentHandler - The Content Handler
      Throws:
      java.io.IOException - Thrown if the IOException is encountered
      ParseException - Thrown if Parser Exception encountered
    • parse

      public void parse​(java.io.Reader in, ContentHandler contentHandler, boolean isResume) throws java.io.IOException, ParseException
      Stream processing of JSON text.
      Parameters:
      in - The Input Reader
      contentHandler - The Content Handler Instance
      isResume - - 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 Invalid
      ParseException - Thrown if the Inputs are Invalid
      See Also:
      ContentHandler