public interface LocationInfo
Note: instances of LocationInfo are only guaranteed to persist as long
as the (stream) reader points to the current element (whatever it is).
After next call to streamReader.next
, it it possible that
the previously accessed LocationInfo points to the old information, new
information, or may even contain just garbage. That is, for each new
event, getLocationInfo
should be called separately.
Modifier and Type | Method and Description |
---|---|
XMLStreamLocation2 |
getCurrentLocation()
A method that returns the current location of the stream reader
at the input source.
|
long |
getEndingByteOffset()
Method that can be used to get exact byte offset (number of bytes
read from the stream right before getting to this location) in the
stream that is pointed to by this reader, right after the end
of the current event.
|
long |
getEndingCharOffset()
Method that can be used to get exact character offset (number of chars
read from the stream right before getting to this location) in the
stream that is pointed to by this reader, right after the end
of the current event.
|
XMLStreamLocation2 |
getEndLocation()
An optional method that either returns the location object that points the
ending position of the current event, or null if implementation
does not keep track of it (some may return only start location; and
some no location at all).
|
Location |
getLocation() |
long |
getStartingByteOffset()
Method that can be used to get exact byte offset (number of bytes
read from the stream right before getting to this location) in the
stream that is pointed to by this reader, right before the start
of the current event.
|
long |
getStartingCharOffset()
Method that can be used to get exact character offset (number of chars
read from the stream right before getting to this location) in the
stream that is pointed to by this reader, right before the start
of the current event.
|
XMLStreamLocation2 |
getStartLocation()
An optional method that either returns the location object that points the
starting position of the current event, or null if implementation
does not keep track of it (some may return only end location; and
some no location at all).
|
long getStartingByteOffset()
Note: this value MAY be the same as the one returned by
getStartingCharOffset()
, but usually only for single-byte
character streams (Ascii, ISO-Latin).
long getStartingCharOffset()
Note: this value MAY be the same as the one returned by
getStartingByteOffset()
; this is the case for single-byte
character streams (Ascii, ISO-Latin), as well as for streams for
which byte offset information is not available (Readers, Strings).
long getEndingByteOffset() throws XMLStreamException
Note: this value MAY be the same as the one returned by
getEndingCharOffset()
, but usually only for single-byte
character streams (Ascii, ISO-Latin).
Note: for lazy-loading implementations, calling this method may require the underlying stream to be advanced and contents parsed; this is why it is possible that an exception be thrown.
XMLStreamException
long getEndingCharOffset() throws XMLStreamException
Note: this value MAY be the same as the one returned by
getEndingByteOffset()
; this is the case for single-byte
character streams (Ascii, ISO-Latin), as well as for streams for
which byte offset information is not available (Readers, Strings).
Note: for lazy-loading implementations, calling this method may require the underlying stream to be advanced and contents parsed; this is why it is possible that an exception be thrown.
XMLStreamException
Location getLocation()
XMLStreamLocation2 getStartLocation()
Note: since it is assumed that the start location must either have
been collected by now, or is not accessible (i.e. implementation
[always] returns null), no exception is allowed to be throws, as
no parsing should ever need to be done (unlike with
getEndLocation()
).
XMLStreamLocation2 getCurrentLocation()
Since this location information should always be accessible, no further parsing is to be done, and no exceptions can be thrown.
XMLStreamLocation2 getEndLocation() throws XMLStreamException
Note: since some implementations may not yet know the end location (esp. ones that do lazy loading), this call may require further parsing. As a result, this method may throw a parsing or I/O errors.
XMLStreamException
- If the stream reader had to advance to
the end of the event (to find the location), it may encounter a
parsing (or I/O) error; if so, that gets thrownCopyright © 2015 fasterxml.com. All Rights Reserved.