| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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  Writer | writerThe writer to use to output JSON in a semi-streaming fashion. | 
| Constructor Summary | |
|---|---|
| JSONWriter(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(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(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 Writer writer
| Constructor Detail | 
|---|
public JSONWriter(Writer writer)
           throws NullPointerException
writer - The writer to use to do 'streaming' JSON writing.
NullPointerException - Thrown if writer is null.| Method Detail | 
|---|
public JSONWriter array()
                 throws IOException,
                        IllegalStateException
IOException - Thrown if an error occurs on the underlying writer.
IllegalstateException - Thrown if the current writer position does not permit an array.
IllegalStateException
public JSONWriter endArray()
                    throws IOException
IOException - Thrown if an IO error occurs on the underlying writer.
IllegalStateException - Thrown if the writer position is not inside an array.
public JSONWriter endObject()
                     throws IOException,
                            IllegalStateException
IOException - Thrown if an IO error occurs on the underlying writer.
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(String s)
               throws IOException,
                      IllegalStateException,
                      NullPointerException
IOException - Thrown if an IO error occurs on the underlying writer.
IllegalStateException - Thrown if the current writer position is not within an object.
NullPointerException
public JSONWriter object()
                  throws IOException,
                         IllegalStateException
IllegalStateException - Thrown if an object cannot currently be created in the stream.
IOException - Thrown if an IO error occurs in the underlying writer.
public JSONWriter value(boolean b)
                 throws IOException,
                        IllegalStateException
IOException - Thrown if an IO error occurs on the underlying writer.
IllegalStateException - Thrown if the current writer position will not accept a boolean value.
public JSONWriter value(double d)
                 throws IOException,
                        IllegalStateException
d - The Double to write.
IOException - Thrown if an IO error occurs on the underlying writer.
IllegalStateException - Thrown if the current writer position will not accept a double value.
public JSONWriter value(long l)
                 throws IOException,
                        IllegalStateException
l - The long to write.
IOException - Thrown if an IO error occurs on the underlying writer.
IllegalStateException - Thrown if the current writer position will not accept a double value.
public JSONWriter value(int i)
                 throws IOException,
                        IllegalStateException
i - The int to write.
IOException - Thrown if an IO error occurs on the underlying writer.
IllegalStateException - Thrown if the current writer position will not accept a double value.
public JSONWriter value(short s)
                 throws IOException,
                        IllegalStateException
s - The short to write.
IOException - Thrown if an IO error occurs on the underlying writer.
IllegalStateException - Thrown if the current writer position will not accept a double value.
public JSONWriter value(Object o)
                 throws IOException,
                        IllegalStateException,
                        JSONException
o - The object to write.
IOException - Thrown if an IO error occurs on the underlying writer.
JSONException - Thrown if the object is not JSONAble.
IllegalStateException
public void close()
           throws IOException,
                  IllegalStateException
IOException - Thrown if an IO error occurs on the underlying writer.
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 IOException
IOException| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||