@Test public void decisionExpression() throws ParseException { JSONArray json = array("['case', true, 10, false, 'aString', true]"); MBFilter mbfilter = new MBFilter(json); Filter filter = mbfilter.filter(); assertEquals("case(true,10,false,'aString',true) = true", ECQL.toCQL(filter)); json = array("['coalesce', 'aString', false, 5]"); mbfilter = new MBFilter(json); filter = mbfilter.filter(); assertEquals("coalesce('aString',false,5) = true", ECQL.toCQL(filter)); json = array( "[\"match\",'bLabel','aLabel', 'firstLabel','bLabel','secondLabel','defaultLabel']"); mbfilter = new MBFilter(json); filter = mbfilter.filter(); assertEquals( "match('bLabel','aLabel','firstLabel','bLabel','secondLabel','defaultLabel') = true", ECQL.toCQL(filter)); }
public Filter filter() { if (json == null || json.isEmpty()) { return Filter.INCLUDE; } String operator = parse.get(json, 0); if (("==".equals(operator) || "!=".equals(operator) || "in".equals(operator) || "!in".equals(operator)) && parse.isString(json, 1) && "$type".equals(parse.get(json, 1))) { return filterByGeometryType(json, operator); } if (("==".equals(operator) || "!=".equals(operator) || "has".equals(operator) || "!has".equals(operator) || "in".equals(operator) || "!in".equals(operator)) && parse.isString(json, 1) && "$id".equals(parse.get(json, 1))) { return filterByFeatureIdentifier(json, operator); } if ("!has".equals(operator)) { String key = parse.get(json, 1); return ff.isNull(ff.property(key)); } else if ("has".equals(operator)) { String key = parse.get(json, 1); return ff.not(ff.isNull(ff.property(key))); } else if ("==".equals(operator)) { return filterEqualTo(json); } else if ("!=".equals(operator)) { return filterNotEqual(json); } else if (">".equals(operator)) { return filterGreater(json); } else if (">=".equals(operator)) { return filterGreaterOrEqual(json); } else if ("<".equals(operator)) { return filterLess(json); } else if ("<=".equals(operator)) { return filterLessOrEqual(json); } else if ("in".equals(operator)) { return filterIn(json, true); } else if ("!in".equals(operator)) { return filterIn(json, false); } else if ("all".equals(operator)) { return filterAll(json); } else if ("any".equals(operator)) { return filterAny(json); } else if ("none".equals(operator)) { return filterNone(json); } else if ("case".equals(operator)) { Expression caseExpr = MBExpression.transformExpression(json); return ff.equals(caseExpr, ff.literal(true)); } else if ("coalesce".equals(operator)) { Expression coalesce = MBExpression.transformExpression(json); return ff.equals(coalesce, ff.literal(true)); } else if ("match".equals(operator)) { Expression match = MBExpression.transformExpression(json); return ff.equals(match, ff.literal(true)); } else if ("within".equals(operator)) { Expression within = MBExpression.transformExpression(json); return ff.equals(within, ff.literal(true)); } else { throw new MBFormatException( "Data expression or filter \"" + operator + "\" invalid. It may be misspelled or not supported by this implementation:" + json); } }
MBFilter { public Filter filter() { if (json == null || json.isEmpty()) { return Filter.INCLUDE; } String operator = parse.get(json, 0); if (("==".equals(operator) || "!=".equals(operator) || "in".equals(operator) || "!in".equals(operator)) && parse.isString(json, 1) && "$type".equals(parse.get(json, 1))) { return filterByGeometryType(json, operator); } if (("==".equals(operator) || "!=".equals(operator) || "has".equals(operator) || "!has".equals(operator) || "in".equals(operator) || "!in".equals(operator)) && parse.isString(json, 1) && "$id".equals(parse.get(json, 1))) { return filterByFeatureIdentifier(json, operator); } if ("!has".equals(operator)) { String key = parse.get(json, 1); return ff.isNull(ff.property(key)); } else if ("has".equals(operator)) { String key = parse.get(json, 1); return ff.not(ff.isNull(ff.property(key))); } else if ("==".equals(operator)) { return filterEqualTo(json); } else if ("!=".equals(operator)) { return filterNotEqual(json); } else if (">".equals(operator)) { return filterGreater(json); } else if (">=".equals(operator)) { return filterGreaterOrEqual(json); } else if ("<".equals(operator)) { return filterLess(json); } else if ("<=".equals(operator)) { return filterLessOrEqual(json); } else if ("in".equals(operator)) { return filterIn(json, true); } else if ("!in".equals(operator)) { return filterIn(json, false); } else if ("all".equals(operator)) { return filterAll(json); } else if ("any".equals(operator)) { return filterAny(json); } else if ("none".equals(operator)) { return filterNone(json); } else if ("case".equals(operator)) { Expression caseExpr = MBExpression.transformExpression(json); return ff.equals(caseExpr, ff.literal(true)); } else if ("coalesce".equals(operator)) { Expression coalesce = MBExpression.transformExpression(json); return ff.equals(coalesce, ff.literal(true)); } else if ("match".equals(operator)) { Expression match = MBExpression.transformExpression(json); return ff.equals(match, ff.literal(true)); } else if ("within".equals(operator)) { Expression within = MBExpression.transformExpression(json); return ff.equals(within, ff.literal(true)); } else { throw new MBFormatException( "Data expression or filter \"" + operator + "\" invalid. It may be misspelled or not supported by this implementation:" + json); } } }
MBFilter { public Filter filter() { if (json == null || json.isEmpty()) { return Filter.INCLUDE; } String operator = parse.get(json, 0); if (("==".equals(operator) || "!=".equals(operator) || "in".equals(operator) || "!in".equals(operator)) && parse.isString(json, 1) && "$type".equals(parse.get(json, 1))) { return filterByGeometryType(json, operator); } if (("==".equals(operator) || "!=".equals(operator) || "has".equals(operator) || "!has".equals(operator) || "in".equals(operator) || "!in".equals(operator)) && parse.isString(json, 1) && "$id".equals(parse.get(json, 1))) { return filterByFeatureIdentifier(json, operator); } if ("!has".equals(operator)) { String key = parse.get(json, 1); return ff.isNull(ff.property(key)); } else if ("has".equals(operator)) { String key = parse.get(json, 1); return ff.not(ff.isNull(ff.property(key))); } else if ("==".equals(operator)) { return filterEqualTo(json); } else if ("!=".equals(operator)) { return filterNotEqual(json); } else if (">".equals(operator)) { return filterGreater(json); } else if (">=".equals(operator)) { return filterGreaterOrEqual(json); } else if ("<".equals(operator)) { return filterLess(json); } else if ("<=".equals(operator)) { return filterLessOrEqual(json); } else if ("in".equals(operator)) { return filterIn(json, true); } else if ("!in".equals(operator)) { return filterIn(json, false); } else if ("all".equals(operator)) { return filterAll(json); } else if ("any".equals(operator)) { return filterAny(json); } else if ("none".equals(operator)) { return filterNone(json); } else if ("case".equals(operator)) { Expression caseExpr = MBExpression.transformExpression(json); return ff.equals(caseExpr, ff.literal(true)); } else if ("coalesce".equals(operator)) { Expression coalesce = MBExpression.transformExpression(json); return ff.equals(coalesce, ff.literal(true)); } else if ("match".equals(operator)) { Expression match = MBExpression.transformExpression(json); return ff.equals(match, ff.literal(true)); } else if ("within".equals(operator)) { Expression within = MBExpression.transformExpression(json); return ff.equals(within, ff.literal(true)); } else { throw new MBFormatException( "Data expression or filter \"" + operator + "\" invalid. It may be misspelled or not supported by this implementation:" + json); } } MBFilter(JSONArray json);  MBFilter(JSONArray json, MBObjectParser parse);  MBFilter(JSONArray json, MBObjectParser parse, SemanticType semanticType); }
MBFilter { public Filter filter() { if (json == null || json.isEmpty()) { return Filter.INCLUDE; } String operator = parse.get(json, 0); if (("==".equals(operator) || "!=".equals(operator) || "in".equals(operator) || "!in".equals(operator)) && parse.isString(json, 1) && "$type".equals(parse.get(json, 1))) { return filterByGeometryType(json, operator); } if (("==".equals(operator) || "!=".equals(operator) || "has".equals(operator) || "!has".equals(operator) || "in".equals(operator) || "!in".equals(operator)) && parse.isString(json, 1) && "$id".equals(parse.get(json, 1))) { return filterByFeatureIdentifier(json, operator); } if ("!has".equals(operator)) { String key = parse.get(json, 1); return ff.isNull(ff.property(key)); } else if ("has".equals(operator)) { String key = parse.get(json, 1); return ff.not(ff.isNull(ff.property(key))); } else if ("==".equals(operator)) { return filterEqualTo(json); } else if ("!=".equals(operator)) { return filterNotEqual(json); } else if (">".equals(operator)) { return filterGreater(json); } else if (">=".equals(operator)) { return filterGreaterOrEqual(json); } else if ("<".equals(operator)) { return filterLess(json); } else if ("<=".equals(operator)) { return filterLessOrEqual(json); } else if ("in".equals(operator)) { return filterIn(json, true); } else if ("!in".equals(operator)) { return filterIn(json, false); } else if ("all".equals(operator)) { return filterAll(json); } else if ("any".equals(operator)) { return filterAny(json); } else if ("none".equals(operator)) { return filterNone(json); } else if ("case".equals(operator)) { Expression caseExpr = MBExpression.transformExpression(json); return ff.equals(caseExpr, ff.literal(true)); } else if ("coalesce".equals(operator)) { Expression coalesce = MBExpression.transformExpression(json); return ff.equals(coalesce, ff.literal(true)); } else if ("match".equals(operator)) { Expression match = MBExpression.transformExpression(json); return ff.equals(match, ff.literal(true)); } else if ("within".equals(operator)) { Expression within = MBExpression.transformExpression(json); return ff.equals(within, ff.literal(true)); } else { throw new MBFormatException( "Data expression or filter \"" + operator + "\" invalid. It may be misspelled or not supported by this implementation:" + json); } } MBFilter(JSONArray json);  MBFilter(JSONArray json, MBObjectParser parse);  MBFilter(JSONArray json, MBObjectParser parse, SemanticType semanticType); Set<SemanticType> semanticTypeIdentifiers(); Filter filter(); }
MBFilter { public Filter filter() { if (json == null || json.isEmpty()) { return Filter.INCLUDE; } String operator = parse.get(json, 0); if (("==".equals(operator) || "!=".equals(operator) || "in".equals(operator) || "!in".equals(operator)) && parse.isString(json, 1) && "$type".equals(parse.get(json, 1))) { return filterByGeometryType(json, operator); } if (("==".equals(operator) || "!=".equals(operator) || "has".equals(operator) || "!has".equals(operator) || "in".equals(operator) || "!in".equals(operator)) && parse.isString(json, 1) && "$id".equals(parse.get(json, 1))) { return filterByFeatureIdentifier(json, operator); } if ("!has".equals(operator)) { String key = parse.get(json, 1); return ff.isNull(ff.property(key)); } else if ("has".equals(operator)) { String key = parse.get(json, 1); return ff.not(ff.isNull(ff.property(key))); } else if ("==".equals(operator)) { return filterEqualTo(json); } else if ("!=".equals(operator)) { return filterNotEqual(json); } else if (">".equals(operator)) { return filterGreater(json); } else if (">=".equals(operator)) { return filterGreaterOrEqual(json); } else if ("<".equals(operator)) { return filterLess(json); } else if ("<=".equals(operator)) { return filterLessOrEqual(json); } else if ("in".equals(operator)) { return filterIn(json, true); } else if ("!in".equals(operator)) { return filterIn(json, false); } else if ("all".equals(operator)) { return filterAll(json); } else if ("any".equals(operator)) { return filterAny(json); } else if ("none".equals(operator)) { return filterNone(json); } else if ("case".equals(operator)) { Expression caseExpr = MBExpression.transformExpression(json); return ff.equals(caseExpr, ff.literal(true)); } else if ("coalesce".equals(operator)) { Expression coalesce = MBExpression.transformExpression(json); return ff.equals(coalesce, ff.literal(true)); } else if ("match".equals(operator)) { Expression match = MBExpression.transformExpression(json); return ff.equals(match, ff.literal(true)); } else if ("within".equals(operator)) { Expression within = MBExpression.transformExpression(json); return ff.equals(within, ff.literal(true)); } else { throw new MBFormatException( "Data expression or filter \"" + operator + "\" invalid. It may be misspelled or not supported by this implementation:" + json); } } MBFilter(JSONArray json);  MBFilter(JSONArray json, MBObjectParser parse);  MBFilter(JSONArray json, MBObjectParser parse, SemanticType semanticType); Set<SemanticType> semanticTypeIdentifiers(); Filter filter(); static final String TYPE_POINT; static final String TYPE_LINE; static final String TYPE_POLYGON; }