Class AbstractReader
java.lang.Object
com.thoughtworks.xstream.io.AbstractReader
- All Implemented Interfaces:
ErrorReporter, ExtendedHierarchicalStreamReader, HierarchicalStreamReader
- Direct Known Subclasses:
AbstractXmlReader
Abstract base class for all HierarchicalStreamReader implementations. Implementations of
HierarchicalStreamReader should rather be derived from this class then implementing
the interface directly.- Since:
- 1.4
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates an AbstractReader with a NameCoder that does nothing.protectedAbstractReader(NameCoder nameCoder) Creates an AbstractReader with a providedNameCoder. -
Method Summary
Modifier and TypeMethodDescriptiondecodeAttribute(String name) Decode an attribute name from the target format.decodeNode(String name) Decode a node name from the target format.protected StringencodeAttribute(String name) Encode the attribute name again into the name of the target format.protected StringencodeNode(String name) Encode the node name again into the name of the target format.Peek the name of the next child.Return the underlying HierarchicalStreamReader implementation.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HierarchicalStreamReader
appendErrors, close, getAttribute, getAttribute, getAttributeCount, getAttributeName, getAttributeNames, getNodeName, getValue, hasMoreChildren, moveDown, moveUp
-
Field Details
-
nameCoder
-
-
Constructor Details
-
AbstractReader
protected AbstractReader()Creates an AbstractReader with a NameCoder that does nothing.- Since:
- 1.4
-
AbstractReader
-
-
Method Details
-
underlyingReader
Return the underlying HierarchicalStreamReader implementation.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.
- Specified by:
underlyingReaderin interfaceHierarchicalStreamReader
-
decodeNode
-
decodeAttribute
-
encodeNode
-
encodeAttribute
-
peekNextChild
Description copied from interface:ExtendedHierarchicalStreamReaderPeek the name of the next child. In situation whereHierarchicalStreamReader.hasMoreChildren()returns true, peek the tag name of the child.- Specified by:
peekNextChildin interfaceExtendedHierarchicalStreamReader
-