Package com.thoughtworks.xstream.io.xml
Class XppReader
- java.lang.Object
-
- com.thoughtworks.xstream.io.AbstractReader
-
- com.thoughtworks.xstream.io.xml.AbstractXmlReader
-
- com.thoughtworks.xstream.io.xml.AbstractPullReader
-
- com.thoughtworks.xstream.io.xml.XppReader
-
- All Implemented Interfaces:
ErrorReporter,ExtendedHierarchicalStreamReader,HierarchicalStreamReader
public class XppReader extends AbstractPullReader
XStream reader that pulls directly from the stream using the XmlPullParser API.
-
-
Field Summary
Fields Modifier and Type Field Description private org.xmlpull.v1.XmlPullParserparserprivate java.io.Readerreader-
Fields inherited from class com.thoughtworks.xstream.io.xml.AbstractPullReader
COMMENT, END_NODE, OTHER, START_NODE, TEXT
-
-
Constructor Summary
Constructors Constructor Description XppReader(java.io.Reader reader)Deprecated.As of 1.4, useXppReader(Reader, XmlPullParser)insteadXppReader(java.io.Reader reader, XmlFriendlyReplacer replacer)Deprecated.As of 1.4, useXppReader(Reader, XmlPullParser, NameCoder)insteadXppReader(java.io.Reader reader, org.xmlpull.v1.XmlPullParser parser)Construct an XppReader.XppReader(java.io.Reader reader, org.xmlpull.v1.XmlPullParser parser, NameCoder nameCoder)Construct an XppReader.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidappendErrors(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).voidclose()Close the reader, if necessary.protected org.xmlpull.v1.XmlPullParsercreateParser()Deprecated.As of 1.4, useXppReader(Reader, XmlPullParser)insteadjava.lang.StringgetAttribute(int index)Get the value of an attribute of the current node, by index.java.lang.StringgetAttribute(java.lang.String name)Get the value of an attribute of the current node.intgetAttributeCount()Number of attributes in current node.java.lang.StringgetAttributeName(int index)Name of attribute in current node.protected java.lang.StringpullElementName()Pull the name of the current element from the stream.protected intpullNextEvent()Pull the next event from the stream.protected java.lang.StringpullText()Pull the contents of the current text node from the stream.-
Methods inherited from class com.thoughtworks.xstream.io.xml.AbstractPullReader
getAttributeNames, getNodeName, getValue, hasMoreChildren, mark, moveDown, moveUp, peekNextChild, reset
-
Methods inherited from class com.thoughtworks.xstream.io.xml.AbstractXmlReader
escapeXmlName, unescapeXmlName
-
Methods inherited from class com.thoughtworks.xstream.io.AbstractReader
decodeAttribute, decodeNode, encodeAttribute, encodeNode, underlyingReader
-
-
-
-
Constructor Detail
-
XppReader
public XppReader(java.io.Reader reader, org.xmlpull.v1.XmlPullParser parser)Construct an XppReader.- Parameters:
reader- the reader with the input dataparser- the XPP parser to use- Since:
- 1.4
-
XppReader
public XppReader(java.io.Reader reader, org.xmlpull.v1.XmlPullParser parser, NameCoder nameCoder)Construct an XppReader.- Parameters:
reader- the reader with the input dataparser- the XPP parser to usenameCoder- the coder for XML friendly tag and attribute names- Since:
- 1.4
-
XppReader
public XppReader(java.io.Reader reader)
Deprecated.As of 1.4, useXppReader(Reader, XmlPullParser)instead
-
XppReader
public XppReader(java.io.Reader reader, XmlFriendlyReplacer replacer)Deprecated.As of 1.4, useXppReader(Reader, XmlPullParser, NameCoder)instead- Since:
- 1.2
-
-
Method Detail
-
createParser
protected org.xmlpull.v1.XmlPullParser createParser()
Deprecated.As of 1.4, useXppReader(Reader, XmlPullParser)insteadTo use another implementation of org.xmlpull.v1.XmlPullParser, override this method.
-
pullNextEvent
protected int pullNextEvent()
Description copied from class:AbstractPullReaderPull the next event from the stream.This MUST return
AbstractPullReader.START_NODE,AbstractPullReader.END_NODE,AbstractPullReader.TEXT,AbstractPullReader.COMMENT,AbstractPullReader.OTHERor throwStreamException.The underlying pull parser will most likely return its own event types. These must be mapped to the appropriate events.
- Specified by:
pullNextEventin classAbstractPullReader
-
pullElementName
protected java.lang.String pullElementName()
Description copied from class:AbstractPullReaderPull the name of the current element from the stream.- Specified by:
pullElementNamein classAbstractPullReader
-
pullText
protected java.lang.String pullText()
Description copied from class:AbstractPullReaderPull the contents of the current text node from the stream.- Specified by:
pullTextin classAbstractPullReader
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
Description copied from interface:HierarchicalStreamReaderGet the value of an attribute of the current node.If no such attribute exists, the method returns null.
-
getAttribute
public java.lang.String getAttribute(int index)
Description copied from interface:HierarchicalStreamReaderGet the value of an attribute of the current node, by 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.
-
getAttributeCount
public int getAttributeCount()
Description copied from interface:HierarchicalStreamReaderNumber of attributes in current node.
-
getAttributeName
public java.lang.String getAttributeName(int index)
Description copied from interface:HierarchicalStreamReaderName of attribute in current node.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.
-
appendErrors
public void appendErrors(ErrorWriter errorWriter)
Description copied from interface:HierarchicalStreamReaderIf any errors are detected, allow the reader to add any additional information that can aid debugging (such as line numbers, XPath expressions, etc).- Parameters:
errorWriter- the error writer
-
close
public void close()
Description copied from interface:HierarchicalStreamReaderClose the reader, if necessary.
-
-