public interface HierarchicalStreamReader extends ErrorReporter
Modifier and Type | Method and Description |
---|---|
void |
appendErrors(ErrorWriter errorWriter)
If any errors are detected, allow the reader to add any additional information that can aid debugging
(such as line numbers, XPath expressions, etc).
|
void |
close()
Close the reader, if necessary.
|
String |
getAttribute(int index)
Get the value of an attribute of the current node, by index.
|
String |
getAttribute(String name)
Get the value of an attribute of the current node.
|
int |
getAttributeCount()
Number of attributes in current node.
|
String |
getAttributeName(int index)
Name of attribute in current node.
|
Iterator |
getAttributeNames()
Iterator with the names of the attributes.
|
String |
getNodeName()
Get the name of the current node.
|
String |
getValue()
Get the value (text content) of the current node.
|
boolean |
hasMoreChildren()
Does the node have any more children remaining that have not yet been read?
|
void |
moveDown()
Select the current child as current node.
|
void |
moveUp()
Select the parent node as current node.
|
HierarchicalStreamReader |
underlyingReader()
Return the underlying HierarchicalStreamReader implementation.
|
boolean hasMoreChildren()
void moveDown()
moveUp()
.void moveUp()
String getNodeName()
String getValue()
String getAttribute(String name)
If no such attribute exists, the method returns null.
String getAttribute(int index)
Note, the behavior of this method is dependent on the underlying parser when calling it with a non-existing index. Typically some kind of RuntimeException is thrown.
int getAttributeCount()
String getAttributeName(int index)
Note, the behavior of this method is dependent on the underlying parser when calling it with a non-existing index. Typically some kind of RuntimeException is thrown.
Iterator getAttributeNames()
Note, the iterator is only valid as long as the internal state of the underlying parser is still at the start of the current element. The behavior is undefined if the parser moved on.
void appendErrors(ErrorWriter errorWriter)
appendErrors
in interface ErrorReporter
errorWriter
- the error writervoid close()
HierarchicalStreamReader underlyingReader()
If a Converter needs to access methods of a specific HierarchicalStreamReader implementation that are not defined in the HierarchicalStreamReader interface, it should call this method before casting. This is because the reader passed to the Converter is often wrapped/decorated by another implementation to provide additional functionality (such as XPath tracking).
For example:
MySpecificReader mySpecificReader = (MySpecificReader)reader; // INCORRECT! mySpecificReader.doSomethingSpecific();
MySpecificReader mySpecificReader = (MySpecificReader)reader.underlyingReader(); // CORRECT! mySpecificReader.doSomethingSpecific();
Implementations of HierarchicalStreamReader should return 'this', unless they are a decorator, in which case they should delegate to whatever they are wrapping.
Copyright © 2004–2017 XStream. All rights reserved.