in src/main/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java [66:119]
public boolean nextNode() {
if (done) {
return false;
}
while (parentContext.nextNode()) {
if (setupDynamicPropertyPointer()) {
final Object pred = nameTestExpression.computeValue(parentContext);
final String propertyName = InfoSetUtil.stringValue(pred);
// At this point it would be nice to say:
// dynamicPropertyPointer.setPropertyName(propertyName)
// and then: dynamicPropertyPointer.isActual().
// However some PropertyPointers, e.g. DynamicPropertyPointer
// will declare that any property you ask for is actual.
// That's not acceptable for us: we really need to know
// if the property is currently declared. Thus,
// we'll need to perform a search.
boolean ok = false;
final String[] names = dynamicPropertyPointer.getPropertyNames();
for (final String name : names) {
if (name.equals(propertyName)) {
ok = true;
break;
}
}
if (ok) {
dynamicPropertyPointer.setPropertyName(propertyName);
position++;
return true;
}
} else {
Object pred = expression.computeValue(parentContext);
if (pred instanceof Iterator) {
if (!((Iterator) pred).hasNext()) {
return false;
}
pred = ((Iterator) pred).next();
}
if (pred instanceof NodePointer) {
pred = ((NodePointer) pred).getNode();
}
if (pred instanceof Number) {
final int pos = (int) InfoSetUtil.doubleValue(pred);
position++;
done = true;
return parentContext.setPosition(pos);
}
if (InfoSetUtil.booleanValue(pred)) {
position++;
return true;
}
}
}
return false;
}