use of org.geotools.filter.CompareFilterImpl in project sldeditor by robward-scisys.
the class MiscTests method testIsNullClass.
/**
* {@link com.sldeditor.filter.v2.function.misc.IsNull}.
*/
@Test
public void testIsNullClass() {
FilterConfigInterface objUnderTest = new IsNull();
assertNotNull(objUnderTest.getFilterConfiguration());
assertNotNull(objUnderTest.createFilter());
assertNull(objUnderTest.createLogicFilter(null));
CompareFilterImpl filter = (CompareFilterImpl) objUnderTest.createFilter(null);
assertNull(filter.getExpression1());
List<Expression> parameterList = new ArrayList<Expression>();
filter = (CompareFilterImpl) objUnderTest.createFilter(parameterList);
assertNull(filter.getExpression1());
parameterList.add(ff.literal("expr1"));
filter = (CompareFilterImpl) objUnderTest.createFilter(parameterList);
assertNotNull(filter.getExpression1());
System.out.println(filter.toString());
}
use of org.geotools.filter.CompareFilterImpl in project hale by halestudio.
the class CqlToMappingConditionTranslator method createNode.
private FilterNode createNode(FilterNode parent, Filter child) {
FilterNode childNode = null;
if (isLogical(child)) {
LogicFilterImpl logicFilter = (LogicFilterImpl) child;
childNode = factory.createLogicNode(logicFilter);
List<?> children = logicFilter.getChildren();
for (Object c : children) {
createNode(childNode, (Filter) c);
}
} else if (isComparison(child)) {
AbstractComparisonNode comparisonNode = null;
if (LikeFilterImpl.class.isAssignableFrom(child.getClass())) {
LikeFilterImpl like = (LikeFilterImpl) child;
comparisonNode = factory.createComparisonNode(like);
comparisonNode.setLeft(getLeftContents((AttributeExpressionImpl) like.getExpression()));
LeafNode node = new LeafNode();
node.setLiteralValue(LiteralValue.getNew(like.getLiteral()));
comparisonNode.setRight(node);
} else {
CompareFilterImpl compare = (CompareFilterImpl) child;
comparisonNode = factory.createComparisonNode(compare);
comparisonNode.setLeft(getLeftContents((AttributeExpressionImpl) compare.getExpression1()));
comparisonNode.setRight(getRightContents(compare.getExpression2()));
}
childNode = comparisonNode;
} else if (isGeometric(child)) {
childNode = factory.createGeometricNode((GeometryFilterImpl) child);
}
if (parent != null) {
parent.addChild(childNode);
}
return childNode;
}
use of org.geotools.filter.CompareFilterImpl in project hale by halestudio.
the class CqlToMappingConditionTranslator method translate.
/**
* {@inheritDoc}
*/
@Override
public ModelMappingCondition translate(Filter source) throws TranslationException {
ModelMappingCondition filter = new ModelMappingCondition();
FilterNode root = null;
if (isLogical(source)) {
LogicFilterImpl logicFilter = (LogicFilterImpl) source;
root = factory.createLogicNode(logicFilter);
List<?> children = logicFilter.getChildren();
for (Object child : children) {
createNode(root, (Filter) child);
}
} else // if it's a comparison filter we assume we are at the start of the tree
if (isComparison(source)) {
CompareFilterImpl compare = (CompareFilterImpl) source;
AbstractComparisonNode cn = factory.createComparisonNode(compare);
cn.setLeft(getLeftContents((AttributeExpressionImpl) compare.getExpression1()));
cn.setRight(getRightContents(compare.getExpression2()));
root = cn;
} else // likewise if it's a geometric filter
if (isGeometric(source)) {
GeometryFilterImpl geometric = (GeometryFilterImpl) source;
AbstractGeometricNode gn = factory.createGeometricNode(geometric);
gn.setLeft(getLeftContents((AttributeExpressionImpl) geometric.getExpression1()));
gn.setRight(getRightContents(geometric.getExpression2()));
setGeometricOperationSpecifics(gn, geometric);
root = gn;
}
filter.setRoot(root);
return filter;
}
Aggregations