public class XPathUtils
extends java.lang.Object
Constructor and Description |
---|
XPathUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
compare(java.lang.String path1,
java.lang.String path2)
Compares two xpaths for "xpath order", using "natuiral" or alphabetical
ordering except for when xpath indexing is involved, e.g., "/record/general[3]/foo[5]"
is "less than" "/record/general[4]/foo[6]".
|
static java.lang.String |
decodeXPath(java.lang.String path)
Converts encoded paths of the form used in jsp pages ( "foo_1_") to a XPath
form ("foo[1]").
|
static java.lang.String |
encodeXPath(java.lang.String s)
Converts indexed paths of the form ("foo[1]") to the form used in jsp pages
( "foo_1_")
|
static int |
getIndex(java.lang.String s)
Returns the index, if any, for the leaf of the given path.
|
static java.lang.String |
getLeaf(java.lang.String xpath)
Returns the name of the element refered to by the given xpath, which is the
leaf, stripped of "\@" in the case of attribute paths).
|
static java.lang.String |
getNodeName(java.lang.String xpath)
Returns the name of the node referred to by the (possibly jsp-encoded)
xpath, stripped of indexing information.
|
static java.lang.String |
getParentXPath(java.lang.String xpath)
Gets the parentXPath attribute of the XPathUtils class
|
static java.lang.String |
getSiblingXPath(java.lang.String xpath)
Gets the siblingPath (that matches all like-named nodes of the parent
Element) of a given xpath.
|
static boolean |
isAttributePath(java.lang.String xpath)
Returns true if the xpath refers to an attribute.
|
static java.lang.String |
normalizeXPath(java.lang.String s)
Removes indexing information from XPath strings.
|
static java.lang.String |
removeELbrackets(java.lang.String s)
Remove jsp expressionLanauge brackets used to support indexing in jsp pages
(i.e., ${...}) from a path.
|
public static java.lang.String decodeXPath(java.lang.String path)
path
- NOT YET DOCUMENTEDpublic static java.lang.String removeELbrackets(java.lang.String s)
s
- path containing el-encoded bracketspublic static int getIndex(java.lang.String s)
Works for both encoded indexing (e.g., "asdf_1_") and decoded (e.g., "asasdf[1]".
s
- NOT YET DOCUMENTEDpublic static java.lang.String encodeXPath(java.lang.String s)
s
- indexed xpathpublic static java.lang.String normalizeXPath(java.lang.String s)
s
- xpath possibly containing index notationpublic static java.lang.String getLeaf(java.lang.String xpath)
xpath
- NOT YET DOCUMENTEDpublic static boolean isAttributePath(java.lang.String xpath)
xpath
- xpath to be testedpublic static java.lang.String getNodeName(java.lang.String xpath)
xpath
- NOT YET DOCUMENTEDpublic static java.lang.String getParentXPath(java.lang.String xpath)
xpath
- Description of the Parameterpublic static java.lang.String getSiblingXPath(java.lang.String xpath)
(String)
does).xpath
- XPath as Stringpublic static int compare(java.lang.String path1, java.lang.String path2)
NOTE: result of this comparison is not the same "document order", since XML documents are not structured in alpha order!
path1
- first path to be comparedpath2
- second path to be compared