Class JSONContentHandler

  • All Implemented Interfaces:
    org.json.simple.parser.ContentHandler
    Direct Known Subclasses:
    LibraryJSONContentHandler

    public class JSONContentHandler
    extends Object
    implements org.json.simple.parser.ContentHandler
    A simplified and stoppable SAX-like content handler for stream processing of JSON text.
    Author:
    Hendrik Schreiber
    • Field Detail

      • LONG_CACHE

        public static final Map<Long,​Long> LONG_CACHE
    • Constructor Detail

      • JSONContentHandler

        public JSONContentHandler()
    • Method Detail

      • getRoot

        public Object getRoot()
      • startJSON

        public void startJSON()
                       throws org.json.simple.parser.ParseException,
                              IOException
        Specified by:
        startJSON in interface org.json.simple.parser.ContentHandler
        Throws:
        org.json.simple.parser.ParseException
        IOException
      • endJSON

        public void endJSON()
                     throws org.json.simple.parser.ParseException,
                            IOException
        Specified by:
        endJSON in interface org.json.simple.parser.ContentHandler
        Throws:
        org.json.simple.parser.ParseException
        IOException
      • startObject

        public boolean startObject()
                            throws org.json.simple.parser.ParseException,
                                   IOException
        Specified by:
        startObject in interface org.json.simple.parser.ContentHandler
        Throws:
        org.json.simple.parser.ParseException
        IOException
      • endObject

        public boolean endObject()
                          throws org.json.simple.parser.ParseException,
                                 IOException
        Specified by:
        endObject in interface org.json.simple.parser.ContentHandler
        Throws:
        org.json.simple.parser.ParseException
        IOException
      • processItem

        public boolean processItem​(Object object)
                            throws org.json.simple.parser.ParseException,
                                   IOException
        Overwrite this method to process specific objects.
        Parameters:
        object - object
        Returns:
        false to abort further processing
        Throws:
        org.json.simple.parser.ParseException
        IOException
      • addObjectToContainer

        public boolean addObjectToContainer​(Object object)
        Overwrite this method to prevent an object to be added to its surrounding container. This can be useful for inline processing to preserve memory.
        Parameters:
        object - object
        Returns:
        false, if the given object should be added to the surrounding container.
      • startObjectEntry

        public boolean startObjectEntry​(String key)
                                 throws org.json.simple.parser.ParseException,
                                        IOException
        Specified by:
        startObjectEntry in interface org.json.simple.parser.ContentHandler
        Throws:
        org.json.simple.parser.ParseException
        IOException
      • endObjectEntry

        public boolean endObjectEntry()
                               throws org.json.simple.parser.ParseException,
                                      IOException
        Specified by:
        endObjectEntry in interface org.json.simple.parser.ContentHandler
        Throws:
        org.json.simple.parser.ParseException
        IOException
      • startArray

        public boolean startArray()
                           throws org.json.simple.parser.ParseException,
                                  IOException
        Specified by:
        startArray in interface org.json.simple.parser.ContentHandler
        Throws:
        org.json.simple.parser.ParseException
        IOException
      • endArray

        public boolean endArray()
                         throws org.json.simple.parser.ParseException,
                                IOException
        Specified by:
        endArray in interface org.json.simple.parser.ContentHandler
        Throws:
        org.json.simple.parser.ParseException
        IOException
      • primitive

        public boolean primitive​(Object newObject)
                          throws org.json.simple.parser.ParseException,
                                 IOException
        Specified by:
        primitive in interface org.json.simple.parser.ContentHandler
        Throws:
        org.json.simple.parser.ParseException
        IOException