XmlBufferedReader
An xml reader that has a buffer that allows peeking events as well as injecting events into the stream. Note that this class does not do any validation of the xml. If injecting/removing elements into/from the buffer you can create invalid XML.
Parameters
The underlying reader to read from.
Properties
Get the amount of attributes on the current element
Get a range for the attributes in the reader
Get an array of all attributes in the current (startTag) event.
The declared encoding for the document. Unlike general parsing, this value is accessible after reading the document element. The document element must be the first non-whitespace element. The value for this property before document element presence is known is implementation defined (and may change).
Enhanced location info that allows a reader to provide more detail than just a string
Are we peeking (is the underlying buffer ahead). If true it may not be valid to inspect the state.
For an unresolved entity determine whether it is known
The current namespace context
Retrieve the namespaces declared at the current level.
Retrieve the namespace URI of the current tag
The declared standalone status for the document. Unlike general parsing, this value is accessible after reading the document element. The document element must be the first non-whitespace element. The value for this property before document element presence is known is implementation defined (and may change).
The declared xml version for the document. Unlike general parsing, this value is accessible after reading the document element. The document element must be the first non-whitespace element. The value for this property before document element presence is known is implementation defined (and may change).
Functions
Add an element to the peek buffer.
Add events to the peek buffer.
Consume all text and non-content (comment/processing instruction) to get an uninterrupted text sequence. This will skip over comments but not ignorable whitespace that starts the string, but not tags. Any tags encountered will lead to a return of this function. Any tags encountered with cause an exception to be thrown. It can either be invoked when in a start tag to return all text content, or on a content element to include it (if text or cdata) and all subsequent siblings.
Get the next text sequence in the reader. This will skip over comments and ignorable whitespace (starting the content), but not tags. Any tags encountered with cause an exception to be thrown. It can either be invoked when in a start tag to return all text content, or on a content element to include it (if text or cdata) and all subsequent siblings.
Create a new reader that only returns the current element and its descendents. Such sub-reader ensures that the user of the return value does not exceed this stream.
Remove the bottom element in the peek buffer (the one returned by peekLast)
Remove the top element in the peek buffer (the one returned by peekFirst)
Consume all text and non-content (comment/processing instruction) to get an uninterrupted text sequence. This will skip over comments and ignorable whitespace that starts the string, but not tags. Any tags encountered will lead to a return of this function. Any tags encountered with cause an exception to be thrown. It can either be invoked when in a start tag to return all text content, or on a content element to include it (if text or cdata) and all subsequent siblings.
Get the next event to add to the queue. Children can override this to customize the events that are added to the peek buffer. Normally this method is only called when the peek buffer is empty.
Differs from .siblingsToFragment in that it skips the current event.
Read the current element (and content) only into a fragment.
Get the local name for the attribute at the given index.
Get the qualified name for the attribute at the given index.
Get the namespace URI for the attribute at the given index.
Get the prefix for the attribute at the given index.
Get the value of the attribute at the given index.
Get the value of the attribute with the given name if it exists.
Get a prefix for the given namespace URI, or null if there is none.
Get the namespace for the given prefix, if any
Is the currrent element character content
Determine whether the current event of the XMLReader is an element with the given name. Note that this ignores the prefix of the name.
Check that the current state is a start element for the given name. The mPrefix is ignored.
Determine whether the current event is an end tag
Determine whether the current event in the reader is ignorable. This ignores: comments, start/end document, processing instructions, document declarations, ignorable whitespace, and text that is effectively xml whitespace.
Determine whether the given prefix is known in the reader (up to this point). This can be used for reading text that could reference a namespace prefix (e.g. when parsing XPath expressions).
Is the current element a start tag
Determine whether the current state is effective whitespace, for text it will check the text.
Peek the last element in the buffer, if it exists, otherwise null. Note that a null value does not reflect an empty stream (or end of file), only an empty buffer.
Peek the next event only (this doesn't give access to the peeked information).
Put the current element in the peek buffer. This is basically a very limited pushback
From a start tag read the text only content of the element. Comments are allowed and handled, but subtags are not allowed. This tag finishes at the end of the element.
Check that the next element is as required. null values are not checked.
Check that the next tag element is as required. null values are not checked.
Read the current event and all subsequent siblings into a compact fragment.
From a start element, skip all element content until the corresponding end element has been read. After invocation the end element has just been read (and would be returned on relevant state calls).
Skil the preamble events in the stream reader
Write all the remaining content of the reader to a CharArrayWriter. Note that this likely fails if the reader is not at the start (as the writer would fail due to an invalid XML document).
Write the current event to the writer. This will not move the reader.
