@Beta
public abstract class XmlParser
extends java.lang.Object
NOTE: This is not a public or final API; if you rely on this be prepared to adjust your code for the next tools release.
| Constructor and Description |
|---|
XmlParser() |
| Modifier and Type | Method and Description |
|---|---|
abstract Location.Handle |
createLocationHandle(XmlContext context,
org.w3c.dom.Node node)
Creates a light-weight handle to a location for the given node.
|
void |
dispose(XmlContext context,
org.w3c.dom.Document document)
Dispose any data structures held for the given context.
|
abstract org.w3c.dom.Node |
findNodeAt(XmlContext context,
int offset)
Returns the leaf node at the given offset (biased towards the right), or null if not found
|
abstract Location |
getLocation(java.io.File file,
org.w3c.dom.Node node)
Attempt to create a location for a given XML node.
|
abstract Location |
getLocation(XmlContext context,
org.w3c.dom.Node node)
Returns a
Location for the given DOM node |
abstract Location |
getLocation(XmlContext context,
org.w3c.dom.Node node,
int start,
int end)
Returns a
Location for the given DOM node. |
abstract Location |
getNameLocation(XmlContext context,
org.w3c.dom.Node node)
Returns a
Location for the given DOM node |
abstract int |
getNodeEndOffset(XmlContext context,
org.w3c.dom.Node node)
Returns the end offset of the given node, or -1 if not known
|
abstract int |
getNodeStartOffset(XmlContext context,
org.w3c.dom.Node node)
Returns the start offset of the given node, or -1 if not known
|
abstract Location |
getValueLocation(XmlContext context,
org.w3c.dom.Attr node)
Returns a
Location for the given DOM node |
abstract org.w3c.dom.Document |
parseXml(java.io.File file)
Parse the given XML content and returns as a Document
|
abstract org.w3c.dom.Document |
parseXml(XmlContext context)
Parse the file pointed to by the given context and return as a Document
|
@Nullable
public abstract org.w3c.dom.Document parseXml(@NonNull
java.io.File file)
throws java.io.IOException,
org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException
file - the file to be parsedjava.io.IOExceptionorg.xml.sax.SAXExceptionjavax.xml.parsers.ParserConfigurationException@Nullable
public abstract org.w3c.dom.Document parseXml(@NonNull
XmlContext context)
context - the context pointing to the file to be parsed, typically
via Context.getContents() but the file handle (
Context.file can also be used to map to an existing
editor buffer in the surrounding tool, etc)@NonNull public abstract Location getLocation(@NonNull XmlContext context, @NonNull org.w3c.dom.Node node)
Location for the given DOM nodecontext - information about the file being parsednode - the node to create a location for@NonNull public abstract Location getLocation(@NonNull java.io.File file, @NonNull org.w3c.dom.Node node)
file - the file that contains the node that was parsednode - the node itself@NonNull public abstract Location getLocation(@NonNull XmlContext context, @NonNull org.w3c.dom.Node node, int start, int end)
Location for the given DOM node. Like
getLocation(XmlContext, Node), but allows a position range that
is a subset of the node range.context - information about the file being parsednode - the node to create a location forstart - the starting position within the node, inclusiveend - the ending position within the node, exclusive@NonNull public abstract Location getNameLocation(@NonNull XmlContext context, @NonNull org.w3c.dom.Node node)
Location for the given DOM nodecontext - information about the file being parsednode - the node to create a location for@NonNull public abstract Location getValueLocation(@NonNull XmlContext context, @NonNull org.w3c.dom.Attr node)
Location for the given DOM nodecontext - information about the file being parsednode - the node to create a location for@NonNull public abstract Location.Handle createLocationHandle(@NonNull XmlContext context, @NonNull org.w3c.dom.Node node)
Location.Handle.resolve().context - the context providing the nodenode - the node (element or attribute) to create a location handle
forpublic void dispose(@NonNull
XmlContext context,
@NonNull
org.w3c.dom.Document document)
context - information about the file previously parseddocument - the document that was parsed and is now being disposedpublic abstract int getNodeStartOffset(@NonNull
XmlContext context,
@NonNull
org.w3c.dom.Node node)
context - the context providing the nodenode - the node (element or attribute) to create a location handle
forpublic abstract int getNodeEndOffset(@NonNull
XmlContext context,
@NonNull
org.w3c.dom.Node node)
context - the context providing the nodenode - the node (element or attribute) to create a location handle
for@Nullable
public abstract org.w3c.dom.Node findNodeAt(@NonNull
XmlContext context,
int offset)
offset - the offset to search at