public abstract class XMLStreamBuffer extends Object
A XMLStreamBuffer is an abstract class. It is immutable with respect to the methods on the class, which are non-modifying in terms of state.
A XMLStreamBuffer can be processed using specific SAX and StAX-based processors. Utility methods on XMLStreamBuffer are provided for such functionality that utilize SAX and StAX-based processors. The same instance of a XMLStreamBuffer may be processed multiple times and concurrently by more than one processor.
There are two concrete implementations of XMLStreamBuffer.
The first, MutableXMLStreamBuffer
, can be instantiated for the creation
of a buffer using SAX and StAX-based creators, and from which may be
processed as an XMLStreamBuffer. The second,
XMLStreamBufferMark
, can be instantiated to mark into an existing
buffer that is being created or processed. This allows a subtree of
XMLStreamBuffer
to be treated as its own XMLStreamBuffer
.
A XMLStreamBuffer can represent a complete XML infoset or a subtree of an XML infoset. It is also capable of representing a "forest", where the buffer represents multiple adjacent XML elements, although in this mode there are restrictions about how you can consume such forest, because not all XML APIs handle forests very well.
Modifier and Type | Field and Description |
---|---|
protected com.sun.xml.stream.buffer.FragmentedArray<char[]> |
_contentCharactersBuffer
Fragmented array to hold content information in a shared char[]
|
protected int |
_contentCharactersBufferPtr |
protected com.sun.xml.stream.buffer.FragmentedArray<Object[]> |
_contentObjects
Fragmented array to hold content information as objects
|
protected int |
_contentObjectsPtr |
protected boolean |
_hasInternedStrings
True if the buffer was created from a parser that interns Strings
as specified by the SAX interning features
|
protected Map<String,String> |
_inscopeNamespaces
In scope namespaces on a fragment
|
protected com.sun.xml.stream.buffer.FragmentedArray<byte[]> |
_structure
Fragmented array to hold structural information
|
protected int |
_structurePtr |
protected com.sun.xml.stream.buffer.FragmentedArray<String[]> |
_structureStrings
Fragmented array to hold structural information as strings
|
protected int |
_structureStringsPtr |
protected String |
systemId
The system identifier associated with the buffer
|
protected int |
treeCount
Number of trees in this stream buffer.
|
Constructor and Description |
---|
XMLStreamBuffer() |
Modifier and Type | Method and Description |
---|---|
static XMLStreamBuffer |
createNewBufferFromXMLReader(XMLReader reader,
InputStream in)
Create a new buffer from a
XMLReader and InputStream . |
static XMLStreamBuffer |
createNewBufferFromXMLReader(XMLReader reader,
InputStream in,
String systemId)
Create a new buffer from a
XMLReader and InputStream . |
static XMLStreamBuffer |
createNewBufferFromXMLStreamReader(javax.xml.stream.XMLStreamReader reader)
Create a new buffer from a XMLStreamReader.
|
protected com.sun.xml.stream.buffer.FragmentedArray<char[]> |
getContentCharactersBuffer() |
protected int |
getContentCharactersBufferPtr() |
protected com.sun.xml.stream.buffer.FragmentedArray<Object[]> |
getContentObjects() |
protected int |
getContentObjectsPtr() |
Map<String,String> |
getInscopeNamespaces()
Get the in-scope namespaces.
|
protected com.sun.xml.stream.buffer.FragmentedArray<byte[]> |
getStructure() |
protected int |
getStructurePtr() |
protected com.sun.xml.stream.buffer.FragmentedArray<String[]> |
getStructureStrings() |
protected int |
getStructureStringsPtr() |
String |
getSystemId()
Get the system identifier associated with the buffer.
|
boolean |
hasInternedStrings()
Has the buffer been created using Strings that have been interned
for certain properties of information items.
|
boolean |
isCreated()
Is the buffer created by creator.
|
boolean |
isElementFragment()
Is the buffer a representation of a fragment of an XML infoset
that is an element (and its contents).
|
boolean |
isForest()
Returns ture if this buffer represents a forest, which is
are more than one adjacent XML elements.
|
boolean |
isFragment()
Is the buffer a representation of a fragment of an XML infoset.
|
SAXBufferProcessor |
readAsXMLReader()
Deprecated.
|
SAXBufferProcessor |
readAsXMLReader(boolean produceFragmentEvent)
Reads the contents of the buffer from a
XMLReader . |
StreamReaderBufferProcessor |
readAsXMLStreamReader()
Read the contents of the buffer as a
XMLStreamReader . |
void |
writeTo(ContentHandler handler)
Deprecated.
|
void |
writeTo(ContentHandler handler,
boolean produceFragmentEvent)
Write the contents of the buffer to a
ContentHandler . |
void |
writeTo(ContentHandler handler,
ErrorHandler errorHandler) |
void |
writeTo(ContentHandler handler,
ErrorHandler errorHandler,
boolean produceFragmentEvent)
Write the contents of the buffer to a
ContentHandler with errors
report to a ErrorHandler . |
Node |
writeTo(Node n)
Writes out the contents of this buffer as DOM node and append that to the given node.
|
void |
writeToXMLStreamWriter(javax.xml.stream.XMLStreamWriter writer)
Deprecated.
|
void |
writeToXMLStreamWriter(javax.xml.stream.XMLStreamWriter writer,
boolean writeAsFragment)
Write the contents of the buffer to an XMLStreamWriter.
|
protected Map<String,String> _inscopeNamespaces
protected boolean _hasInternedStrings
protected com.sun.xml.stream.buffer.FragmentedArray<byte[]> _structure
protected int _structurePtr
protected com.sun.xml.stream.buffer.FragmentedArray<String[]> _structureStrings
protected int _structureStringsPtr
protected com.sun.xml.stream.buffer.FragmentedArray<char[]> _contentCharactersBuffer
protected int _contentCharactersBufferPtr
protected com.sun.xml.stream.buffer.FragmentedArray<Object[]> _contentObjects
protected int _contentObjectsPtr
protected int treeCount
1 if there's only one, which is the normal case. When the buffer holds a forest, this value is greater than 1. If the buffer is empty, then 0.
Notice that we cannot infer this value by looking at the FragmentedArray
s,
because this XMLStreamBuffer
maybe a view of a portion of another bigger
XMLStreamBuffer
.
protected String systemId
public final boolean isCreated()
true
if the buffer has been created.public final boolean isFragment()
true
if the buffer is a representation of a fragment
of an XML infoset.public final boolean isElementFragment()
true
if the buffer a representation
of a fragment of an XML infoset that is an element (and its contents).public final boolean isForest()
public final String getSystemId()
public final Map<String,String> getInscopeNamespaces()
The in-scope namespaces will be empty if the buffer is not a
fragment (isFragment()
returns false
).
The in-scope namespace will correspond to the in-scope namespaces of the
fragment if the buffer is a fragment (isFragment()
returns false
). The in-scope namespaces will include any
namespace delcarations on an element if the fragment correspond to that
of an element (isElementFragment()
returns false
).
public final boolean hasInternedStrings()
An buffer may have been created, for example, from an XML document parsed using the Xerces SAX parser. The Xerces SAX parser will have interned certain Strings according to the SAX string interning property. This method enables processors to avoid the duplication of String interning if such a feature is required by a procesing application and the buffer being processed was created using Strings that have been interned.
true
if the buffer has been created using Strings that
have been interned.public final StreamReaderBufferProcessor readAsXMLStreamReader() throws javax.xml.stream.XMLStreamException
XMLStreamReader
.StreamReaderBufferProcessor
. Always non-null.javax.xml.stream.XMLStreamException
public final void writeToXMLStreamWriter(javax.xml.stream.XMLStreamWriter writer, boolean writeAsFragment) throws javax.xml.stream.XMLStreamException
The XMLStreamBuffer will be written out to the XMLStreamWriter using
an instance of StreamWriterBufferProcessor
.
writer
- A XMLStreamWriter to write to.writeAsFragment
- If true, XMLStreamWriter
will not receive XMLStreamWriter.writeStartDocument()
nor XMLStreamWriter.writeEndDocument()
. This is desirable behavior when
you are writing the contents of a buffer into a bigger document.javax.xml.stream.XMLStreamException
public final void writeToXMLStreamWriter(javax.xml.stream.XMLStreamWriter writer) throws javax.xml.stream.XMLStreamException
writeToXMLStreamWriter(XMLStreamWriter, boolean)
public final SAXBufferProcessor readAsXMLReader()
readAsXMLReader(boolean)
XMLReader
.SAXBufferProcessor
.public final SAXBufferProcessor readAsXMLReader(boolean produceFragmentEvent)
XMLReader
.produceFragmentEvent
- True to generate fragment SAX events without start/endDocument.
False to generate a full document SAX events.SAXBufferProcessor
.public final void writeTo(ContentHandler handler, boolean produceFragmentEvent) throws SAXException
ContentHandler
.
If the handler
is also an instance of other SAX-based
handlers, such as LexicalHandler
, than corresponding SAX events
will be reported to those handlers.
handler
- The ContentHandler to receive SAX events.produceFragmentEvent
- True to generate fragment SAX events without start/endDocument.
False to generate a full document SAX events.SAXException
- if a parsing fails, or if ContentHandler
throws a SAXException
.public final void writeTo(ContentHandler handler) throws SAXException
writeTo(ContentHandler,boolean)
SAXException
public final void writeTo(ContentHandler handler, ErrorHandler errorHandler, boolean produceFragmentEvent) throws SAXException
ContentHandler
with errors
report to a ErrorHandler
.
If the handler
is also an instance of other SAX-based
handlers, such as LexicalHandler
, than corresponding SAX events
will be reported to those handlers.
handler
- The ContentHandler to receive SAX events.errorHandler
- The ErrorHandler to receive error events.SAXException
- if a parsing fails and ErrorHandler
throws a SAXException
,
or if ContentHandler
throws a SAXException
.public final void writeTo(ContentHandler handler, ErrorHandler errorHandler) throws SAXException
SAXException
public final Node writeTo(Node n) throws XMLStreamBufferException
XMLStreamBufferException
public static XMLStreamBuffer createNewBufferFromXMLStreamReader(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
reader
- A XMLStreamReader to read from to create.javax.xml.stream.XMLStreamException
MutableXMLStreamBuffer.createFromXMLStreamReader(XMLStreamReader)
public static XMLStreamBuffer createNewBufferFromXMLReader(XMLReader reader, InputStream in) throws SAXException, IOException
XMLReader
and InputStream
.reader
- The XMLReader
to use for parsing.in
- The InputStream
to be parsed.SAXException
IOException
MutableXMLStreamBuffer.createFromXMLReader(XMLReader, InputStream)
public static XMLStreamBuffer createNewBufferFromXMLReader(XMLReader reader, InputStream in, String systemId) throws SAXException, IOException
XMLReader
and InputStream
.reader
- The XMLReader
to use for parsing.in
- The InputStream
to be parsed.systemId
- The system ID of the input stream.SAXException
IOException
MutableXMLStreamBuffer.createFromXMLReader(XMLReader, InputStream, String)
protected final com.sun.xml.stream.buffer.FragmentedArray<byte[]> getStructure()
protected final int getStructurePtr()
protected final com.sun.xml.stream.buffer.FragmentedArray<String[]> getStructureStrings()
protected final int getStructureStringsPtr()
protected final com.sun.xml.stream.buffer.FragmentedArray<char[]> getContentCharactersBuffer()
protected final int getContentCharactersBufferPtr()
protected final com.sun.xml.stream.buffer.FragmentedArray<Object[]> getContentObjects()
protected final int getContentObjectsPtr()
Copyright © 2006-2015. All Rights Reserved.