use of org.z3950.zing.cql.CQLPrefixNode in project okapi by folio-org.
the class CQLUtil method reducer.
public static CQLNode reducer(CQLNode vn1, CQLTermNode tn, Comparator<CQLTermNode> cmp) {
if (vn1 instanceof CQLBooleanNode) {
return reduceBoolean((CQLBooleanNode) vn1, tn, cmp);
} else if (vn1 instanceof CQLTermNode) {
CQLTermNode n1 = (CQLTermNode) vn1;
if (cmp != null && cmp.compare(n1, tn) == 0) {
return null;
}
return new CQLTermNode(n1.getIndex(), n1.getRelation(), n1.getTerm());
} else if (vn1 instanceof CQLSortNode) {
CQLSortNode n1 = (CQLSortNode) vn1;
CQLNode n2 = reducer(n1.getSubtree(), tn, cmp);
if (n2 == null) {
return null;
} else {
CQLSortNode sn = new CQLSortNode(n2);
List<ModifierSet> mods = n1.getSortIndexes();
for (ModifierSet mSet : mods) {
sn.addSortIndex(mSet);
}
return sn;
}
} else if (vn1 instanceof CQLPrefixNode) {
CQLPrefixNode n1 = (CQLPrefixNode) vn1;
CQLNode n2 = reducer(n1.getSubtree(), tn, cmp);
if (n2 == null) {
return null;
} else {
CQLPrefix prefix = n1.getPrefix();
return new CQLPrefixNode(prefix.getName(), prefix.getIdentifier(), n2);
}
} else {
throw new IllegalArgumentException("unknown type for CQLNode: " + vn1.toString());
}
}
Aggregations