APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.xml.internal.stream.writers

public final Class XMLStreamWriterImpl

extends AbstractMap<Object, Object>
implements XMLStreamWriterBase
Class Inheritance
All Implemented Interfaces
com.sun.xml.internal.stream.writers.XMLStreamWriterBase, javax.xml.stream.XMLStreamWriter
Imports
com.sun.org.apache.xerces.internal.impl.Constants, .PropertyManager, com.sun.org.apache.xerces.internal.util.NamespaceSupport, .SymbolTable, com.sun.org.apache.xerces.internal.xni.QName, com.sun.xml.internal.stream.util.ReadOnlyIterator, java.io.FileOutputStream, .IOException, .OutputStream, .OutputStreamWriter, .Writer, java.nio.charset.Charset, .CharsetEncoder, java.util.AbstractMap, .ArrayList, .HashMap, .Iterator, .List, .Map, .Objects, .Random, .Set, javax.xml.XMLConstants, javax.xml.namespace.NamespaceContext, javax.xml.stream.XMLOutputFactory, .XMLStreamConstants, .XMLStreamException, javax.xml.transform.stream.StreamResult, jdk.xml.internal.SecuritySupport

This class implements a StAX XMLStreamWriter. It extends AbstractMap in order to support a getter for implementation-specific properties. For example, you can get the underlying OutputStream by casting an instance of this class to Map and calling getProperty(OUTPUTSTREAM_PROPERTY).
Authors
Neeraj Bajaj, K.Venugopal, Santiago Pericas-Geertsen, Sunitha Reddy

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
protected class
pack-priv class
XMLStreamWriterImpl.ElementState

Maintains element state .

pack-priv class
XMLStreamWriterImpl.NamespaceContextImpl

Implementation of NamespaceContext .

Field Summary

Modifier and TypeField and Description
public static final String
public static final char
public static final char
public static final String
private final String
public static final String
public static final String
public static final String
public static final String
private List<XMLStreamWriterImpl.Attribute>
fAttributeCache

Collects attributes when the writer is in reparing mode.

pack-priv Map<String, String>
fAttrNamespace

This is used to hold the namespace for attributes which happen to have the same uri as the default namespace; It's added to avoid changing the current impl.

private XMLStreamWriterImpl.ElementStack
private CharsetEncoder
fEncoder

In some cases, this charset encoder is used to determine if a char is encodable by underlying writer.

pack-priv boolean
fEscapeCharacters

This flag can be used to turn escaping off for content.

private NamespaceSupport
private boolean
fIsRepairingNamespace

Flag for the value of repairNamespace property

private XMLStreamWriterImpl.NamespaceContextImpl
fNamespaceContext

Namespace context encapsulating user specified context and context built by the writer

private List<QName>
fNamespaceDecls

Collects namespace declarations when the writer is in reparing mode.

private OutputStream
fOutputStream

Underlying OutputStream to which fWriter writes to.

private Random
private PropertyManager
fPropertyManager

Reference to PropertyManager

private final ReadOnlyIterator<String>
private boolean
fReuse

Boolean flag to indicate, if instance can be reused

private boolean
fStartTagOpened

Flag to track if start tag is opened

private SymbolTable
private Writer
fWriter

Underlying Writer to which characters are written.

public static final String
public static final char
public static final String
public static final String
public static final String
public static final String
public static final String

Constructor Summary

AccessConstructor and Description
public
XMLStreamWriterImpl(OutputStream
Underlying stream to write the bytes to
outputStream
,
PropertyManager
Properties used by this writer
props
)

Creates a new instance of XMLStreamWriterImpl.

public
XMLStreamWriterImpl(OutputStream
Underlying stream to write the bytes
outputStream
,
String
Encoding used to convert chars into bytes
encoding
,
PropertyManager
Properties used by this writer
props
)

Creates a new instance of XMLStreamWriterImpl.

public
XMLStreamWriterImpl(Writer
Underlying writer to which chars are written
writer
,
PropertyManager
Properties used by this writer
props
)

Creates a new instance of XMLStreamWriterImpl using a Writer.

public
XMLStreamWriterImpl(StreamResult sr, String encoding, PropertyManager
Properties used by this writer
props
)

Creates a new instance of XMLStreamWriterImpl using a StreamResult.

Method Summary

Modifier and TypeMethod and Description
private void
public boolean

Returns:

boolean boolean value to indicate if this instance can be reused or not
canReuse
()

Can this instance be reused

pack-priv void
private boolean
public void
close()

Implements javax.xml.stream.XMLStreamWriter.close.

Close this XMLStreamWriter by closing underlying writer.

private void
closeStartTag()

marks close of start tag and writes the same into the writer.

public boolean
containsKey(Object key)

Overrides java.util.AbstractMap.containsKey.

Implements java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key.

private void
correctPrefix(QName attr, int type)

pack-priv void
correctPrefix(QName attr1, QName attr2)

public Set<Map.Entry<Object, Object>>
entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.

public boolean
equals(Object obj)

Overrides java.util.AbstractMap.equals.

Implements java.util.Map.equals.

Overrides the method defined in AbstractMap This is required to satisfy the contract for hashCode.

public void
flush()

Implements javax.xml.stream.XMLStreamWriter.flush.

Flush this XMLStreamWriter by flushin underlying writer.

public Object
get(Object key)

Overrides java.util.AbstractMap.get.

Implements java.util.Map.get.

Returns the value associated to an implementation-specific property.

private String
getAttrPrefix(String uri)

return the prefix if the attribute has an uri the same as that of the default namespace

public boolean
public NamespaceContext

Returns:

NamespaceContext
getNamespaceContext
()

Implements javax.xml.stream.XMLStreamWriter.getNamespaceContext.

Return NamespaceContext being used by the writer.

public String
getPrefix(String
The namespace uri
uri
)

Implements javax.xml.stream.XMLStreamWriter.getPrefix.

Return a prefix associated with specified uri, or null if the uri is unknown.

public Object

Returns:

value associated with the specified property.
getProperty
(String
Property name
str
)

Implements javax.xml.stream.XMLStreamWriter.getProperty.

Returns value associated with the specified property name.

public int
hashCode()

Overrides java.util.AbstractMap.hashCode.

Implements java.util.Map.hashCode.

Overrides the method defined in AbstractMap This is required by the toString() method

private void
init()

Initialize an instance of this XMLStreamWriter.

pack-priv boolean
private boolean
public boolean
isEmpty()

Overrides java.util.AbstractMap.isEmpty.

Implements java.util.Map.isEmpty.

Returns true if this map contains no key-value mappings.

private void
openStartTag()

marks open of start tag and writes the same into the writer.

pack-priv void
protected void
repair()

Correct's namespaces as per requirements of isReparisingNamespace property.

pack-priv void
public void
reset()

Reset this instance so that it can be re-used.

pack-priv void
reset(boolean
Indicates if properties should be read again
resetProperties
)

Reset this instance so that it can be re-used.

public void
setDefaultNamespace(String
Namespace URI
uri
)

Implements javax.xml.stream.XMLStreamWriter.setDefaultNamespace.

Set the specified URI as default namespace in the current namespace context.

public void
setEscapeCharacters(boolean escape)

public void
setNamespaceContext(NamespaceContext
the namespace context to use for this writer, may not be null
namespaceContext
)

Implements javax.xml.stream.XMLStreamWriter.setNamespaceContext.

Sets the current NamespaceContext for prefix and uri bindings.

public void
setOutput(StreamResult
StreamResult encapsulating output information
sr
,
String
Encoding to be used except when a Writer is available
encoding
)

Use a StreamResult to initialize the output for this XMLStreamWriter.

private void
setOutputUsingStream(OutputStream
Underlying OutputStream
os
,
String
Encoding used to convert chars into bytes
encoding
)

Utility method to create a writer when passed an OutputStream.

private void
public void
setPrefix(String prefix, String uri)

Implements javax.xml.stream.XMLStreamWriter.setPrefix.

Sets the prefix the uri is bound to.

public int
size()

Overrides java.util.AbstractMap.size.

Implements java.util.Map.size.

Returns the number of key-value mappings in this map.

public String
toString()

Overrides java.util.AbstractMap.toString.

Overrides the method defined in AbstractMap which is not completely implemented.

private void
verifyEncoding(String
the specified encoding
encoding
)

Verifies that the encoding is consistent between the underlying encoding and that specified.

public void
writeAttribute(String localName, String value)

Implements javax.xml.stream.XMLStreamWriter.writeAttribute.

Writes an attribute to the output stream without a prefix.

public void
writeAttribute(String namespaceURI, String localName, String value)

Implements javax.xml.stream.XMLStreamWriter.writeAttribute.

Writes an attribute to the output stream

public void
writeAttribute(String prefix, String namespaceURI, String localName, String value)

Implements javax.xml.stream.XMLStreamWriter.writeAttribute.

Writes an attribute to the output stream

private void
writeAttributeWithPrefix(String prefix, String localName, String value)

public void
writeCData(String cdata)

Implements javax.xml.stream.XMLStreamWriter.writeCData.

Writes a CData section

public void
public void
writeCharacters(char[] data, int start, int len)

Implements javax.xml.stream.XMLStreamWriter.writeCharacters.

Write text to the output

private void
writeCharRef(int codePoint)

Writes character reference in hex format.

public void
writeComment(String comment)

Implements javax.xml.stream.XMLStreamWriter.writeComment.

Writes an xml comment with the data enclosed

public void
writeDefaultNamespace(String namespaceURI)

Implements javax.xml.stream.XMLStreamWriter.writeDefaultNamespace.

Writes the default namespace to the stream

public void
writeDTD(String dtd)

Implements javax.xml.stream.XMLStreamWriter.writeDTD.

Write a DTD section.

public void
writeEmptyElement(String localName)

Implements javax.xml.stream.XMLStreamWriter.writeEmptyElement.

Writes an empty element tag to the output

public void
writeEmptyElement(String namespaceURI, String localName)

Implements javax.xml.stream.XMLStreamWriter.writeEmptyElement.

Writes an empty element tag to the output

public void
writeEmptyElement(String prefix, String localName, String namespaceURI)

Implements javax.xml.stream.XMLStreamWriter.writeEmptyElement.

Writes an empty element tag to the output

public void
writeEndDocument()

Implements javax.xml.stream.XMLStreamWriter.writeEndDocument.

Closes any start tags and writes corresponding end tags.

public void
writeEndElement()

Implements javax.xml.stream.XMLStreamWriter.writeEndElement.

Writes an end tag to the output relying on the internal state of the writer to determine the prefix and local name of the event.

public void
writeEntityRef(String refName)

Implements javax.xml.stream.XMLStreamWriter.writeEntityRef.

Writes an entity reference

public void
writeNamespace(String
Prefix to bind.
prefix
,
String
NamespaceURI to declare.
namespaceURI
)

Implements javax.xml.stream.XMLStreamWriter.writeNamespace.

Write a Namespace declaration.

private void
writenamespace(String prefix, String namespaceURI)

public void
public void
public void
public void
writeStartDocument(String
the specified version
version
)

Implements javax.xml.stream.XMLStreamWriter.writeStartDocument.

Writes the XML declaration.

public void
writeStartDocument(String
the specified encoding
encoding
,
String
the specified version
version
)

Implements javax.xml.stream.XMLStreamWriter.writeStartDocument.

Writes the XML declaration.

public void
writeStartDocument(String encoding, String version, boolean standalone, boolean standaloneSet)

Implements com.sun.xml.internal.stream.writers.XMLStreamWriterBase.writeStartDocument.

Writes the XML declaration.

public void
writeStartElement(String localName)

Implements javax.xml.stream.XMLStreamWriter.writeStartElement.

Writes a start tag to the output.

public void
writeStartElement(String namespaceURI, String localName)

Implements javax.xml.stream.XMLStreamWriter.writeStartElement.

Writes a start tag to the output

public void
writeStartElement(String prefix, String localName, String namespaceURI)

Implements javax.xml.stream.XMLStreamWriter.writeStartElement.

Writes a start tag to the output

private void
writeXMLContent(char[] content, int start, int length, boolean escapeChars)

Writes XML content to underlying writer.

private void
private void
writeXMLContent(String content, boolean escapeChars, boolean escapeDoubleQuotes)

Writes XML content to underlying writer.

Inherited from java.util.AbstractMap:
clearclonecontainsValuekeySetputputAllremovevalues