com.google.gdata.wireformats
Class XmlGenerator.XmlElementGenerator

java.lang.Object
  extended by com.google.gdata.wireformats.XmlGenerator.XmlElementGenerator
All Implemented Interfaces:
XmlGenerator.ElementGenerator
Enclosing class:
XmlGenerator

public static class XmlGenerator.XmlElementGenerator
extends java.lang.Object
implements XmlGenerator.ElementGenerator

The XmlElementGenerator class provides the default implementation of the interface. It will generate start and end elements based directly on the element metadata, attributes, and value.


Constructor Summary
XmlGenerator.XmlElementGenerator()
           
 
Method Summary
 void endElement(XmlWriter xw, Element e, ElementMetadata<?,?> metadata)
          End an element, writing a close tag if needed.
protected  java.util.List<XmlWriter.Attribute> getAttributes(Element e, ElementMetadata<?,?> metadata)
          Get a list of attributes for the given element.
protected  QName getName(Element e, ElementMetadata<?,?> metadata)
          Returns the QName of an element, possibly using the given metadata for the name if it is not null.
protected  java.util.Collection<XmlNamespace> getNamespaces(Element parent, Element e, ElementMetadata<?,?> metadata)
          Get a collection of namespaces for the current element and parent.
 boolean startElement(XmlWriter xw, Element parent, Element e, ElementMetadata<?,?> metadata)
          Start an element.
 void textContent(XmlWriter xw, Element e, ElementMetadata<?,?> metadata)
          Write the text content for an element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlGenerator.XmlElementGenerator

public XmlGenerator.XmlElementGenerator()
Method Detail

startElement

public boolean startElement(XmlWriter xw,
                            Element parent,
                            Element e,
                            ElementMetadata<?,?> metadata)
                     throws java.io.IOException
Description copied from interface: XmlGenerator.ElementGenerator
Start an element. If an ElementGenerator instances writes a full element tag, it should return false to indicate that textContent and child elements should not be added.

Specified by:
startElement in interface XmlGenerator.ElementGenerator
Parameters:
xw - the xml writer to write to.
parent - the parent element.
e - the element to start.
metadata - the metadata for the element
Returns:
true if child elements should be written, false if the element was fully written.
Throws:
java.io.IOException - if an error occurs while writing to the writer.

getName

protected QName getName(Element e,
                        ElementMetadata<?,?> metadata)
Returns the QName of an element, possibly using the given metadata for the name if it is not null.


getNamespaces

protected java.util.Collection<XmlNamespace> getNamespaces(Element parent,
                                                           Element e,
                                                           ElementMetadata<?,?> metadata)
Get a collection of namespaces for the current element and parent. This will only return namespaces for the root element, because we bubble all namespaces up to the root for wire efficiency.


getAttributes

protected java.util.List<XmlWriter.Attribute> getAttributes(Element e,
                                                            ElementMetadata<?,?> metadata)
Get a list of attributes for the given element.


textContent

public void textContent(XmlWriter xw,
                        Element e,
                        ElementMetadata<?,?> metadata)
                 throws java.io.IOException
Description copied from interface: XmlGenerator.ElementGenerator
Write the text content for an element.

Specified by:
textContent in interface XmlGenerator.ElementGenerator
Throws:
java.io.IOException

endElement

public void endElement(XmlWriter xw,
                       Element e,
                       ElementMetadata<?,?> metadata)
                throws java.io.IOException
Description copied from interface: XmlGenerator.ElementGenerator
End an element, writing a close tag if needed.

Specified by:
endElement in interface XmlGenerator.ElementGenerator
Throws:
java.io.IOException