org.apache.pivot.serialization
Class StringSerializer

java.lang.Object
  extended by org.apache.pivot.serialization.StringSerializer
All Implemented Interfaces:
Serializer<String>

public class StringSerializer
extends Object
implements Serializer<String>

Implementation of the Serializer interface that reads data from and writes data to Java Strings.


Field Summary
static int BUFFER_SIZE
           
static String DEFAULT_CHARSET_NAME
           
static String MIME_TYPE
           
static String TEXT_EXTENSION
           
 
Constructor Summary
StringSerializer()
           
StringSerializer(Charset charset)
           
 
Method Summary
 Charset getCharset()
           
 String getMIMEType(String object)
          Returns the MIME type of the data read and written by this serializer.
 String readObject(InputStream inputStream)
          Reads plain text data from an input stream.
 void writeObject(String text, OutputStream outputStream)
          Writes plain text data to an output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CHARSET_NAME

public static final String DEFAULT_CHARSET_NAME
See Also:
Constant Field Values

TEXT_EXTENSION

public static final String TEXT_EXTENSION
See Also:
Constant Field Values

MIME_TYPE

public static final String MIME_TYPE
See Also:
Constant Field Values

BUFFER_SIZE

public static final int BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

StringSerializer

public StringSerializer()

StringSerializer

public StringSerializer(Charset charset)
Method Detail

getCharset

public Charset getCharset()

readObject

public String readObject(InputStream inputStream)
                  throws IOException,
                         SerializationException
Reads plain text data from an input stream.

Specified by:
readObject in interface Serializer<String>
Parameters:
inputStream - The input stream from which data will be read.
Returns:
An instance of String containing the text read from the input stream.
Throws:
IOException
SerializationException

writeObject

public void writeObject(String text,
                        OutputStream outputStream)
                 throws IOException,
                        SerializationException
Writes plain text data to an output stream.

Specified by:
writeObject in interface Serializer<String>
Parameters:
text - The text to be written to the output stream.
outputStream - The output stream to which data will be written.
Throws:
IOException
SerializationException

getMIMEType

public String getMIMEType(String object)
Description copied from interface: Serializer
Returns the MIME type of the data read and written by this serializer.

Specified by:
getMIMEType in interface Serializer<String>
Parameters:
object - If provided, allows the serializer to attach parameters to the returned MIME type containing more detailed information about the data. If null, the base MIME type is returned.