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

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

public abstract class XmlGenerator<S>
extends CharacterGenerator<S>

The XmlGenerator class is an abstract base class supporting the implementation of the OutputGenerator interface for XML content types.


Field Summary
protected static java.util.List<ContentType> XML_CONTENT_TYPES
          The base set of matching content types for XML content.
 
Constructor Summary
XmlGenerator()
           
 
Method Summary
protected static java.util.List<ContentType> createMatchingXmlList(ContentType... types)
          Creates a new matching ContentType set that contains all of the basic XML types plus an additional list of types.
 void generate(java.io.Writer w, OutputProperties outProps, S source)
          Generates content to the writer based upon the provided request/response.
abstract  void generateXml(XmlWriter w, OutputProperties outProps, S source)
          Generates the XML content to the provided XML writer instance based upon the query request/response attributes.
protected  XmlWriter getXmlWriter(java.io.Writer w, OutputProperties outProps, java.lang.String charset)
          Returns an XmlWriter configured based upon request attributes.
 
Methods inherited from class com.google.gdata.wireformats.output.CharacterGenerator
generate, getCharsetEncoding, getContentWriter, usePrettyPrint
 
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
 

Field Detail

XML_CONTENT_TYPES

protected static final java.util.List<ContentType> XML_CONTENT_TYPES
The base set of matching content types for XML content. Custom subclasses may add to this list.

Constructor Detail

XmlGenerator

public XmlGenerator()
Method Detail

getXmlWriter

protected XmlWriter getXmlWriter(java.io.Writer w,
                                 OutputProperties outProps,
                                 java.lang.String charset)
                          throws java.io.IOException
Returns an XmlWriter configured based upon request attributes.

Parameters:
w - The underlying writer to write to
outProps - output properties
charset - The writer's character encoding (determines which characters need to be escaped. Note that the writer must already be configured to use this character set. If the writer and the character set are out of sync, the generated XML may be overly escaped (not too bad) or malformed (pretty serious.)
Returns:
An XmlWriter
Throws:
java.io.IOException - If an error occurs creating the XmlWriter.

createMatchingXmlList

protected static java.util.List<ContentType> createMatchingXmlList(ContentType... types)
Creates a new matching ContentType set that contains all of the basic XML types plus an additional list of types.


generate

public void generate(java.io.Writer w,
                     OutputProperties outProps,
                     S source)
              throws java.io.IOException
Generates content to the writer based upon the provided request/response.

Specified by:
generate in class CharacterGenerator<S>
Parameters:
w - output writer.
outProps - output properties for the generated output.
source - source object for the generated output.
Throws:
java.io.IOException

generateXml

public abstract void generateXml(XmlWriter w,
                                 OutputProperties outProps,
                                 S source)
                          throws java.io.IOException
Generates the XML content to the provided XML writer instance based upon the query request/response attributes.

Throws:
java.io.IOException