| java.lang.Object |
| ↳ |
com.google.gdata.wireformats.XmlGenerator |
Class Overview
XML generator that outputs a tree of Element objects
using the XML wire format.
Summary
| Nested Classes |
|
interface |
XmlGenerator.ElementGenerator |
The ElementGenerator interface is implemented by helper classes that
will generate the start element, text content, and end element syntax
for an Element to an XmlWriter. |
|
class |
XmlGenerator.XmlElementGenerator |
The XmlElementGenerator class provides the default implementation of the
interface. |
| Public Constructors |
|
|
XmlGenerator(StreamProperties props, Writer w, Charset cs, boolean prettyPrint)
Creates a new xml generator for generating xml output.
|
|
|
XmlGenerator(StreamProperties props, Writer w, Charset cs, boolean prettyPrint, XmlNamespace defaultNamespace)
Creates a new xml generator for generating xml output, using the
given namespace as the default namespace.
|
Fields
private
static
final
XmlNamespace
USE_ROOT_ELEMENT_NAMESPACE
A namespace marker that means we should use the root element namespace
as the default namespace. This can be overridden by calling
#XmlGenerator(OutputProperties, Writer, Charset, boolean, XmlNamespace)
and giving it a different namespace.
private
final
XmlNamespace
defaultNamespace
The default namespace to use for this generator.
protected
final
ElementMetadata<?, ?>
rootMetadata
Metadata for the root element
protected
final
XmlWriter
xw
XML writer used by this generator.
Public Constructors
public
XmlGenerator
(StreamProperties props, Writer w, Charset cs, boolean prettyPrint)
Creates a new xml generator for generating xml output. This constructor
will use the namespace of the root element as the default namespace of the
output. Callers that would like to change the default namespace should
call #XmlGenerator(OutputProperties, Writer, Charset, boolean, XmlNamespace)
with the namespace that should be used as the default.
public
XmlGenerator
(StreamProperties props, Writer w, Charset cs, boolean prettyPrint, XmlNamespace defaultNamespace)
Creates a new xml generator for generating xml output, using the
given namespace as the default namespace.
Parameters
| props
| |
| w
| |
| cs
| |
| prettyPrint
| |
| defaultNamespace
| |
Public Methods
public
void
generate
(Element element)
Generate wire content for tree rooted at root.
Called during Element tree traversal to allow the visitor instance
to process an element in the tree.
Parameters
| parent
| The parent of the target element |
| e
| The target element being visited |
| metadata
| The metadata for the target element |
Returns
- boolean value indicating whether child elements (if any) should
be visited.
The visitComplete method is called when traversal for an Element
and all of its nested children has been completed.
Parameters
| parent
| The parent of the target element |
| e
| The visited element |
| metadata
| The metadata for the target element |