juglr
Class JSonBoxReader

java.lang.Object
  extended by java.io.Reader
      extended by juglr.BoxReader
          extended by juglr.JSonBoxReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class JSonBoxReader
extends BoxReader

Serialize a Message object to JSON. To save system resources you can reuse the same JSonBoxReader by calling reset(Box) when starting the serialization of a new message.

Note that contrary to JSonBoxReader this class is not thread safe.

See Also:
Box, BoxReader, JSonBoxReader

Field Summary
 
Fields inherited from class juglr.BoxReader
msg
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
JSonBoxReader(Box msg)
           
 
Method Summary
 java.lang.String asString()
          Read the entire message an return it as a string
 void close()
           
 int read()
           
 int read(char[] chars, int offset, int count)
           
 JSonBoxReader reset(Box msg)
          Prepare the reader for serializing another message.
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSonBoxReader

public JSonBoxReader(Box msg)
Method Detail

reset

public JSonBoxReader reset(Box msg)
Description copied from class: BoxReader
Prepare the reader for serializing another message.

Specified by:
reset in class BoxReader
Parameters:
msg - the message to serialize
Returns:
always returns this

asString

public java.lang.String asString()
Description copied from class: BoxReader
Read the entire message an return it as a string

Specified by:
asString in class BoxReader
Returns:
string representation of the message

read

public int read(char[] chars,
                int offset,
                int count)
         throws java.io.IOException
Specified by:
read in class java.io.Reader
Throws:
java.io.IOException

read

public int read()
Overrides:
read in class java.io.Reader

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
java.io.IOException