ECQL { public static String toCQL( List<Filter> filterList ){ FilterToECQL toECQL = new FilterToECQL(); StringBuilder output = new StringBuilder(); Iterator<Filter> iter = filterList.iterator(); while( iter.hasNext() ){ Filter filter = iter.next(); filter.accept( toECQL, output ); if(iter.hasNext() ){ output.append("; "); } } return output.toString(); } private  ECQL(); static Filter toFilter(final String ecqlPredicate); static Filter toFilter(final String ecqlPredicate, final FilterFactory filterFactory); static Expression toExpression(String ecqlExpression); static Expression toExpression(final String ecqlExpression,
            final FilterFactory filterFactory); static List<Filter> toFilterList(final String ecqlSequencePredicate); static List<Filter> toFilterList(final String ecqlSequencePredicate, FilterFactory filterFactory); static String toCQL( List<Filter> filterList ); static String toCQL( Filter filter ); static String toCQL( Expression expression ); static final void main(String[] args);  }
@Test public void greaterFilterToCQL() throws Exception { String expectedECQL = FilterECQLSample.PROPERTY_GREATER_MINUS_INGEGER; Filter filter = FilterECQLSample.getSample(expectedECQL); String resultECQL = ECQL.toCQL(filter ); Assert.assertEquals(expectedECQL, resultECQL); }
@Test public void likeFilterToCQL() throws Exception { String expectedECQL = FilterECQLSample.LITERAL_LIKE_ECQL_PATTERN; Filter filter = FilterECQLSample.getSample(expectedECQL); String resultECQL = ECQL.toCQL(filter ); Assert.assertEquals(expectedECQL, resultECQL); }
@Test public void functionExpressionToCQL() throws Exception { Expression[] absArgs = new Expression[1]; FilterFactory ff = CommonFactoryFinder.getFilterFactory((Hints) null); absArgs[0] = ff.literal(10); Function abs = ff.function("abs", absArgs); String resultECQL = ECQL.toCQL(abs); Assert.assertEquals("abs(10)", resultECQL); }
@Test public void testDivideEncode() throws Exception { final FilterFactory2 filterFactory2 = CommonFactoryFinder.getFilterFactory2(); final Filter javaFilter = filterFactory2.less( filterFactory2.divide(filterFactory2.property("population"), filterFactory2.literal(2)), filterFactory2.divide(filterFactory2.property("pop2000"), filterFactory2.literal(2)) ); Assert.assertEquals("population/2<pop2000/2", ECQL.toCQL(javaFilter).replace(" ", "")); }