Methods Summary |
---|
private static int | bypassBrackets(java.lang.String xPath, int idx)
char ch;
while(idx>=0 && ((ch=xPath.charAt(idx))!=OPENBRACKET_CHAR || isEscapedChar(xPath,idx))) {
idx--;
}
return idx-1;
|
public static java.lang.String | getAbsoluteIdXpathExpression(java.lang.String childTagName, java.lang.String nameId, java.lang.String valueId)
if(childTagName.startsWith(XPATH_SEPARATOR))
return childTagName + "[@" + nameId + "='" + valueId + "']";
else
return XPATH_SEPARATOR + childTagName + "[@" + nameId + "='" + valueId + "']";
|
public static java.lang.String | getLastNodeName(java.lang.String xPath)
/*
* returns element's tag name extracting from its xpath
*/
//FIXME: it is supposed that open bracket should be escaped if its part of name or value
// FIXME no error handling
int idx = xPath.length()-1;
char ch;
int idxEnd = -1;
if(idx>=0 && (ch=xPath.charAt(idx))==CLOSEBRACKET_CHAR) {
idxEnd = bypassBrackets(xPath, --idx);
idx = idxEnd;
}
while(idx>=0 && ((ch=xPath.charAt(idx))!=SEPARATOR_CHAR || isEscapedChar(xPath,idx))) {
idx--;
}
idx++;
if(idxEnd<=0 || idxEnd==xPath.length()-1)
return xPath.substring(idx);
else
return xPath.substring(idx, idxEnd+1);
|
public static java.lang.String | getParentXPath(java.lang.String xPath)
//FIXME: it is supposed that open bracket should be escaped if its part of name or value
// FIXME no error handling
int idx = xPath.length()-1;
char ch;
if(idx>=0 && (ch=xPath.charAt(idx))==CLOSEBRACKET_CHAR) {
idx = bypassBrackets(xPath, --idx);
}
while(idx>=0 && ((ch=xPath.charAt(idx))!=SEPARATOR_CHAR || isEscapedChar(xPath,idx))) {
idx--;
}
if(idx<=0)
return "/";
return xPath.substring(0, idx);
|
private static boolean | isEscapedChar(java.lang.String xPath, int idx)
if(idx<=0)
return false;
int count = 0;
while(--idx>=0 && xPath.charAt(idx)==ESCAPE_CHAR)
count++;
return ((count%2)==1);
|