|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface JsonContentHandler
Content handler that defines events for JSON data structures. This interface
can be used to both generate and parse JSON data. It is modelled after the
ContentHandler
interface. For JSON generation is it more convenient
to use the DefaultJsonContentHandler
wrapper. For JSON parsing
consider to subclass your parser from EmptyJsonContentHandler
.
The JSON data is represented as a stream of events. The events begin with
startDocument()
and end with endDocument()
. Each JSON data
type is represented by a startXXX event, followed by the content, followed by
an endXXX event. For objects and arrays these events may be nested.
String values are represented as callbacks to the
value(char[], int, int)
method. Depending on the size of the string,
there might be multiple calls to represent a single value. String values are
always sent in their unescaped format.
Example: The following JSON structure
{ "Image": { "Height": 600, "Width": 800, "Title": "View from 15th Floor", "Thumbnail": { "Height": 125, "Url": "http://www.example.com/image/481989943", "Width": "100" } }, "IDs": [ 116, 943, 234, 38793 ] }is represented via the following events
startDocument(); startObject(); startMember("Image"); startObject(); startMember("Width"); startNumber(); value(800); endNumber(); endMember(); startMember("Height"); startNumber(); value(600); endNumber(); endMember(); startMember("Title"); startString(); value("View from 15th Floor", .., ..); endString(); endMember(); startMember("Thumbnail"); startObject(); startMember("Url"); startString(); value("http://www.example.com/image/481989943", .., ..); endString(); endMember(); startMember("Height"); startNumber(); value(125); endNumber(); endMember(); startMember("Width"); startString(); value("100", .., ..); endString(); endMember(); endObject(); endMember(); startMember("IDs"); startArray(); startNumber(); value(116); endNumber(); startNumber(); value(943); endNumber(); startNumber(); value(234); endNumber(); startNumber(); value(38793); endNumber(); endArray(); endMember(); endObject(); endMember(); endObject(); endDocument();
DefaultJsonContentHandler
,
EmptyJsonContentHandler
This interface is designed to be implemented by clients. |
Method Summary | |
---|---|
void |
endArray()
Indicates the end of an array |
void |
endBoolean()
Indicates the end of a boolean value |
void |
endDocument()
Indicates the end of the event sequence |
void |
endMember()
Indicates the end of a member inside an object |
void |
endNull()
Indicates the end of the null token |
void |
endNumber()
Indicates the end of a numerical value |
void |
endObject()
Indicates the end of an object |
void |
endString()
Indicates the end of a string based value |
void |
startArray()
Indicates the start of an array |
void |
startBoolean()
Indicates the start of a boolean value |
void |
startDocument()
Indicates the start of the event sequence |
void |
startMember(java.lang.String name)
Indicates the start of a member inside an object |
void |
startNull()
Indicates the start of the null token |
void |
startNumber()
Indicates the start of a numerical value, either of integer or floating type |
void |
startObject()
Indicates the start of an object |
void |
startString()
Indicates the start of a string based value |
void |
value(boolean value)
Writes a boolean value |
void |
value(char[] cbuf,
int off,
int len)
Streams the content of a string value in its unescaped form |
void |
value(double value)
Writes a floating value |
void |
value(long value)
Writes an integer value |
Method Detail |
---|
void endArray() throws java.io.IOException
java.io.IOException
void endBoolean() throws java.io.IOException
java.io.IOException
void endDocument() throws java.io.IOException
java.io.IOException
void endMember() throws java.io.IOException
java.io.IOException
void endNull() throws java.io.IOException
null
token
java.io.IOException
void endNumber() throws java.io.IOException
java.io.IOException
void endObject() throws java.io.IOException
java.io.IOException
void endString() throws java.io.IOException
java.io.IOException
void startArray() throws java.io.IOException
java.io.IOException
void startBoolean() throws java.io.IOException
java.io.IOException
void startDocument() throws java.io.IOException
java.io.IOException
void startMember(java.lang.String name) throws java.io.IOException
name
- name of the member in its unescaped form, not
null
java.io.IOException
void startNull() throws java.io.IOException
null
token
java.io.IOException
void startNumber() throws java.io.IOException
java.io.IOException
void startObject() throws java.io.IOException
java.io.IOException
void startString() throws java.io.IOException
java.io.IOException
void value(boolean value) throws java.io.IOException
value
- the boolean
java.io.IOException
void value(char[] cbuf, int off, int len) throws java.io.IOException
cbuf
- character buffer holding the data, not null
off
- index of the first valid character in the bufferlen
- length of the valid sequence
java.io.IOException
void value(double value) throws java.io.IOException
value
- the value, not NaN nor Infinity
java.io.IOException
void value(long value) throws java.io.IOException
value
- the integer
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |