|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.android.utils.PositionXmlParser
public class PositionXmlParser
A simple DOM XML parser which can retrieve exact beginning and end offsets (and line and column numbers) for element nodes as well as attribute nodes.
Nested Class Summary | |
---|---|
protected static class |
PositionXmlParser.DefaultPosition
|
static interface |
PositionXmlParser.Position
|
Constructor Summary | |
---|---|
PositionXmlParser()
|
Method Summary | |
---|---|
protected PositionXmlParser.Position |
createPosition(int line,
int column,
int offset)
Creates a position while constructing the DOM document. |
PositionXmlParser.Position |
getPosition(org.w3c.dom.Node node)
Returns the position for the given node. |
PositionXmlParser.Position |
getPosition(org.w3c.dom.Node node,
int start,
int end)
Returns the position for the given node. |
static java.lang.String |
getXmlString(byte[] data)
Returns the String corresponding to the given byte array of XML data (with unknown encoding). |
static java.lang.String |
getXmlString(byte[] data,
java.lang.String defaultCharset)
Returns the String corresponding to the given byte array of XML data (with unknown encoding). |
org.w3c.dom.Document |
parse(byte[] data)
Parses the XML content from the given byte array |
org.w3c.dom.Document |
parse(java.io.InputStream input)
Parses the XML content from the given input stream. |
org.w3c.dom.Document |
parse(java.lang.String xml)
Parses the given XML content. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PositionXmlParser()
Method Detail |
---|
@Nullable public org.w3c.dom.Document parse(@NonNull java.io.InputStream input) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
input
- the input stream containing the XML to be parsed
javax.xml.parsers.ParserConfigurationException
- if a SAX parser is not available
org.xml.sax.SAXException
- if the document contains a parsing error
java.io.IOException
- if something is seriously wrong. This should not
happen since the input source is known to be constructed from
a string.@Nullable public org.w3c.dom.Document parse(@NonNull byte[] data) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
data
- the raw XML data (with unknown encoding)
javax.xml.parsers.ParserConfigurationException
- if a SAX parser is not available
org.xml.sax.SAXException
- if the document contains a parsing error
java.io.IOException
- if something is seriously wrong. This should not
happen since the input source is known to be constructed from
a string.@Nullable public org.w3c.dom.Document parse(@NonNull java.lang.String xml) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
xml
- the XML string to be parsed. This must be in the correct
encoding already.
javax.xml.parsers.ParserConfigurationException
- if a SAX parser is not available
org.xml.sax.SAXException
- if the document contains a parsing error
java.io.IOException
- if something is seriously wrong. This should not
happen since the input source is known to be constructed from
a string.@NonNull public static java.lang.String getXmlString(@NonNull byte[] data)
data
- the XML data to be decoded into a string
@NonNull public static java.lang.String getXmlString(@NonNull byte[] data, @NonNull java.lang.String defaultCharset)
data
- the XML data to be decoded into a stringdefaultCharset
- the default charset to use if not specified by an encoding prologue
attribute or a byte order mark
@Nullable public PositionXmlParser.Position getPosition(@NonNull org.w3c.dom.Node node)
PositionXmlParser.Position.getEnd()
.
node
- the node to look up position for
@Nullable public PositionXmlParser.Position getPosition(@NonNull org.w3c.dom.Node node, int start, int end)
PositionXmlParser.Position.getEnd()
. A specific
range within the node can be specified with the start
and
end
parameters.
node
- the node to look up position forstart
- the relative offset within the node range to use as the
starting position, inclusive, or -1 to not limit the rangeend
- the relative offset within the node range to use as the ending
position, or -1 to not limit the range
@NonNull protected PositionXmlParser.Position createPosition(int line, int column, int offset)
line
- the line number for the positioncolumn
- the column number for the positionoffset
- the character offset
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |