ariba.util.io
Class Serializer

java.lang.Object
  extended by java.io.Writer
      extended by java.io.FilterWriter
          extended by ariba.util.io.Serializer
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable
Direct Known Subclasses:
FormattingSerializer

public class Serializer
extends java.io.FilterWriter

Object subclass that can serialize a fixed set of data types (Dictionaries, arrays, Lists, and Strings) to an ASCII writer. If the object passed in is not one of these types, or contains an object that is not one of these types, the Serializer converts the object to a string via the object's toString() method. The serialization format is very similar to the output of Map's and List's toString() methods, except that strings with non-alphanumeric characters are quoted and special characters are escaped, so that the output can be unambiguously deserialized. Serializer produces an ASCII representation with few, if any, spaces separating components. To get a more readable representation, use the OutputSerializer class.

See Also:
Deserializer
Note:
1.0 Added several unsafe characters that will always be quoted (fixed problem with archiving the @ symbol)

Constructor Summary
Serializer(java.io.Writer writer)
          Constructs a Serializer that writes its output to writer.
 
Method Summary
 void flush()
          Flushes the Serializer's output to its writer.
static java.lang.String serializeObject(java.lang.Object anObject)
          Convenience method for generating anObject's ASCII serialization.
 void writeObject(java.lang.Object anObject)
          Serializes anObject to its writer
static boolean writeObject(java.io.Writer writer, java.lang.Object anObject)
          Convenience method for writing anObjectwriter.
 
Methods inherited from class java.io.FilterWriter
close, write, write, write
 
Methods inherited from class java.io.Writer
append, append, append, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Serializer

public Serializer(java.io.Writer writer)
Constructs a Serializer that writes its output to writer.

Method Detail

flush

public void flush()
           throws java.io.IOException
Flushes the Serializer's output to its writer.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.FilterWriter
Throws:
java.io.IOException

writeObject

public void writeObject(java.lang.Object anObject)
                 throws java.io.IOException
Serializes anObject to its writer

Throws:
java.io.IOException

serializeObject

public static java.lang.String serializeObject(java.lang.Object anObject)
Convenience method for generating anObject's ASCII serialization. Returns null on error.


writeObject

public static boolean writeObject(java.io.Writer writer,
                                  java.lang.Object anObject)
Convenience method for writing anObjectwriter. Returns true if the serialization and writing succeeds, rather than throwing an exception.



AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.