// optimization for large child node lists:
// no need to iterate over the entire child node list if the filter
// does not include wildcards
int count = maxChildNodes == -1 ? Integer.MAX_VALUE : maxChildNodes;
for (String name : childFilter.getInclusionPatterns()) {
ChildNodeEntry cne = node.getChildNodeEntry(name);
if (cne != null) {
boolean incl = true;
for (String exclName : childFilter.getExclusionPatterns()) {
if (name.equals(exclName)) {
incl = false;
break;
}
}
if (incl) {
if (count-- <= 0) {
break;
}
builder.key(name).object();
if (depth > 0) {
toJson(builder, rep.getRevisionStore().getNode(cne.getId()), depth - 1, 0, maxChildNodes, inclVirtualProps, filter);
}
builder.endObject();
}
}
}
return;
}
}
int count = maxChildNodes;
if (count != -1
&& filter != null
&& filter.getChildNodeFilter() != null) {
// specific maxChildNodes limit and child node filter
count = -1;
}
int numSiblings = 0;
for (Iterator<ChildNodeEntry> it = node.getChildNodeEntries(offset, count); it.hasNext(); ) {
ChildNodeEntry cne = it.next();
if (filter == null || filter.includeNode(cne.getName())) {
if (maxChildNodes != -1 && ++numSiblings > maxChildNodes) {
break;
}
builder.key(cne.getName()).object();
if (depth > 0) {
toJson(builder, rep.getRevisionStore().getNode(cne.getId()), depth - 1, 0, maxChildNodes, inclVirtualProps, filter);
}
builder.endObject();
}
}
}