gov.sandia.cognition.io.serialization
Class AbstractTextSerializationHandler<SerializedType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.io.serialization.AbstractFileSerializationHandler<SerializedType>
          extended by gov.sandia.cognition.io.serialization.AbstractStreamSerializationHandler<SerializedType>
              extended by gov.sandia.cognition.io.serialization.AbstractTextSerializationHandler<SerializedType>
Type Parameters:
SerializedType - The type of object that can be serialized.
All Implemented Interfaces:
FileSerializationHandler<SerializedType>, StreamSerializationHandler<SerializedType>, TextSerializationHandler<SerializedType>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
XStreamSerializationHandler

public abstract class AbstractTextSerializationHandler<SerializedType>
extends AbstractStreamSerializationHandler<SerializedType>
implements TextSerializationHandler<SerializedType>

An abstract implementation of the TextSerializationHandler interface. Converts stream calls to readers/writers so all you need to implement are those versions of the methods.

Since:
3.0
Author:
Justin Basilico
See Also:
Serialized Form

Constructor Summary
AbstractTextSerializationHandler()
          Creates a new AbstractTextSerializationHandler.
 
Method Summary
 Object convertFromString(String string)
          Converts an object from its serialized string representation.
 String convertToString(SerializedType object)
          Converts a given object to its serialized string representation.
 Object readObject(InputStream stream)
          Reads an object from the given stream.
 void writeObject(OutputStream stream, SerializedType object)
          Writes an object to a given output stream.
 
Methods inherited from class gov.sandia.cognition.io.serialization.AbstractStreamSerializationHandler
convertFromBytes, convertToBytes, readFromFile, writeToFile
 
Methods inherited from class gov.sandia.cognition.io.serialization.AbstractFileSerializationHandler
readFromFile, writeToFile
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.io.serialization.TextSerializationHandler
readObject, writeObject
 
Methods inherited from interface gov.sandia.cognition.io.serialization.StreamSerializationHandler
convertFromBytes, convertToBytes
 
Methods inherited from interface gov.sandia.cognition.io.serialization.FileSerializationHandler
readFromFile, readFromFile, writeToFile, writeToFile
 

Constructor Detail

AbstractTextSerializationHandler

public AbstractTextSerializationHandler()
Creates a new AbstractTextSerializationHandler.

Method Detail

writeObject

public void writeObject(OutputStream stream,
                        SerializedType object)
                 throws IOException
Description copied from interface: StreamSerializationHandler
Writes an object to a given output stream.

Specified by:
writeObject in interface StreamSerializationHandler<SerializedType>
Parameters:
stream - The stream to write the object to.
object - The object to write.
Throws:
IOException - If there is an i/o error.

readObject

public Object readObject(InputStream stream)
                  throws IOException,
                         ClassNotFoundException
Description copied from interface: StreamSerializationHandler
Reads an object from the given stream.

Specified by:
readObject in interface StreamSerializationHandler<SerializedType>
Parameters:
stream - The stream to read an object from.
Returns:
The object read from the stream.
Throws:
IOException - If there is an i/o error.
ClassNotFoundException - If a class cannot be found.

convertToString

public String convertToString(SerializedType object)
                       throws IOException
Description copied from interface: TextSerializationHandler
Converts a given object to its serialized string representation.

Specified by:
convertToString in interface TextSerializationHandler<SerializedType>
Parameters:
object - The object to serialized to a string.
Returns:
The serialized string version of the object.
Throws:
IOException - If there is an i/o error.

convertFromString

public Object convertFromString(String string)
                         throws IOException,
                                ClassNotFoundException
Description copied from interface: TextSerializationHandler
Converts an object from its serialized string representation.

Specified by:
convertFromString in interface TextSerializationHandler<SerializedType>
Parameters:
string - The string to convert an object from.
Returns:
The object deserialized from the string.
Throws:
IOException - If there is an i/o error.
ClassNotFoundException - If a class cannot be found.