-
- All Known Implementing Classes:
JSONDefaultHandler
public interface JSONContentHandlerThis is the main interface to be implemented by an application wanting to receive JSON parsing events. An application can implement this interface and register the implementation with the JSONParser using the setContentHandler method.- Author:
- Chris Burdess
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidbooleanValue(boolean value)Notifies of a JSON boolean value.voidendArray()Indicates the end of a JSON array.voidendObject()Indicates the end of a JSON object.voidkey(java.lang.String key)Notifies of a key in a JSON object.default booleanneedsWhitespace()Indicates whether this handler needs to receive whitespace events.voidnullValue()Notifies of a JSON null value.voidnumberValue(java.lang.Number number)Notifies of a JSON number.voidsetLocator(JSONLocator locator)Receive an object that can be used to determine the current location during parsing.voidstartArray()Indicates the start of a JSON array.voidstartObject()Indicates the start of a JSON object.voidstringValue(java.lang.String value)Notifies of a JSON string.voidwhitespace(java.lang.String whitespace)Notifies of whitespace in the underlying stream.
-
-
-
Method Detail
-
startObject
void startObject() throws JSONExceptionIndicates the start of a JSON object.- Throws:
JSONException- the client may throw an exception during processing
-
endObject
void endObject() throws JSONExceptionIndicates the end of a JSON object.- Throws:
JSONException- the client may throw an exception during processing
-
startArray
void startArray() throws JSONExceptionIndicates the start of a JSON array.- Throws:
JSONException- the client may throw an exception during processing
-
endArray
void endArray() throws JSONExceptionIndicates the end of a JSON array.- Throws:
JSONException- the client may throw an exception during processing
-
numberValue
void numberValue(java.lang.Number number) throws JSONExceptionNotifies of a JSON number.- Parameters:
number- the number parsed: may be an Integer, Long, or Double- Throws:
JSONException- the client may throw an exception during processing
-
stringValue
void stringValue(java.lang.String value) throws JSONExceptionNotifies of a JSON string.- Parameters:
value- the string value, unescaped and unquoted- Throws:
JSONException- the client may throw an exception during processing
-
booleanValue
void booleanValue(boolean value) throws JSONExceptionNotifies of a JSON boolean value.- Parameters:
value- the boolean value- Throws:
JSONException- the client may throw an exception during processing
-
nullValue
void nullValue() throws JSONExceptionNotifies of a JSON null value.- Throws:
JSONException- the client may throw an exception during processing
-
whitespace
void whitespace(java.lang.String whitespace) throws JSONExceptionNotifies of whitespace in the underlying stream. Note that whitespace between key strings and their associated colon, if present, will not be reported by this method.- Parameters:
whitespace- the whitespace contents as a string- Throws:
JSONException- the client may throw an exception during processing
-
key
void key(java.lang.String key) throws JSONException
Notifies of a key in a JSON object. This is a string followed by a colon inside an object representation in the JSON source. It will always be associated with the most recent previous startObject event.- Parameters:
key- the key name- Throws:
JSONException- the client may throw an exception during processing
-
setLocator
void setLocator(JSONLocator locator)
Receive an object that can be used to determine the current location during parsing. The locator allows the application to determine the end position of any parsing-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules).- Parameters:
locator- the locator object
-
needsWhitespace
default boolean needsWhitespace()
Indicates whether this handler needs to receive whitespace events. By default, handlers do not need whitespace, which allows the parser to skip expensive string extraction for whitespace sequences. Implementations that need whitespace (e.g., for pretty-printing or preserving exact formatting) should override this to return true.- Returns:
- true if this handler wants
whitespace(String)to be called, false otherwise (default)
-
-