Package ghidra.xml
Class AbstractXmlPullParser
- java.lang.Object
-
- ghidra.xml.AbstractXmlPullParser
-
- All Implemented Interfaces:
XmlPullParser
- Direct Known Subclasses:
NonThreadedXmlPullParserImpl
public abstract class AbstractXmlPullParser extends java.lang.Object implements XmlPullParser
-
-
Constructor Summary
Constructors Constructor Description AbstractXmlPullParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
discardSubTree()
Discards the current subtree.int
discardSubTree(XmlElement element)
Discards a subtree.int
discardSubTree(java.lang.String elementName)
Discards the current subtree.XmlElement
end()
Returns the next element, which must be an end element.XmlElement
end(XmlElement element)
Returns the next element, which must be an end element, and must match the supplied XmlElement's name (presumably the start element of the subtree).int
getColumnNumber()
Returns the current column number where the parser is (note that this may actually be ahead of where you think it is because of look-ahead and caching).int
getCurrentLevel()
The current element level, as if the XML document was a tree.int
getLineNumber()
Returns the current line number where the parser is (note that this may actually be ahead of where you think it is because of look-ahead and caching).XmlElement
softStart(java.lang.String... names)
Returns the next element, which must be a start element, and must be one of the supplied names (if provided).XmlElement
start(java.lang.String... names)
Returns the next element, which must be a start element, and must be one of the supplied names (if provided).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ghidra.xml.XmlPullParser
dispose, getName, getProcessingInstruction, hasNext, isPullingContent, next, peek, setPullingContent
-
-
-
-
Method Detail
-
end
public XmlElement end()
Description copied from interface:XmlPullParser
Returns the next element, which must be an end element. The name doesn't matter. This method throws an XmlException if the next element is not an end element. Use this method when you really know you're matching the right end and want to avoid extra constraint checks.- Specified by:
end
in interfaceXmlPullParser
- Returns:
- the next element (which is an end element)
-
end
public XmlElement end(XmlElement element)
Description copied from interface:XmlPullParser
Returns the next element, which must be an end element, and must match the supplied XmlElement's name (presumably the start element of the subtree). This method throws an XmlException if the next element is not an end element, or if the name doesn't match.- Specified by:
end
in interfaceXmlPullParser
- Parameters:
element
- the presumed start element to match names- Returns:
- the next element (which is an end element)
-
getColumnNumber
public int getColumnNumber()
Description copied from interface:XmlPullParser
Returns the current column number where the parser is (note that this may actually be ahead of where you think it is because of look-ahead and caching).- Specified by:
getColumnNumber
in interfaceXmlPullParser
- Returns:
- the current column number
-
getCurrentLevel
public int getCurrentLevel()
Description copied from interface:XmlPullParser
The current element level, as if the XML document was a tree. The root element is at level 0. Each child is at a level one higher than its parent. Note that this is the same as peek().getLevel().- Specified by:
getCurrentLevel
in interfaceXmlPullParser
- Returns:
- the current element level
-
getLineNumber
public int getLineNumber()
Description copied from interface:XmlPullParser
Returns the current line number where the parser is (note that this may actually be ahead of where you think it is because of look-ahead and caching).- Specified by:
getLineNumber
in interfaceXmlPullParser
- Returns:
- the current line number
-
start
public XmlElement start(java.lang.String... names)
Description copied from interface:XmlPullParser
Returns the next element, which must be a start element, and must be one of the supplied names (if provided). This method is very useful for starting a subtree, and throws an XmlException if the next element does not conform to your specification.- Specified by:
start
in interfaceXmlPullParser
- Parameters:
names
- optional vararg Strings which start element name must be one of- Returns:
- the next element (which is a start element)
-
softStart
public XmlElement softStart(java.lang.String... names)
Description copied from interface:XmlPullParser
Returns the next element, which must be a start element, and must be one of the supplied names (if provided). This method is very useful for starting a subtree, but differs from start(...) in that failures are soft. This means that if the next element isn't a start element, or doesn't match one of the optional provided names, null is returned (instead of raising an XmlException).- Specified by:
softStart
in interfaceXmlPullParser
- Parameters:
names
- optional vararg Strings which start element name must be one of- Returns:
- the next element (which is a start element) or null
-
discardSubTree
public int discardSubTree()
Description copied from interface:XmlPullParser
Discards the current subtree. If the current element (peek()) is a content or end element, then just that element is discarded. If it's a start element, then the entire subtree starting with the start element is discarded (i.e. next() is called until the current element is now the element after the subtree's end element).- Specified by:
discardSubTree
in interfaceXmlPullParser
- Returns:
- the number of elements discarded
-
discardSubTree
public int discardSubTree(XmlElement element)
Description copied from interface:XmlPullParser
Discards a subtree. The element provided is used as the "start" of the subtree (although it doesn't actually have to be a start element; only its name and level are used). The queue of elements is discarded such that the last element discarded is an end element, has the same name as the provided element, and is the same level as the provided element. If the provided element's level is higher than the current level, then nothing is discarded.- Specified by:
discardSubTree
in interfaceXmlPullParser
- Parameters:
element
- the element provided as the "start" element- Returns:
- the number of elements discarded
-
discardSubTree
public int discardSubTree(java.lang.String elementName)
Description copied from interface:XmlPullParser
Discards the current subtree. The current element must be a start element, and must be named name, otherwise an XmlException is thrown.- Specified by:
discardSubTree
in interfaceXmlPullParser
- Parameters:
elementName
- what the current start element must be named- Returns:
- the number of elements discarded
-
-