Package com.tagtraum.core.json
Class JSONContentHandler
- java.lang.Object
-
- com.tagtraum.core.json.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 Summary
Fields Modifier and Type Field Description static Map<Long,Long>
LONG_CACHE
-
Constructor Summary
Constructors Constructor Description JSONContentHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addObjectToContainer(Object object)
Overwrite this method to prevent an object to be added to its surrounding container.boolean
endArray()
void
endJSON()
boolean
endObject()
boolean
endObjectEntry()
Object
getRoot()
Stack<Object>
getStack()
boolean
primitive(Object newObject)
boolean
processItem(Object object)
Overwrite this method to process specific objects.boolean
startArray()
void
startJSON()
boolean
startObject()
boolean
startObjectEntry(String key)
-
-
-
Method Detail
-
getRoot
public Object getRoot()
-
startJSON
public void startJSON() throws org.json.simple.parser.ParseException, IOException
- Specified by:
startJSON
in interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.json.simple.parser.ContentHandler
- Throws:
org.json.simple.parser.ParseException
IOException
-
-