final class ContainerElement extends java.lang.Object implements java.lang.reflect.InvocationHandler, TypedXmlWriter
TypedXmlWriter
interfaces.Modifier and Type | Field and Description |
---|---|
private boolean |
blocked
Set to true if the start eleent is blocked.
|
(package private) Document |
document |
(package private) EndTag |
endTag |
private ContainerElement |
lastOpenChild |
private ContainerElement |
nextOpen |
private java.lang.String |
nsUri
Namespace URI of this element.
|
private ContainerElement |
parent |
private ContainerElement |
prevOpen
Uncommitted
ContainerElement s form a doubly-linked list,
so that the parent can close them recursively. |
(package private) 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 and Description |
---|
ContainerElement(Document document,
ContainerElement parent,
java.lang.String nsUri,
java.lang.String localName) |
Modifier and Type | Method and Description |
---|---|
void |
_attribute(javax.xml.namespace.QName attributeName,
java.lang.Object value)
Adds an attribute of the given name and the value.
|
void |
_attribute(java.lang.String localName,
java.lang.Object value)
Adds an attribute of the given name and the value.
|
void |
_attribute(java.lang.String nsUri,
java.lang.String localName,
java.lang.Object value)
Adds an attribute of the given name and the value.
|
<T extends TypedXmlWriter> |
_cast(java.lang.Class<T> facadeType)
Returns a different interface for this typed XML Writer.
|
void |
_cdata(java.lang.Object value)
Appends CDATA section.
|
void |
_comment(java.lang.Object value)
Appends a comment.
|
private void |
_commit(boolean includingAllPredecessors) |
<T extends TypedXmlWriter> |
_element(java.lang.Class<T> contentModel)
Appends a new child element.
|
<T extends TypedXmlWriter> |
_element(javax.xml.namespace.QName tagName,
java.lang.Class<T> contentModel)
Appends a new child element.
|
<T extends TypedXmlWriter> |
_element(java.lang.String localName,
java.lang.Class<T> contentModel)
Appends a new child element.
|
<T extends TypedXmlWriter> |
_element(java.lang.String nsUri,
java.lang.String localName,
java.lang.Class<T> contentModel)
Appends a new child element.
|
void |
_namespace(java.lang.String uri)
Declares a new namespace URI on this element.
|
void |
_namespace(java.lang.String uri,
boolean requirePrefix)
Declares a new namespace URI on this element.
|
void |
_namespace(java.lang.String uri,
java.lang.String prefix)
Declares a new namespace URI on this element to
a specific prefix.
|
void |
_pcdata(java.lang.Object value)
Appends text data.
|
private void |
addAttribute(XmlAttribute xa,
java.lang.reflect.Method method,
java.lang.Object[] args)
Writes an attribute.
|
private void |
addChild(Content child)
Appends this child object to the tail.
|
private java.lang.Object |
addElement(XmlElement e,
java.lang.reflect.Method method,
java.lang.Object[] args)
Writes a new element.
|
void |
block()
Blocks the writing of the start tag so that
new attributes can be added even after child
elements are appended.
|
private void |
checkStartTag() |
void |
commit()
Commits this element (and all its descendants) to the output.
|
void |
commit(boolean includingAllPredecessors)
Commits this element (and all its descendants) to the output.
|
Document |
getDocument()
Gets the
Document object that this writer is writing to. |
private java.lang.String |
getNamespace(java.lang.Package pkg)
Decides the namespace URI of the given package.
|
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args) |
(package private) boolean |
isBlocked() |
private boolean |
isCommitted() |
private boolean |
isRoot() |
final Document document
StartTag startTag
final EndTag endTag
private final java.lang.String nsUri
private Content tail
Content
.
If this element is committed, this parameter is null.private ContainerElement prevOpen
ContainerElement
s form a doubly-linked list,
so that the parent can close them recursively.private ContainerElement nextOpen
private final ContainerElement parent
private ContainerElement lastOpenChild
private boolean blocked
public ContainerElement(Document document, ContainerElement parent, java.lang.String nsUri, java.lang.String localName)
private boolean isRoot()
private boolean isCommitted()
public Document getDocument()
TypedXmlWriter
Document
object that this writer is writing to.getDocument
in interface TypedXmlWriter
boolean isBlocked()
public void block()
TypedXmlWriter
This blocks the output at the token before the start tag until
the TypedXmlWriter.commit()
method is called to _commit this element.
For more information, see the TXW documentation.
block
in interface TypedXmlWriter
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
invoke
in interface java.lang.reflect.InvocationHandler
java.lang.Throwable
private void addAttribute(XmlAttribute xa, java.lang.reflect.Method method, java.lang.Object[] args)
private void checkStartTag()
private java.lang.Object addElement(XmlElement e, java.lang.reflect.Method method, java.lang.Object[] args)
private java.lang.String getNamespace(java.lang.Package pkg)
private void addChild(Content child)
public void commit()
TypedXmlWriter
Short for _commit(true).
commit
in interface TypedXmlWriter
public void commit(boolean includingAllPredecessors)
TypedXmlWriter
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.
commit
in interface TypedXmlWriter
includingAllPredecessors
- if false, this operation will _commit this writer and all its
descendants writers. If true, in addition to those writers,
this operation will close all the writers before this writer
in the document order.private void _commit(boolean includingAllPredecessors)
public void _attribute(java.lang.String localName, java.lang.Object value)
TypedXmlWriter
Short for
_attribute("",localName,value);
_attribute
in interface TypedXmlWriter
TypedXmlWriter._attribute(String, String, Object)
public void _attribute(java.lang.String nsUri, java.lang.String localName, java.lang.Object value)
TypedXmlWriter
Short for
_attribute(new QName(nsUri,localName),value);
_attribute
in interface TypedXmlWriter
TypedXmlWriter._attribute(QName, Object)
public void _attribute(javax.xml.namespace.QName attributeName, java.lang.Object value)
TypedXmlWriter
_attribute
in interface TypedXmlWriter
attributeName
- must not be null.value
- value of the attribute.
must not be null.
See the documentation for the conversion rules.public void _namespace(java.lang.String uri)
TypedXmlWriter
The runtime system will assign an unique prefix for the URI.
_namespace
in interface TypedXmlWriter
uri
- can be empty, but must not be null.public void _namespace(java.lang.String uri, java.lang.String prefix)
TypedXmlWriter
_namespace
in interface TypedXmlWriter
uri
- can be empty, but must not be null.prefix
- If non-empty, this prefix is bound to the URI
on this element. If empty, then the runtime will still try to
use the URI as the default namespace, but it may fail to do so
because of the constraints in the XML.public void _namespace(java.lang.String uri, boolean requirePrefix)
TypedXmlWriter
The runtime system will assign an unique prefix for the URI.
_namespace
in interface TypedXmlWriter
uri
- can be empty, but must not be null.requirePrefix
- if false, this method behaves just like TypedXmlWriter._namespace(String)
.
if true, this guarantees that the URI is bound to a non empty prefix.public void _pcdata(java.lang.Object value)
TypedXmlWriter
_pcdata
in interface TypedXmlWriter
value
- must not be null.
See the documentation for the conversion rules.public void _cdata(java.lang.Object value)
TypedXmlWriter
_cdata
in interface TypedXmlWriter
value
- must not be null.
See the documentation for the conversion rules.public void _comment(java.lang.Object value) throws java.lang.UnsupportedOperationException
TypedXmlWriter
_comment
in interface TypedXmlWriter
value
- must not be null.
See the documentation for the conversion rules.java.lang.UnsupportedOperationException
- if the underlying XmlSerializer
does not support
writing comments, this exception can be thrown.public <T extends TypedXmlWriter> T _element(java.lang.String localName, java.lang.Class<T> contentModel)
TypedXmlWriter
Short for
_element(URI of this element,localName,contentModel);
The namespace URI will be inherited from the parent element.
_element
in interface TypedXmlWriter
TypedXmlWriter._element(String, String, Class)
public <T extends TypedXmlWriter> T _element(javax.xml.namespace.QName tagName, java.lang.Class<T> contentModel)
TypedXmlWriter
Short for
_element(tagName.getNamespaceURI(),tagName.getLocalPart(),contentModel);
_element
in interface TypedXmlWriter
TypedXmlWriter._element(String, String, Class)
public <T extends TypedXmlWriter> T _element(java.lang.Class<T> contentModel)
TypedXmlWriter
This version of the _element method requires the T class to be
annotated with XmlElement
annotation. The element name will be
taken from there.
_element
in interface TypedXmlWriter
TypedXmlWriter._element(String, String, Class)
public <T extends TypedXmlWriter> T _cast(java.lang.Class<T> facadeType)
TypedXmlWriter
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.
_cast
in interface TypedXmlWriter
public <T extends TypedXmlWriter> T _element(java.lang.String nsUri, java.lang.String localName, java.lang.Class<T> contentModel)
TypedXmlWriter
The newly created child element is appended at the end of the children.
_element
in interface TypedXmlWriter
nsUri
- The namespace URI of the newly created element.localName
- The local name of the newly created element.contentModel
- The typed XML writer interface used to write the children of
the new child element.TypedXmlWriter
that can be used
to write the contents of the newly created child element.