in ch-commons-xbean/src/main/java/com/cloudhopper/commons/xml/XPath.java [86:113]
public boolean matches(String xpath, boolean includeParent) {
if (xpath == null || xpath.equals("")) {
throw new IllegalArgumentException("xpath cannot be null or empty");
}
// make sure xpath doesn't end with an /
if (xpath.endsWith("/")) {
throw new IllegalArgumentException("Should not end with /");
}
// the xpath might be a parent path
if (includeParent && normalizedXPath.startsWith(xpath+"/")) {
return true;
}
// otherwise, either this is an exact match or a child of a previous match
if (xpath.startsWith(normalizedXPath)) {
// if lengths are equal, then its a perfect match
if (xpath.length() == normalizedXPath.length()) {
return true;
} else if (includeChildren) {
return true;
} else {
return false;
}
}
return false;
}