XmlTokenSource Interface

com.bea.xml
XmlTokenSource Interface

public interface XmlTokenSource

Represents a holder of XML that can return an XmlCursor or copy itself to various media such as Writer or File. Both XmlObject (and thus all XML Beans) and XmlCursor are XmlTokenSource implementations.

Related Topics

XmlObject
XmlCursor


All Known Implementing Classes
FilterXmlObject
All Known Subinterfaces

SimpleValue, XmlAnySimpleType, XmlAnyURI, XmlBase64Binary, XmlBoolean, XmlByte, XmlCursor, XmlDate, XmlDateTime, XmlDecimal, XmlDouble, XmlDuration, XmlENTITIES, XmlENTITY, XmlFloat, XmlGDay, XmlGMonth, XmlGMonthDay, XmlGYear, XmlGYearMonth, XmlHexBinary, XmlID, XmlIDREF, XmlIDREFS, XmlInt, XmlInteger, XmlLanguage, XmlLong, XmlName, XmlNCName, XmlNegativeInteger, XmlNMTOKEN, XmlNMTOKENS, XmlNonNegativeInteger, XmlNonPositiveInteger, XmlNormalizedString, XmlNOTATION, XmlObject, XmlPositiveInteger, XmlQName, XmlShort, XmlString, XmlTime, XmlToken, XmlUnsignedByte, XmlUnsignedInt, XmlUnsignedLong, XmlUnsignedShort

Method Summary

public XmlDocumentProperties
documentProperties()
Returns the XmlDocumentProperties object for the document this token source is associated with.
public Object
monitor()
Returns the synchronization object for the document.
public XmlCursor
newCursor()
Returns a new XML cursor.
public Node
newDomNode()
Returns a W3C DOM Node containing the XML represented by this source.
public Node
newDomNode(XmlOptions options)
Just like newDomNode() but with options.
public InputStream
newInputStream()
Returns a new stream containing standard XML text, encoded according to the given encoding.
public InputStream
newInputStream(XmlOptions options)
Just like newInputStream(String encoding) but with options.
public Reader
newReader()
Returns a new character reader containing XML text.
public Reader
newReader(XmlOptions options)
Just like newReader() but with options.
public XMLInputStream
newXMLInputStream()
Returns a new XmlInputStream.
public XMLInputStream
newXMLInputStream(XmlOptions options)

Just like newXMLInputStream() but with any of a number of options.

public void
save(ContentHandler ch, LexicalHandler lh)
Writes the XML represented by this source to the given SAX content and lexical handlers.
public void
save(File file)
Writes the XML represented by this source to the given File.
public void
save(OutputStream os)
Writes the XML represented by this source to the given output stream.
public void
save(Writer w)
Writes the XML represented by this source to the given writer.
public void
save(ContentHandler ch, LexicalHandler lh, XmlOptions options)
Writes the XML represented by this source to the given SAX content and lexical handlers.
public void
save(File file, XmlOptions options)
Writes the XML represented by this source to the given File.
public void
save(OutputStream os, XmlOptions options)
Writes the XML represented by this source to the given output stream.
public void
save(Writer w, XmlOptions options)
Writes the XML represented by this source to the given writer.
public String
xmlText()
Returns standard XML text.
public String
xmlText(XmlOptions options)
Just like xmlText() but with options.

Method Detail

documentProperties() Method

public XmlDocumentProperties documentProperties()
Returns the XmlDocumentProperties object for the document this token source is associated with.


monitor() Method

public Object monitor()
Returns the synchronization object for the document. If concurrent multithreaded access to a document is required, the access should should be protected by synchronizing on this monitor() object. There is one monitor per XML document tree.


newCursor() Method

public XmlCursor newCursor()
Returns a new XML cursor. A cursor provides random access to all the tokens in the XML data, plus the ability to extract strongly-typed XmlObjects for the data. If the data is not read-only, the XML cursor also allows modifications to the data. Using a cursor for the first time typically forces the XML document into memory.


newDomNode() Method

public Node newDomNode()
Returns a W3C DOM Node containing the XML represented by this source. This is a copy of the XML, it is not a live with the underlying store of this token source. If this is the document node, then a Document is returned, else a DocumentFragment is returned.


newDomNode(XmlOptions) Method

public Node newDomNode(XmlOptions options)
Just like newDomNode() but with options. Options map may be null.

Related Topics

XmlOptions


newInputStream() Method

public InputStream newInputStream()
Returns a new stream containing standard XML text, encoded according to the given encoding. The byte stream contains contents starting at the current begin-tag or begin-document and ending at the matching end-tag or end-document. The specified encoding is used and also emitted in a PI at the beginning of the stream. This is a fail-fast stream, so if the underlying data is changed while the stream is being read, the stream throws a ConcurrentModificationException. Throws an IllegalStateException if the XmlTokenSource is not positioned at begin-tag or begin-document (e.g., if it is at an attribute).


newInputStream(XmlOptions) Method

public InputStream newInputStream(XmlOptions options)
Just like newInputStream(String encoding) but with options. Options map may be null.

Related Topics

XmlOptions


newReader() Method

public Reader newReader()
Returns a new character reader containing XML text. The contents of the reader represents the document contents starting at the current begin-tag or begin-document and ending at the matching end-tag or end-document. No encoding annotation will be made in the text itself. This is a fail-fast reader, so if the underlying data is changed while the reader is being read, the reader throws a ConcurrentModificationException. Throws an IllegalStateException if the XmlTokenSource is not positioned at begin-tag or begin-document (e.g., if it is at an attribute).


newReader(XmlOptions) Method

public Reader newReader(XmlOptions options)
Just like newReader() but with options. Options map may be null.

Related Topics

XmlOptions


newXMLInputStream() Method

DEPRECATED Superceded by JSR 173

public XMLInputStream newXMLInputStream()
Returns a new XmlInputStream. The stream starts at the current begin-tag or begin-document position and ends at the matching end-tag or end-document. This is a fail-fast stream, so if the underlying data is changed while the stream is being read, the stream throws a ConcurrentModificationException. Throws an IllegalStateException if the XmlTokenSource is not positioned at begin-tag or begin-document (e.g., if it is at an attribute).


newXMLInputStream(XmlOptions) Method

DEPRECATED Superceded by JSR 173

public XMLInputStream newXMLInputStream(XmlOptions options)

Just like newXMLInputStream() but with any of a number of options. Use the options parameter to specify the following:

To specify thisUse this method
The character encoding to use when converting the character data in the XML to bytess. XmlOptions.setCharacterEncoding(String)
Prefix-to-namespace mappings that should be assumed when saving this XML. This is useful when the resulting XML will be part of a larger XML document, ensuring that this inner document will take advantage of namespaces defined in the outer document. XmlOptions.setSaveImplicitNamespaces(Map)
Suggested namespace prefixes to use when saving. Used only when a namespace attribute needs to be synthesized. XmlOptions.setSaveSuggestedPrefixes(Map)
That namespace attributes should occur first in elements when the XML is saved. By default, they occur last. XmlOptions.setSaveNamespacesFirst()
The XML should be pretty printed when saved. Note that this should only be used for debugging. XmlOptions.setSavePrettyPrint()
The number of spaces to use when indenting for pretty printing. The default is 2. XmlOptions.setSavePrettyPrintIndent(int)
The additional number of spaces indented from the left for pretty printed XML. XmlOptions.setSavePrettyPrintOffset(int)
To minimize the number of namespace attributes generated for the saved XML. Note that this can reduce performance significantly. XmlOptions.setSaveAggresiveNamespaces()
To reduce the size of the saved document by allowing the use of the default namespace. Note that this can potentially change the semantic meaning of the XML if unprefixed QNames are present as the value of an attribute or element. XmlOptions.setUseDefaultNamespace()
To filter out processing instructions with the specified target name. XmlOptions.setSaveFilterProcinst(String)
Change the QName of the synthesized root element when saving. This replaces "xml-fragment" with "fragment" in the namespace http://www.openuri.org/fragment XmlOptions.setSaveUseOpenFrag()
Saving should begin on the element's contents. XmlOptions.setSaveInner()
Saving should begin on the element, rather than its contents. XmlOptions.setSaveOuter()
To rename the document element, or to specify the document element for this XML. XmlOptions.setSaveSyntheticDocumentElement(QName)

Parameters

options
Any of the described options.

Returns

A new validating XMLInputStream.

Related Topics

XmlOptions


save(ContentHandler, LexicalHandler) Method

public void save(ContentHandler ch, 
                 LexicalHandler lh)
throws SAXException
Writes the XML represented by this source to the given SAX content and lexical handlers.

Exceptions

SAXException

save(File) Method

public void save(File file)
throws IOException
Writes the XML represented by this source to the given File.

Exceptions

IOException

save(OutputStream) Method

public void save(OutputStream os)
throws IOException
Writes the XML represented by this source to the given output stream.

Exceptions

IOException

save(Writer) Method

public void save(Writer w)
throws IOException
Writes the XML represented by this source to the given writer.

Exceptions

IOException

save(ContentHandler, LexicalHandler, XmlOptions) Method

public void save(ContentHandler ch, 
                 LexicalHandler lh, 
                 XmlOptions options)
throws SAXException
Writes the XML represented by this source to the given SAX content and lexical handlers.

Exceptions

SAXException

save(File, XmlOptions) Method

public void save(File file, 
                 XmlOptions options)
throws IOException
Writes the XML represented by this source to the given File.

Exceptions

IOException

save(OutputStream, XmlOptions) Method

public void save(OutputStream os, 
                 XmlOptions options)
throws IOException
Writes the XML represented by this source to the given output stream.

Exceptions

IOException

save(Writer, XmlOptions) Method

public void save(Writer w, 
                 XmlOptions options)
throws IOException
Writes the XML represented by this source to the given writer.

Exceptions

IOException

xmlText() Method

public String xmlText()
Returns standard XML text. The text returned represents the document contents starting at the current begin-tag or begin-document and ending at the matching end-tag or end-document. This is same content as newReader, but it is returned as a single string. Throws an IllegalStateException if the XmlTokenSource is not positioned at begin-tag or begin-document (e.g., if it is at an attribute).


xmlText(XmlOptions) Method

public String xmlText(XmlOptions options)
Just like xmlText() but with options. Options map may be null.

Related Topics

XmlOptions