Top Description Fields Constructors Methods
com.sun.xml.txw2

pack-priv final Class ContainerElement

extends Object
implements InvocationHandler, TypedXmlWriter
Class Inheritance
All Implemented Interfaces
com.sun.xml.txw2.TypedXmlWriter, java.lang.reflect.InvocationHandler
Imports
com.sun.xml.txw2.annotation.XmlAttribute, .XmlElement, .XmlNamespace, .XmlValue, .XmlCDATA, javax.xml.namespace.QName, java.lang.reflect.InvocationHandler, .InvocationTargetException, .Method, .Proxy

Dynamically implements TypedXmlWriter interfaces.
Author
Kohsuke Kawaguchi

Field Summary

Modifier and TypeField and Description
private boolean
blocked

Set to true if the start eleent is blocked.

pack-priv final Document
pack-priv final EndTag
private ContainerElement
private ContainerElement
private final String
nsUri

Namespace URI of this element.

private final ContainerElement
private ContainerElement
prevOpen

Uncommitted ContainerElements form a doubly-linked list, so that the parent can close them recursively.

pack-priv StartTag
startTag

Initially, point to the start tag token, but once we know we are done with the start tag, we will reset it to null so that the token sequence can be GC-ed.

private Content
tail

When this element can accept more child content, this value is non-null and holds the last child Content.

Constructor Summary

AccessConstructor and Description
public
ContainerElement(Document document, ContainerElement parent, String nsUri, String localName)

Method Summary

Modifier and TypeMethod and Description
public void
_attribute(String localName, Object value)

Implements com.sun.xml.txw2.TypedXmlWriter._attribute.

Adds an attribute of the given name and the value.

public void
_attribute(String nsUri, String localName, Object value)

Implements com.sun.xml.txw2.TypedXmlWriter._attribute.

Adds an attribute of the given name and the value.

public void
_attribute(QName attributeName, Object value)

Implements com.sun.xml.txw2.TypedXmlWriter._attribute.

Adds an attribute of the given name and the value.

public <T extends TypedXmlWriter> T
_cast(Class<T> facadeType)

Implements com.sun.xml.txw2.TypedXmlWriter._cast.

Returns a different interface for this typed XML Writer.

public void
_cdata(Object value)

Implements com.sun.xml.txw2.TypedXmlWriter._cdata.

Appends CDATA section.

public void
_comment(Object value)

Implements com.sun.xml.txw2.TypedXmlWriter._comment.

Appends a comment.

private void
_commit(boolean includingAllPredecessors)

public <T extends TypedXmlWriter> T
_element(String localName, Class<T> contentModel)

Implements com.sun.xml.txw2.TypedXmlWriter._element.

Appends a new child element.

public <T extends TypedXmlWriter> T
_element(QName tagName, Class<T> contentModel)

Implements com.sun.xml.txw2.TypedXmlWriter._element.

Appends a new child element.

public <T extends TypedXmlWriter> T
_element(Class<T> contentModel)

Implements com.sun.xml.txw2.TypedXmlWriter._element.

Appends a new child element.

public <T extends TypedXmlWriter> T
_element(String nsUri, String localName, Class<T> contentModel)

Implements com.sun.xml.txw2.TypedXmlWriter._element.

Appends a new child element.

public void
_namespace(String uri)

Implements com.sun.xml.txw2.TypedXmlWriter._namespace.

Declares a new namespace URI on this element.

public void
_namespace(String uri, String prefix)

Implements com.sun.xml.txw2.TypedXmlWriter._namespace.

Declares a new namespace URI on this element to a specific prefix.

public void
_namespace(String uri, boolean requirePrefix)

Implements com.sun.xml.txw2.TypedXmlWriter._namespace.

Declares a new namespace URI on this element.

public void
_pcdata(Object value)

Implements com.sun.xml.txw2.TypedXmlWriter._pcdata.

Appends text data.

private void
addAttribute(XmlAttribute xa, Method method, Object[] args)

Writes an attribute.

private void
addChild(Content child)

Appends this child object to the tail.

private Object
addElement(XmlElement e, Method method, Object[] args)

Writes a new element.

public void
block()

Implements com.sun.xml.txw2.TypedXmlWriter.block.

Blocks the writing of the start tag so that new attributes can be added even after child elements are appended.

private void
public void
commit()

Implements com.sun.xml.txw2.TypedXmlWriter.commit.

Commits this element (and all its descendants) to the output.

public void
commit(boolean includingAllPredecessors)

Implements com.sun.xml.txw2.TypedXmlWriter.commit.

Commits this element (and all its descendants) to the output.

public Document
getDocument()

Implements com.sun.xml.txw2.TypedXmlWriter.getDocument.

Gets the Document object that this writer is writing to.

private String
getNamespace(Package pkg)

Decides the namespace URI of the given package.

public Object
invoke(Object proxy, Method method, Object[] args)

Implements java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result.

pack-priv boolean
private boolean
private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockedback to summary
private boolean blocked

Set to true if the start eleent is blocked.

documentback to summary
pack-priv final Document document
endTagback to summary
pack-priv final EndTag endTag
lastOpenChildback to summary
private ContainerElement lastOpenChild
nextOpenback to summary
private ContainerElement nextOpen
nsUriback to summary
private final String nsUri

Namespace URI of this element.

parentback to summary
private final ContainerElement parent
prevOpenback to summary
private ContainerElement prevOpen

Uncommitted ContainerElements form a doubly-linked list, so that the parent can close them recursively.

startTagback to summary
pack-priv StartTag startTag

Initially, point to the start tag token, but once we know we are done with the start tag, we will reset it to null so that the token sequence can be GC-ed.

tailback to summary
private Content tail

When this element can accept more child content, this value is non-null and holds the last child Content. If this element is committed, this parameter is null.

Constructor Detail

ContainerElementback to summary
public ContainerElement(Document document, ContainerElement parent, String nsUri, String localName)

Method Detail

_attributeback to summary
public void _attribute(String localName, Object value)

Implements com.sun.xml.txw2.TypedXmlWriter._attribute.

Doc from com.sun.xml.txw2.TypedXmlWriter._attribute.

Adds an attribute of the given name and the value.

Short for

_attribute("",localName,value);
Annotations
@Override
_attributeback to summary
public void _attribute(String nsUri, String localName, Object value)

Implements com.sun.xml.txw2.TypedXmlWriter._attribute.

Doc from com.sun.xml.txw2.TypedXmlWriter._attribute.

Adds an attribute of the given name and the value.

Short for

_attribute(new QName(nsUri,localName),value);
Annotations
@Override
_attributeback to summary
public void _attribute(QName attributeName, Object value)

Implements com.sun.xml.txw2.TypedXmlWriter._attribute.

Doc from com.sun.xml.txw2.TypedXmlWriter._attribute.

Adds an attribute of the given name and the value.

Annotations
@Override
_castback to summary
public <T extends TypedXmlWriter> T _cast(Class<T> facadeType)

Implements com.sun.xml.txw2.TypedXmlWriter._cast.

Doc from com.sun.xml.txw2.TypedXmlWriter._cast.

Returns a different interface for this typed XML Writer.

Semantically, this operation is a 'cast' --- it returns the same underlying writer in a different interface. The returned new writer and the current writer will write to the same element.

But this is different from Java's ordinary cast because the returned object is not always the same as the current object.

Annotations
@Override
_cdataback to summary
public void _cdata(Object value)

Implements com.sun.xml.txw2.TypedXmlWriter._cdata.

Doc from com.sun.xml.txw2.TypedXmlWriter._cdata.

Appends CDATA section.

Annotations
@Override
_commentback to summary
public void _comment(Object value) throws UnsupportedOperationException

Implements com.sun.xml.txw2.TypedXmlWriter._comment.

Doc from com.sun.xml.txw2.TypedXmlWriter._comment.

Appends a comment.

Annotations
@Override
Exceptions
UnsupportedOperationException:
if the underlying XmlSerializer does not support writing comments, this exception can be thrown.
_commitback to summary
private void _commit(boolean includingAllPredecessors)
_elementback to summary
public <T extends TypedXmlWriter> T _element(String localName, Class<T> contentModel)

Implements com.sun.xml.txw2.TypedXmlWriter._element.

Doc from com.sun.xml.txw2.TypedXmlWriter._element.

Appends a new child element.

Short for

_element(URI of this element,localName,contentModel);

The namespace URI will be inherited from the parent element.

Annotations
@Override
_elementback to summary
public <T extends TypedXmlWriter> T _element(QName tagName, Class<T> contentModel)

Implements com.sun.xml.txw2.TypedXmlWriter._element.

Doc from com.sun.xml.txw2.TypedXmlWriter._element.

Appends a new child element.

Short for

_element(tagName.getNamespaceURI(),tagName.getLocalPart(),contentModel);
Annotations
@Override
_elementback to summary
public <T extends TypedXmlWriter> T _element(Class<T> contentModel)

Implements com.sun.xml.txw2.TypedXmlWriter._element.

Doc from com.sun.xml.txw2.TypedXmlWriter._element.

Appends a new child element.

This version of the _element method requires the T class to be annotated with XmlElement annotation. The element name will be taken from there.

Annotations
@Override
_elementback to summary
public <T extends TypedXmlWriter> T _element(String nsUri, String localName, Class<T> contentModel)

Implements com.sun.xml.txw2.TypedXmlWriter._element.

Doc from com.sun.xml.txw2.TypedXmlWriter._element.

Appends a new child element.

The newly created child element is appended at the end of the children.

Annotations
@Override
_namespaceback to summary
public void _namespace(String uri)

Implements com.sun.xml.txw2.TypedXmlWriter._namespace.

Doc from com.sun.xml.txw2.TypedXmlWriter._namespace.

Declares a new namespace URI on this element.

The runtime system will assign an unique prefix for the URI.

Annotations
@Override
_namespaceback to summary
public void _namespace(String uri, String prefix)

Implements com.sun.xml.txw2.TypedXmlWriter._namespace.

Doc from com.sun.xml.txw2.TypedXmlWriter._namespace.

Declares a new namespace URI on this element to a specific prefix.

Annotations
@Override
_namespaceback to summary
public void _namespace(String uri, boolean requirePrefix)

Implements com.sun.xml.txw2.TypedXmlWriter._namespace.

Doc from com.sun.xml.txw2.TypedXmlWriter._namespace.

Declares a new namespace URI on this element.

The runtime system will assign an unique prefix for the URI.

Annotations
@Override
_pcdataback to summary
public void _pcdata(Object value)

Implements com.sun.xml.txw2.TypedXmlWriter._pcdata.

Doc from com.sun.xml.txw2.TypedXmlWriter._pcdata.

Appends text data.

Annotations
@Override
addAttributeback to summary
private void addAttribute(XmlAttribute xa, Method method, Object[] args)

Writes an attribute.

addChildback to summary
private void addChild(Content child)

Appends this child object to the tail.

addElementback to summary
private Object addElement(XmlElement e, Method method, Object[] args)

Writes a new element.

Annotations
@SuppressWarnings:unchecked
blockback to summary
public void block()

Implements com.sun.xml.txw2.TypedXmlWriter.block.

Doc from com.sun.xml.txw2.TypedXmlWriter.block.

Blocks the writing of the start tag so that new attributes can be added even after child elements are appended.

This blocks the output at the token before the start tag until the commit() method is called to _commit this element.

For more information, see the TXW documentation.

Annotations
@Override
checkStartTagback to summary
private void checkStartTag()
commitback to summary
public void commit()

Implements com.sun.xml.txw2.TypedXmlWriter.commit.

Doc from com.sun.xml.txw2.TypedXmlWriter.commit.

Commits this element (and all its descendants) to the output.

Short for _commit(true).

Annotations
@Override
commitback to summary
public void commit(boolean includingAllPredecessors)

Implements com.sun.xml.txw2.TypedXmlWriter.commit.

Doc from com.sun.xml.txw2.TypedXmlWriter.commit.

Commits this element (and all its descendants) to the output.

Once a writer is committed, nothing can be added to it further. Committing allows TXW to output a part of the document even if the rest has not yet been written.

Annotations
@Override
getDocumentback to summary
public Document getDocument()

Implements com.sun.xml.txw2.TypedXmlWriter.getDocument.

Doc from com.sun.xml.txw2.TypedXmlWriter.getDocument.

Gets the Document object that this writer is writing to.

Annotations
@Override
getNamespaceback to summary
private String getNamespace(Package pkg)

Decides the namespace URI of the given package.

invokeback to summary
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

Doc from java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.

Annotations
@Override
Exceptions
Throwable:
the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the invoked method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the invoked method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.
isBlockedback to summary
pack-priv boolean isBlocked()
isCommittedback to summary
private boolean isCommitted()
isRootback to summary
private boolean isRoot()