} else if (lpr.first != null && !lpr.first.equals(lpr.last)) {
// > & >= in ascending index
value = lpr.first.getValue(Type.STRING);
final String vv = value;
final boolean include = lpr.firstIncluding;
final OrderDirection dd = direction;
Iterable<? extends ChildNodeEntry> children = getChildNodeEntries(content);
Predicate<String> predicate = new Predicate<String>() {
private String v = vv;
private boolean i = include;
private OrderDirection d = dd;
@Override
public boolean apply(String input) {
boolean b;
if (d.equals(OrderDirection.ASC)) {
b = v.compareTo(input) > 0;
} else {
b = v.compareTo(input) < 0;
}
b = b || (i && v.equals(input));
return b;
}
@Override
public String getSearchFor() {
throw new UnsupportedOperationException();
}
};
CountingNodeVisitor v;
int depthTotal = 0;
// seeking the right starting point
for (ChildNodeEntry child : children) {
String converted = convert(child.getName());
if (predicate.apply(converted)) {
// here we are let's start counting
v = new CountingNodeVisitor(max);
v.visit(content.getChildNode(child.getName()));
count += v.getCount();
depthTotal += v.depthTotal;
if (count > max) {
break;
}
}
}
// small hack for having a common way of counting
v = new CountingNodeVisitor(max);
v.depthTotal = depthTotal;
v.count = (int) Math.min(count, Integer.MAX_VALUE);
count = v.getEstimatedCount();
} else if (lpr.last != null && !lpr.last.equals(lpr.first)) {
// < & <=
value = lpr.last.getValue(Type.STRING);
final String vv = value;
final boolean include = lpr.lastIncluding;
final OrderDirection dd = direction;
Iterable<? extends ChildNodeEntry> children = getChildNodeEntries(content);
Predicate<String> predicate = new Predicate<String>() {
private String v = vv;
private boolean i = include;