use of org.n52.shetland.ogc.filter.ComparisonFilter in project arctic-sea by 52North.
the class ODataFesParserTest method testEndswith.
@Test
public void testEndswith() throws DecodingException {
Filter<?> filter = parser.decode("endswith(textValue,'asdf')");
assertThat(filter, is(instanceOf(ComparisonFilter.class)));
ComparisonFilter cf = (ComparisonFilter) filter;
errors.checkThat(cf.getOperator(), is(ComparisonOperator.PropertyIsLike));
errors.checkThat(cf.getValue(), is("%asdf"));
errors.checkThat(cf.getValueReference(), is("om:result"));
}
use of org.n52.shetland.ogc.filter.ComparisonFilter in project arctic-sea by 52North.
the class ODataFesParserTest method testStartswith.
@Test
public void testStartswith() throws DecodingException {
Filter<?> filter = parser.decode("startswith(textValue,'asdf')");
assertThat(filter, is(instanceOf(ComparisonFilter.class)));
ComparisonFilter cf = (ComparisonFilter) filter;
errors.checkThat(cf.getOperator(), is(ComparisonOperator.PropertyIsLike));
errors.checkThat(cf.getValue(), is("asdf%"));
errors.checkThat(cf.getValueReference(), is("om:result"));
}
use of org.n52.shetland.ogc.filter.ComparisonFilter in project arctic-sea by 52North.
the class FesDecoderv20 method parsePropertyIsBetweenFilter.
/**
* Parse XML propertyIsBetween element
*
* @param comparisonOpsType
* XML propertyIsBetween element
* @return SOS comparison filter
* @throws DecodingException
* If an error occurs of the filter is not supported
*/
private ComparisonFilter parsePropertyIsBetweenFilter(PropertyIsBetweenType comparisonOpsType) throws DecodingException {
ComparisonFilter comparisonFilter = new ComparisonFilter();
comparisonFilter.setOperator(ComparisonOperator.PropertyIsBetween);
try {
comparisonFilter.setValueReference(parseValueReference(comparisonOpsType.getExpression()));
} catch (XmlException xmle) {
throw valueReferenceParsingException(xmle);
}
if (comparisonOpsType.getLowerBoundary().getExpression() instanceof LiteralType) {
comparisonFilter.setValue(parseLiteralValue((LiteralType) comparisonOpsType.getLowerBoundary().getExpression()));
}
if (comparisonOpsType.getUpperBoundary().getExpression() instanceof LiteralType) {
comparisonFilter.setValueUpper(parseLiteralValue((LiteralType) comparisonOpsType.getUpperBoundary().getExpression()));
}
return comparisonFilter;
}
use of org.n52.shetland.ogc.filter.ComparisonFilter in project arctic-sea by 52North.
the class FesDecoderv20 method parseBinaryComparisonFilter.
private ComparisonFilter parseBinaryComparisonFilter(BinaryComparisonOpType comparisonOpsType) throws DecodingException {
ComparisonFilter comparisonFilter = new ComparisonFilter();
String localName = XmlHelper.getLocalName(comparisonOpsType);
if (ComparisonOperator.PropertyIsEqualTo.name().equals(localName)) {
comparisonFilter.setOperator(ComparisonOperator.PropertyIsEqualTo);
} else if (ComparisonOperator.PropertyIsNotEqualTo.name().equals(localName)) {
comparisonFilter.setOperator(ComparisonOperator.PropertyIsNotEqualTo);
} else if (ComparisonOperator.PropertyIsLessThan.name().equals(localName)) {
comparisonFilter.setOperator(ComparisonOperator.PropertyIsLessThan);
} else if (ComparisonOperator.PropertyIsGreaterThan.name().equals(localName)) {
comparisonFilter.setOperator(ComparisonOperator.PropertyIsGreaterThan);
} else if (ComparisonOperator.PropertyIsLessThanOrEqualTo.name().equals(localName)) {
comparisonFilter.setOperator(ComparisonOperator.PropertyIsLessThanOrEqualTo);
} else if (ComparisonOperator.PropertyIsGreaterThanOrEqualTo.name().equals(localName)) {
comparisonFilter.setOperator(ComparisonOperator.PropertyIsGreaterThanOrEqualTo);
} else {
throw new UnsupportedDecoderXmlInputException(this, comparisonOpsType);
}
if (comparisonOpsType.isSetMatchCase()) {
comparisonFilter.setMatchCase(comparisonOpsType.getMatchCase());
}
parseExpressions(comparisonOpsType.getExpressionArray(), comparisonFilter);
return comparisonFilter;
}
use of org.n52.shetland.ogc.filter.ComparisonFilter in project arctic-sea by 52North.
the class ComparisonFilterTest method testCopyOf_like.
@Test
public void testCopyOf_like() throws OwsExceptionReport {
ComparisonFilter original = new ComparisonFilter(FilterConstants.ComparisonOperator.PropertyIsLike, "vr", "val", "up", "escape");
original.setMatchCase(false);
original.setSingleChar("single");
original.setWildCard("wild");
ComparisonFilter copy = original.copy();
Assert.assertThat(copy.getEscapeString(), is(original.getEscapeString()));
Assert.assertThat(copy.getSingleChar(), is(original.getSingleChar()));
Assert.assertThat(copy.getValue(), is(original.getValue()));
Assert.assertThat(copy.getValueReference(), is(original.getValueReference()));
Assert.assertThat(copy.getValueUpper(), is(original.getValueUpper()));
Assert.assertThat(copy.getWildCard(), is(original.getWildCard()));
Assert.assertThat(copy, is(not(original)));
Assert.assertThat("copy is not equal to original, equal to is not implemented", not(copy.equals(original)));
}
Aggregations