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

public final Class Document

extends Object
Class Inheritance
Imports
com.sun.xml.txw2.output.XmlSerializer, java.util.Map, .HashMap

Coordinates the entire writing process.
Author
Kohsuke Kawaguchi ([email protected])

Field Summary

Modifier and TypeField and Description
private NamespaceDecl
activeNamespaces

Remembers the namespace declarations of the last unclosed start tag, so that we can fix up dummy prefixes in Pcdata.

private Content
current

Currently active writer.

private final Map<Class<?>, DatatypeWriter<Object>>
private final NamespaceSupport
inscopeNamespace

Used to keep track of in-scope namespace bindings declared in ancestors.

private int
iota

Used to generate unique namespace prefix.

pack-priv static final char
MAGIC

The first char of the dummy prefix.

private final XmlSerializer
private int
private final StringBuilder
private boolean
started

Set to true once we invoke XmlSerializer#startDocument().

private final ContentVisitor

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
addDatatypeWriter(DatatypeWriter<Object>
The DatatypeWriter to be added. Must not be null.
dw
)

Defines additional user object -> string conversion logic.

pack-priv char
private StringBuilder

Returns:

the buffer passed as the buf parameter.
fixPrefix
(StringBuilder buf)

Replaces dummy prefixes in the value to the real ones by using activeNamespaces.

pack-priv void
private String
newPrefix()

Allocates a new unique prefix.

pack-priv void
run()

Performs the output as much as possible

pack-priv void
pack-priv void
writeValue(Object obj, NamespaceResolver
use
nsResolver
,
StringBuilder buf)

Appends the given object to the end of the given buffer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

activeNamespacesback to summary
private NamespaceDecl activeNamespaces

Remembers the namespace declarations of the last unclosed start tag, so that we can fix up dummy prefixes in Pcdata.

currentback to summary
private Content current

Currently active writer.

This points to the last written token.

datatypeWritersback to summary
private final Map<Class<?>, DatatypeWriter<Object>> datatypeWriters
inscopeNamespaceback to summary
private final NamespaceSupport inscopeNamespace

Used to keep track of in-scope namespace bindings declared in ancestors.

iotaback to summary
private int iota

Used to generate unique namespace prefix.

MAGICback to summary
pack-priv static final char MAGIC

The first char of the dummy prefix.

outback to summary
private final XmlSerializer out
prefixIotaback to summary
private int prefixIota
prefixSeedback to summary
private final StringBuilder prefixSeed

Used by newPrefix().

startedback to summary
private boolean started

Set to true once we invoke XmlSerializer#startDocument().

This is so that we can defer the writing as much as possible.

visitorback to summary
private final ContentVisitor visitor

Constructor Detail

Documentback to summary
pack-priv Document(XmlSerializer out)

Method Detail

addDatatypeWriterback to summary
public void addDatatypeWriter(DatatypeWriter<Object> dw)

Defines additional user object -> string conversion logic.

Applications can add their own DatatypeWriter so that application-specific objects can be turned into String for output.

Parameters
dw:DatatypeWriter<Object>

The DatatypeWriter to be added. Must not be null.

assignNewIdback to summary
pack-priv char assignNewId()
fixPrefixback to summary
private StringBuilder fixPrefix(StringBuilder buf)

Replaces dummy prefixes in the value to the real ones by using activeNamespaces.

Returns:StringBuilder

the buffer passed as the buf parameter.

flushback to summary
pack-priv void flush()
newPrefixback to summary
private String newPrefix()

Allocates a new unique prefix.

runback to summary
pack-priv void run()

Performs the output as much as possible

setFirstContentback to summary
pack-priv void setFirstContent(Content c)
writeValueback to summary
pack-priv void writeValue(Object obj, NamespaceResolver nsResolver, StringBuilder buf)

Appends the given object to the end of the given buffer.

Parameters
nsResolver:NamespaceResolver

use