public boolean match(XMLPathPattern other) {
return match(this, other, 0, 0);
}
private static boolean match(final XMLPathPattern verifyPattern, final XMLPathPattern targetPattern, int vi, int oi) {
final IntStack verifyTypes = verifyPattern.types;
final Stack<QualifiedName> verifyPatterns = verifyPattern.patterns;
final IntStack otherTypes = targetPattern.types;
final Stack<QualifiedName> otherPatterns = targetPattern.patterns;
final int otherPtnlen = otherPatterns.size();
final int verifyPtnlen = verifyPatterns.size();
for(; vi < verifyPtnlen; vi++, oi++) {
if(oi >= otherPtnlen) {
return false;
}
final int verifyType = verifyTypes.elementAt(vi);
if((verifyType & MATCH) == MATCH) {
final int otherType = otherTypes.elementAt(oi);
if((otherType & MATCH) != MATCH) {
throw new IllegalArgumentException("Comparing other pattern must be an AbstractPath"
+ otherTypes.toString());
}
if(verifyType != otherType) {
return false;
}
if(verifyType == TEXT_MATCH) {
continue;
}
final QualifiedName otherName = otherPatterns.get(oi);
final QualifiedName verifyName = verifyPatterns.get(vi);
if(!verifyName.equals(otherName)) {
return false;
}
} else if(verifyType == ELEM_WILDCARD) {
final int otherType = otherTypes.elementAt(oi);
if((otherType & ELEMENT) != ELEMENT) {
return false;
}
} else if(verifyType == ATTR_WILDCARD) {
final int otherType = otherTypes.elementAt(oi);
if((otherType & ATTRIBUTE) != ATTRIBUTE) {
return false;
}
} else if(verifyType == SKIPPABLE) {
if(++vi >= verifyPtnlen) {