org.sandev.basics.nodecommon
Interface CharSerializer

All Superinterfaces:
Serializer

public interface CharSerializer
extends Serializer

Character-based Serializer. Used for non-binary serialization. See the superinterface for details.

To use a Serializer to write to a String, consider using a ByteArrayOutputStream and then calling its toString() method to retrieve the result String. To read, use the getBytes method of the String as input to the ByteArrayInputStream ctor.

Most other formats have associated input/output streams that are fairly straightforward (e.g. FileInputStream/FileOutputStream).


Method Summary
 boolean isArray(java.io.Reader in)
          Destructively tests the stream to see if it contains an array or a single SandMessage.
 SandMessage read(java.io.Reader in)
          Read the specified stream for a SandMessage.
 SandMessage[] readArray(java.io.Reader in)
          Reads the specified stream for a SandMessage[].
 void write(SandMessage msg, java.io.PrintWriter out)
          Write the specified SandMessage to the output stream.
 void writeArray(SandMessage[] msgArray, java.io.PrintWriter out)
          Write the specified SandMessage[] to the output stream.
 

Method Detail

write

void write(SandMessage msg,
           java.io.PrintWriter out)
           throws java.io.IOException
Write the specified SandMessage to the output stream. If the msg is null, the results are undefined. If anything goes wrong an IOException is thrown. The implementation calls through to the corresponding static method to ensure reentrancy.

Throws:
java.io.IOException

read

SandMessage read(java.io.Reader in)
                 throws java.io.IOException
Read the specified stream for a SandMessage. If no SandMessage was found, this method returns null. If an array is found, or if any other problem occurs, an IOException is thrown. The implementation calls through to the corresponding static method to ensure reentrancy.

Throws:
java.io.IOException

writeArray

void writeArray(SandMessage[] msgArray,
                java.io.PrintWriter out)
                throws java.io.IOException
Write the specified SandMessage[] to the output stream. This method assumes that msgArray is not null. If the array is empty, then an empty array is written so it can be read back as empty. If anything goes wrong, an IOException is thrown. The implementation calls through to the corresponding static method to ensure reentrancy.

Throws:
java.io.IOException

readArray

SandMessage[] readArray(java.io.Reader in)
                        throws java.io.IOException
Reads the specified stream for a SandMessage[]. If no array was found, this method returns null. If a single message is found, or if any other problem occurs, an IOException is thrown.

Throws:
java.io.IOException

isArray

boolean isArray(java.io.Reader in)
                throws java.io.IOException
Destructively tests the stream to see if it contains an array or a single SandMessage. The stream must be reset after calling this method since the first part of it will have been read to determine the result.

Throws:
java.io.IOException