|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnu.validator.json.Serializer
public class Serializer
| Nested Class Summary | |
|---|---|
private static class |
Serializer.State
|
| Field Summary | |
|---|---|
private boolean |
first
|
private boolean |
hadCallback
|
private List<Serializer.State> |
stack
|
private Writer |
writer
|
| Constructor Summary | |
|---|---|
Serializer(OutputStream out)
|
|
| Method Summary | |
|---|---|
void |
bool(boolean bool)
Reports a boolean. |
void |
characters(char[] ch,
int start,
int length)
Adds characters to the current string started with startString(). |
private void |
charactersImpl(char[] ch,
int start,
int length)
|
void |
endArray()
Reports the end of an array. |
void |
endDocument()
Reports the end of the JSON file. |
void |
endObject()
Reports the end of an object. |
void |
endString()
Reports the end of a string. |
void |
key(String key)
Starts a key-value pair inside an object. |
private static Writer |
newOutputStreamWriter(OutputStream out)
|
void |
number(double number)
Reports a number. |
void |
number(float number)
Reports a number. |
void |
number(int number)
Reports a number. |
void |
number(long number)
Reports a number. |
private Serializer.State |
peek()
|
private void |
pop()
|
private void |
push(Serializer.State state)
|
void |
startArray()
Reports the start of an array. |
void |
startDocument(String callback)
Reports the start of the JSON file. |
void |
startObject()
Reports the start of an object. |
void |
startString()
Reports the start of a string. |
void |
string(String string)
Reports a JSON null on null and
a string otherwise. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final List<Serializer.State> stack
private boolean hadCallback
private boolean first
private final Writer writer
| Constructor Detail |
|---|
public Serializer(OutputStream out)
| Method Detail |
|---|
private static Writer newOutputStreamWriter(OutputStream out)
private void push(Serializer.State state)
private void pop()
private Serializer.State peek()
public void bool(boolean bool)
throws SAXException
JsonHandler
bool in interface JsonHandlerbool - the boolean
SAXException - if bad things happen
private void charactersImpl(char[] ch,
int start,
int length)
throws IOException
IOException
public void characters(char[] ch,
int start,
int length)
throws SAXException
JsonHandlerstartString().
characters in interface JsonHandlerch - a buffer of UTF-16 code unitsstart - the first code unit to readlength - the number of code units to read
SAXException - if bad things happen
public void endArray()
throws SAXException
JsonHandler
endArray in interface JsonHandlerSAXException - if bad things happen
public void endDocument()
throws SAXException
JsonHandlerfinally.
endDocument in interface JsonHandlerSAXException - if bad things happen
public void endObject()
throws SAXException
JsonHandler
endObject in interface JsonHandlerSAXException - if bad things happen
public void endString()
throws SAXException
JsonHandler
endString in interface JsonHandlerSAXException - if bad things happen
public void key(String key)
throws SAXException
JsonHandlerkey gives the key and the next
reported value is taken to be the value associated with
the key. (Hence, there is no need for a corresponding
end callback.)
key in interface JsonHandlerkey - the key for the key-value pair (must not be null)
SAXException - if bad things happen
public void number(int number)
throws SAXException
JsonHandler
number in interface JsonHandlernumber - the number
SAXException - if bad things happen
public void number(long number)
throws SAXException
JsonHandler
number in interface JsonHandlernumber - the number
SAXException - if bad things happen
public void number(float number)
throws SAXException
JsonHandler
number in interface JsonHandlernumber - the number
SAXException - if bad things happen
public void number(double number)
throws SAXException
JsonHandler
number in interface JsonHandlernumber - the number
SAXException - if bad things happen
public void startArray()
throws SAXException
JsonHandler
startArray in interface JsonHandlerSAXException - if bad things happen
public void startDocument(String callback)
throws SAXException
JsonHandlercallback is
null, the file is a pure JSON file. With a non-null
callback, a JSON value is wrapped in a function call named
callback.
Note that the JSON null value is represented as
string(null).
startDocument in interface JsonHandlercallback - JavaScript callback function name or null for
pure JSON.
SAXException - if bad things happen
public void startObject()
throws SAXException
JsonHandler
startObject in interface JsonHandlerSAXException - if bad things happen
public void startString()
throws SAXException
JsonHandler
startString in interface JsonHandlerSAXException - if bad things happen
public void string(String string)
throws SAXException
JsonHandlernull and
a string otherwise.
When the argument is not null, this method is
shorthand for
startString(); characters(string.toCharArray(), 0, string.length()); endString();
string in interface JsonHandlerstring - a string or null
SAXException - if bad things happen
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||