Top Description Methods
com.sun.xml.txw2

public Interface TypedXmlWriter

Known Direct Subinterfaces
org.glassfish.jaxb.core.v2.schemagen.episode.Bindings, org.glassfish.jaxb.core.v2.schemagen.episode.Klass, org.glassfish.jaxb.core.v2.schemagen.episode.Package, org.glassfish.jaxb.core.v2.schemagen.episode.SchemaBindings, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ExtensionType, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Annotated, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Annotation, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Any, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Appinfo, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.AttrDecls, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.AttributeType, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ComplexContent, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ComplexExtension, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ComplexRestriction, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ComplexType, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ComplexTypeHost, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ComplexTypeModel, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ContentModelContainer, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Documentation, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Element, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.ExplicitGroup, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.FixedOrDefault, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Import, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.List, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.LocalAttribute, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.LocalElement, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.NestedParticle, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.NoFixedFacet, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Occurs, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Redefinable, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Schema, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.SchemaTop, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.SimpleContent, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.SimpleDerivation, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.SimpleExtension, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.SimpleRestriction, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.SimpleRestrictionModel, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.SimpleType, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.SimpleTypeHost, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.TopLevelAttribute, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.TopLevelElement, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.TypeDefParticle, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.TypeHost, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Union, org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Wildcard
Known Direct Implementers
com.sun.xml.txw2.ContainerElement
Imports
com.sun.xml.txw2.annotation.XmlElement, com.sun.xml.txw2.output.XmlSerializer, javax.xml.namespace.QName

Defines common operations for all typed XML writers. Root of all typed XML writer interfaces.

This interface defines a series of methods to allow client applications to write arbitrary well-formed documents.

Author
Kohsuke Kawaguchi

Method Summary

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

Adds an attribute of the given name and the value.

public void
_attribute(String
the namespace URI
nsUri
,
String
the name
localName
,
Object
the value
value
)

Adds an attribute of the given name and the value.

public void
_attribute(QName
must not be null.
attributeName
,
Object
value of the attribute. must not be null. See the documentation for the conversion rules.
value
)

Adds an attribute of the given name and the value.

public <
type
T extends TypedXmlWriter
>
T

Returns:

always return non-null.
_cast
(Class<T>
target interface
targetInterface
)

Returns a different interface for this typed XML Writer.

public void
_cdata(Object
must not be null. See the documentation for the conversion rules.
value
)

Appends CDATA section.

public void
_comment(Object
must not be null. See the documentation for the conversion rules.
value
)

Appends a comment.

public <
type
T extends TypedXmlWriter
>
T

Returns:

always return non-null that can be used to write the contents of the newly created child element.
_element
(String
The local name of the newly created element.
localName
,
Class<T>
The typed XML writer interface used to write the children of the new child element.
contentModel
)

Appends a new child element.

public <
type
T extends TypedXmlWriter
>
T

Returns:

always return non-null that can be used to write the contents of the newly created child element.
_element
(String
The namespace URI of the newly created element.
nsUri
,
String
The local name of the newly created element.
localName
,
Class<T>
The typed XML writer interface used to write the children of the new child element.
contentModel
)

Appends a new child element.

public <
type
T extends TypedXmlWriter
>
T

Returns:

always return non-null that can be used to write the contents of the newly created child element.
_element
(QName
The local name of the newly created element.
tagName
,
Class<T>
The typed XML writer interface used to write the children of the new child element.
contentModel
)

Appends a new child element.

public <
type
T extends TypedXmlWriter
>
T

Returns:

always return non-null that can be used to write the contents of the newly created child element.
_element
(Class<T>
The typed XML writer interface used to write the children of the new child element.
contentModel
)

Appends a new child element.

public void
_namespace(String
can be empty, but must not be null.
uri
)

Declares a new namespace URI on this element.

public void
_namespace(String
can be empty, but must not be null.
uri
,
String
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.
prefix
)

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

public void
_namespace(String
can be empty, but must not be null.
uri
,
boolean
if false, this method behaves just like _namespace(String). if true, this guarantees that the URI is bound to a non empty prefix.
requirePrefix
)

Declares a new namespace URI on this element.

public void
_pcdata(Object
must not be null. See the documentation for the conversion rules.
value
)

Appends text data.

public void
block()

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

public void
commit()

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

public void
commit(boolean
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.
includingAllPredecessors
)

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

public Document

Returns:

always non-null.
getDocument
()

Gets the Document object that this writer is writing to.

Method Detail

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

Adds an attribute of the given name and the value.

Short for

_attribute("",localName,value);
Parameters
localName:String

the name

value:Object

the value

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

Adds an attribute of the given name and the value.

Short for

_attribute(new QName(nsUri,localName),value);
Parameters
nsUri:String

the namespace URI

localName:String

the name

value:Object

the value

See Also
_attribute(QName, Object)
_attributeback to summary
public void _attribute(QName attributeName, Object value)

Adds an attribute of the given name and the value.

Parameters
attributeName:QName

must not be null.

value:Object

value of the attribute. must not be null. See the documentation for the conversion rules.

_castback to summary
public <T extends TypedXmlWriter> T _cast(Class<T> targetInterface)

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.

Parameters
<T>
type
targetInterface:Class<T>

target interface

Returns:T

always return non-null.

_cdataback to summary
public void _cdata(Object value)

Appends CDATA section.

Parameters
value:Object

must not be null. See the documentation for the conversion rules.

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

Appends a comment.

Parameters
value:Object

must not be null. See the documentation for the conversion rules.

Exceptions
UnsupportedOperationException:
if the underlying XmlSerializer does not support writing comments, this exception can be thrown.
_elementback to summary
public <T extends TypedXmlWriter> T _element(String localName, Class<T> contentModel)

Appends a new child element.

Short for

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

The namespace URI will be inherited from the parent element.

Parameters
<T>
type
localName:String

The local name of the newly created element.

contentModel:Class<T>

The typed XML writer interface used to write the children of the new child element.

Returns:T

always return non-null that can be used to write the contents of the newly created child element.

See Also
_element(String, String, Class)
_elementback to summary
public <T extends TypedXmlWriter> T _element(String nsUri, String localName, Class<T> contentModel)

Appends a new child element.

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

Parameters
<T>
type
nsUri:String

The namespace URI of the newly created element.

localName:String

The local name of the newly created element.

contentModel:Class<T>

The typed XML writer interface used to write the children of the new child element.

Returns:T

always return non-null that can be used to write the contents of the newly created child element.

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

Appends a new child element.

Short for

_element(tagName.getNamespaceURI(),tagName.getLocalPart(),contentModel);
Parameters
<T>
type
tagName:QName

The local name of the newly created element.

contentModel:Class<T>

The typed XML writer interface used to write the children of the new child element.

Returns:T

always return non-null that can be used to write the contents of the newly created child element.

See Also
_element(String, String, Class)
_elementback to summary
public <T extends TypedXmlWriter> T _element(Class<T> contentModel)

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.

Parameters
<T>
type
contentModel:Class<T>

The typed XML writer interface used to write the children of the new child element.

Returns:T

always return non-null that can be used to write the contents of the newly created child element.

See Also
_element(String, String, Class)
_namespaceback to summary
public void _namespace(String uri)

Declares a new namespace URI on this element.

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

Parameters
uri:String

can be empty, but must not be null.

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

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

Parameters
uri:String

can be empty, but must not be null.

prefix:String

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.

Exceptions
IllegalArgumentException:
if the same prefix is already declared on this element.
_namespaceback to summary
public void _namespace(String uri, boolean requirePrefix)

Declares a new namespace URI on this element.

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

Parameters
uri:String

can be empty, but must not be null.

requirePrefix:boolean

if false, this method behaves just like _namespace(String). if true, this guarantees that the URI is bound to a non empty prefix.

_pcdataback to summary
public void _pcdata(Object value)

Appends text data.

Parameters
value:Object

must not be null. See the documentation for the conversion rules.

blockback to summary
public void 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.

commitback to summary
public void commit()

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

Short for _commit(true).

commitback to summary
public void commit(boolean includingAllPredecessors)

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.

Parameters
includingAllPredecessors:boolean

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.

getDocumentback to summary
public Document getDocument()

Gets the Document object that this writer is writing to.

Returns:Document

always non-null.