ariba.util.io
Class FormattingSerializer

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

public class FormattingSerializer
extends Serializer

Serializer subclass that formats and indents the ASCII generated by the Serializer. This class makes it possible to insert comments into a serialization.


Constructor Summary
FormattingSerializer(java.io.Writer writer)
          Constructs a FormattingSerializer that writes to writer.
 
Method Summary
static java.lang.String formatString(java.lang.String input)
          Convenience method to format any ASCII serialization produced by a Serializer.
 int indentationLength()
          Returns the number of spaces currently used to indent an expression.
static java.lang.String serializeObject(java.lang.Object anObject)
          Convenience method for generating anObject's ASCII serialization.
static java.lang.String serializeObject(java.lang.Object anObject, int length)
          Convenience method for generating anObject's ASCII serialization.
 void setIndentationLength(int numberOfSpaces)
          Sets the number of spaces to indent an expression.
 void writeComment(java.lang.String aComment, boolean cStyle)
          Writes aComment to the FormattingSerializer's writer.
 void writeObject(java.lang.Object anObject)
          Overridden to produce a formatted serialization of anObject.
static boolean writeObject(java.io.Writer writer, java.lang.Object anObject)
          Convenience method for writing anObjectwriter.
 
Methods inherited from class ariba.util.io.Serializer
flush
 
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

FormattingSerializer

public FormattingSerializer(java.io.Writer writer)
Constructs a FormattingSerializer that writes to writer.

Method Detail

setIndentationLength

public void setIndentationLength(int numberOfSpaces)
Sets the number of spaces to indent an expression. The default value is 4.


indentationLength

public int indentationLength()
Returns the number of spaces currently used to indent an expression.


writeComment

public void writeComment(java.lang.String aComment,
                         boolean cStyle)
                  throws java.io.IOException
Writes aComment to the FormattingSerializer's writer. Ignores all non-ASCII characters. If cStyle is true, the FormattingSerializer will use C-style delimiters, otherwise it will use C++-style delimiters ("//"). aComment should not include comment delimiters.

Throws:
java.io.IOException

writeObject

public void writeObject(java.lang.Object anObject)
                 throws java.io.IOException
Overridden to produce a formatted serialization of anObject.

Overrides:
writeObject in class Serializer
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.


serializeObject

public static java.lang.String serializeObject(java.lang.Object anObject,
                                               int length)
Convenience method for generating anObject's ASCII serialization. This version will truncate the serialized object to about the maxLength. It will also add a warning message when truncation occurs. Returns null on empty input.


formatString

public static java.lang.String formatString(java.lang.String input)
Convenience method to format any ASCII serialization produced by a Serializer. 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.