|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wink.json4j.JSONWriter
public class JSONWriter
This class implements a JSONWrier, a convenience function for writing out JSON to a writer or underlying stream.
Field Summary | |
---|---|
protected java.io.Writer |
writer
The writer to use to output JSON in a semi-streaming fashion. |
Constructor Summary | |
---|---|
JSONWriter(java.io.Writer writer)
Constructor. |
Method Summary | |
---|---|
JSONWriter |
array()
Open a new JSON Array in the output stream. |
void |
close()
Method to close the JSON Writer. |
JSONWriter |
endArray()
Method to close the current JSON Array in the stream. |
JSONWriter |
endObject()
Method to close a current JSON object in the stream. |
JSONWriter |
flush()
Method to flush the underlying writer so that all buffered content, if any, is written out. |
JSONWriter |
key(java.lang.String s)
Place a key in the current JSON Object. |
JSONWriter |
object()
Open a new JSON Object in the output stream. |
JSONWriter |
value(boolean b)
Method to write a boolean to the current writer position. |
JSONWriter |
value(double d)
Method to write a double to the current writer position. |
JSONWriter |
value(int i)
Method to write an int to the current writer position. |
JSONWriter |
value(long l)
Method to write a double to the current writer position. |
JSONWriter |
value(java.lang.Object o)
Method to write an Object to the current writer position. |
JSONWriter |
value(short s)
Method to write a short to the current writer position. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.io.Writer writer
Constructor Detail |
---|
public JSONWriter(java.io.Writer writer) throws java.lang.NullPointerException
writer
- The writer to use to do 'streaming' JSON writing.
java.lang.NullPointerException
- Thrown if writer is null.Method Detail |
---|
public JSONWriter array() throws java.io.IOException, java.lang.IllegalStateException
java.io.IOException
- Thrown if an error occurs on the underlying writer.
IllegalstateException
- Thrown if the current writer position does not permit an array.
java.lang.IllegalStateException
public JSONWriter endArray() throws java.io.IOException
java.io.IOException
- Thrown if an IO error occurs on the underlying writer.
java.lang.IllegalStateException
- Thrown if the writer position is not inside an array.public JSONWriter endObject() throws java.io.IOException, java.lang.IllegalStateException
java.io.IOException
- Thrown if an IO error occurs on the underlying writer.
java.lang.IllegalStateException
- Thrown if the writer position is not inside an object, or if the object has a key placed, but no value.public JSONWriter key(java.lang.String s) throws java.io.IOException, java.lang.IllegalStateException, java.lang.NullPointerException
java.io.IOException
- Thrown if an IO error occurs on the underlying writer.
java.lang.IllegalStateException
- Thrown if the current writer position is not within an object.
java.lang.NullPointerException
public JSONWriter object() throws java.io.IOException, java.lang.IllegalStateException
java.lang.IllegalStateException
- Thrown if an object cannot currently be created in the stream.
java.io.IOException
- Thrown if an IO error occurs in the underlying writer.public JSONWriter value(boolean b) throws java.io.IOException, java.lang.IllegalStateException
java.io.IOException
- Thrown if an IO error occurs on the underlying writer.
java.lang.IllegalStateException
- Thrown if the current writer position will not accept a boolean value.public JSONWriter value(double d) throws java.io.IOException, java.lang.IllegalStateException
d
- The Double to write.
java.io.IOException
- Thrown if an IO error occurs on the underlying writer.
java.lang.IllegalStateException
- Thrown if the current writer position will not accept a double value.public JSONWriter value(long l) throws java.io.IOException, java.lang.IllegalStateException
l
- The long to write.
java.io.IOException
- Thrown if an IO error occurs on the underlying writer.
java.lang.IllegalStateException
- Thrown if the current writer position will not accept a double value.public JSONWriter value(int i) throws java.io.IOException, java.lang.IllegalStateException
i
- The int to write.
java.io.IOException
- Thrown if an IO error occurs on the underlying writer.
java.lang.IllegalStateException
- Thrown if the current writer position will not accept a double value.public JSONWriter value(short s) throws java.io.IOException, java.lang.IllegalStateException
s
- The short to write.
java.io.IOException
- Thrown if an IO error occurs on the underlying writer.
java.lang.IllegalStateException
- Thrown if the current writer position will not accept a double value.public JSONWriter value(java.lang.Object o) throws java.io.IOException, java.lang.IllegalStateException, JSONException
o
- The object to write.
java.io.IOException
- Thrown if an IO error occurs on the underlying writer.
JSONException
- Thrown if the object is not JSONAble.
java.lang.IllegalStateException
public void close() throws java.io.IOException, java.lang.IllegalStateException
java.io.IOException
- Thrown if an IO error occurs on the underlying writer.
java.lang.IllegalStateException
- Thrown if the writer position is in an object and a key has been placed, but a value has not been assigned or if the writer was already closed.public JSONWriter flush() throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |