com.google.gdata.wireformats.output
Class CharacterGenerator<S>

java.lang.Object
  extended by com.google.gdata.wireformats.output.CharacterGenerator<S>
Type Parameters:
S - source object type for object generation
All Implemented Interfaces:
OutputGenerator<S>
Direct Known Subclasses:
WireFormatOutputGenerator, XmlGenerator

public abstract class CharacterGenerator<S>
extends java.lang.Object
implements OutputGenerator<S>

The CharacterGenerator class is a base class to support the implementation of character-oriented OutputGenerator types. It provides common logic for determining the appropriate character set encoding based upon output properties and will provide a bridge between output streams and writers.


Constructor Summary
CharacterGenerator()
           
 
Method Summary
 void generate(java.io.OutputStream contentStream, OutputProperties outProps, S s)
          Generates content to the output stream based upon the provided request/response.
abstract  void generate(java.io.Writer contentWriter, OutputProperties outProps, S s)
          Generates character content to the specified writer.
protected static java.lang.String getCharsetEncoding(OutputProperties outProps)
          Returns the character set encoding that should be used for generated output.
protected  java.io.Writer getContentWriter(OutputProperties outProps, java.io.OutputStream contentStream)
          Returns a Writer that is properly configured to generate output based upon the request and response attributes.
protected  boolean usePrettyPrint(OutputProperties outProps)
          Returns true if the output should use a pretty printed format on output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.google.gdata.wireformats.output.OutputGenerator
getAltFormat, getSourceType
 

Constructor Detail

CharacterGenerator

public CharacterGenerator()
Method Detail

getCharsetEncoding

protected static java.lang.String getCharsetEncoding(OutputProperties outProps)
Returns the character set encoding that should be used for generated output.

Parameters:
outProps - output properties for generated output
Returns:
character set encoding for output

getContentWriter

protected java.io.Writer getContentWriter(OutputProperties outProps,
                                          java.io.OutputStream contentStream)
                                   throws java.io.IOException
Returns a Writer that is properly configured to generate output based upon the request and response attributes.

Parameters:
outProps - output properties for the generated output.
contentStream -
Returns:
output writer.
Throws:
java.io.IOException

generate

public void generate(java.io.OutputStream contentStream,
                     OutputProperties outProps,
                     S s)
              throws java.io.IOException
Description copied from interface: OutputGenerator
Generates content to the output stream based upon the provided request/response.

Specified by:
generate in interface OutputGenerator<S>
Parameters:
contentStream - the target stream for content generation.
outProps - output properties for the generated output
s - source object for output generation
Throws:
java.io.IOException

generate

public abstract void generate(java.io.Writer contentWriter,
                              OutputProperties outProps,
                              S s)
                       throws java.io.IOException
Generates character content to the specified writer.

Parameters:
contentWriter - output writer.
outProps - output properties for the generated output.
s - source object for the generated output.
Throws:
java.io.IOException

usePrettyPrint

protected boolean usePrettyPrint(OutputProperties outProps)
Returns true if the output should use a pretty printed format on output. The default implementation will pretty print output if the GDataProtocol.Parameter#PRETTYPRINT parameter has a value of "true".

Parameters:
outProps - output properties for the generated output.
Returns:
true if the output should be formatted.