Author: jsorel
Date: Tue Apr 12 13:13:18 2016
New Revision: 1738798
URL: http://svn.apache.org/viewvc?rev=1738798&view=rev
Log:
Implement Literal and PropertyName expressions
Added:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractExpression.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultLiteral.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultPropertyName.java
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/filter/
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultLiteralTest.java
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultPropertyNameTest.java
Modified:
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
Added:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractExpression.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractExpression.java?rev=1738798&view=auto
==============================================================================
---
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractExpression.java
(added)
+++
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractExpression.java
Tue Apr 12 13:13:18 2016
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import java.io.Serializable;
+
+import org.apache.sis.util.ObjectConverters;
+
+import org.apache.sis.util.UnconvertibleObjectException;
+import org.opengis.filter.expression.Expression;
+
+/**
+ * Override evaluate(Object,Class) by using the converters system.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @since 0.7
+ * @version 0.7
+ * @module
+ */
+public abstract class AbstractExpression implements Expression,Serializable {
+
+ /**
+ * Use SIS object converters to convert the default result object
+ * to the wished class.
+ *
+ * @param candidate to evaluate
+ * @param target wanted class
+ */
+ @Override
+ public <T> T evaluate(final Object candidate, final Class<T> target) {
+ final Object value = evaluate(candidate);
+ if (target == null) {
+ return (T) value;
+ }
+ try{
+ return ObjectConverters.convert(value, target);
+ }catch (UnconvertibleObjectException ex){
+ return null;
+ }
+ }
+
+}
Added:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java?rev=1738798&view=auto
==============================================================================
---
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
(added)
+++
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java
Tue Apr 12 13:13:18 2016
@@ -0,0 +1,900 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import java.util.List;
+import java.util.Set;
+import org.opengis.filter.And;
+import org.opengis.filter.Filter;
+import org.opengis.filter.FilterFactory2;
+import org.opengis.filter.Id;
+import org.opengis.filter.MatchAction;
+import org.opengis.filter.Not;
+import org.opengis.filter.Or;
+import org.opengis.filter.PropertyIsBetween;
+import org.opengis.filter.PropertyIsEqualTo;
+import org.opengis.filter.PropertyIsGreaterThan;
+import org.opengis.filter.PropertyIsGreaterThanOrEqualTo;
+import org.opengis.filter.PropertyIsLessThan;
+import org.opengis.filter.PropertyIsLessThanOrEqualTo;
+import org.opengis.filter.PropertyIsLike;
+import org.opengis.filter.PropertyIsNil;
+import org.opengis.filter.PropertyIsNotEqualTo;
+import org.opengis.filter.PropertyIsNull;
+import org.opengis.filter.capability.ArithmeticOperators;
+import org.opengis.filter.capability.ComparisonOperators;
+import org.opengis.filter.capability.FilterCapabilities;
+import org.opengis.filter.capability.FunctionName;
+import org.opengis.filter.capability.Functions;
+import org.opengis.filter.capability.GeometryOperand;
+import org.opengis.filter.capability.IdCapabilities;
+import org.opengis.filter.capability.Operator;
+import org.opengis.filter.capability.ScalarCapabilities;
+import org.opengis.filter.capability.SpatialCapabilities;
+import org.opengis.filter.capability.SpatialOperator;
+import org.opengis.filter.capability.SpatialOperators;
+import org.opengis.filter.capability.TemporalCapabilities;
+import org.opengis.filter.capability.TemporalOperand;
+import org.opengis.filter.capability.TemporalOperators;
+import org.opengis.filter.expression.Add;
+import org.opengis.filter.expression.Divide;
+import org.opengis.filter.expression.Expression;
+import org.opengis.filter.expression.Function;
+import org.opengis.filter.expression.Literal;
+import org.opengis.filter.expression.Multiply;
+import org.opengis.filter.expression.PropertyName;
+import org.opengis.filter.expression.Subtract;
+import org.opengis.filter.identity.FeatureId;
+import org.opengis.filter.identity.GmlObjectId;
+import org.opengis.filter.identity.Identifier;
+import org.opengis.filter.sort.SortBy;
+import org.opengis.filter.sort.SortOrder;
+import org.opengis.filter.spatial.BBOX;
+import org.opengis.filter.spatial.Beyond;
+import org.opengis.filter.spatial.Contains;
+import org.opengis.filter.spatial.Crosses;
+import org.opengis.filter.spatial.DWithin;
+import org.opengis.filter.spatial.Disjoint;
+import org.opengis.filter.spatial.Equals;
+import org.opengis.filter.spatial.Intersects;
+import org.opengis.filter.spatial.Overlaps;
+import org.opengis.filter.spatial.Touches;
+import org.opengis.filter.spatial.Within;
+import org.opengis.filter.temporal.After;
+import org.opengis.filter.temporal.AnyInteracts;
+import org.opengis.filter.temporal.Before;
+import org.opengis.filter.temporal.Begins;
+import org.opengis.filter.temporal.BegunBy;
+import org.opengis.filter.temporal.During;
+import org.opengis.filter.temporal.EndedBy;
+import org.opengis.filter.temporal.Ends;
+import org.opengis.filter.temporal.Meets;
+import org.opengis.filter.temporal.MetBy;
+import org.opengis.filter.temporal.OverlappedBy;
+import org.opengis.filter.temporal.TContains;
+import org.opengis.filter.temporal.TEquals;
+import org.opengis.filter.temporal.TOverlaps;
+import org.opengis.geometry.Envelope;
+import org.opengis.geometry.Geometry;
+import org.opengis.util.GenericName;
+
+/**
+ * Default implementation of GeoAPI filter factory.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @since 0.7
+ * @version 0.7
+ * @module
+ */
+public class DefaultFilterFactory implements FilterFactory2 {
+
+ // SPATIAL FILTERS
/////////////////////////////////////////////////////////
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public BBOX bbox(final String propertyName, final double minx,
+ final double miny, final double maxx, final double maxy, final
String srs) {
+ return bbox(property(propertyName), minx, miny, maxx, maxy, srs);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public BBOX bbox(final Expression e, final double minx, final double miny,
+ final double maxx, final double maxy, final String srs) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public BBOX bbox(final Expression e, final Envelope bounds) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Beyond beyond(final String propertyName, final Geometry geometry,
+ final double distance, final String units) {
+ final PropertyName name = property(propertyName);
+ final Literal geom = literal(geometry);
+ return beyond(name, geom, distance, units);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Beyond beyond(final Expression left, final Expression right,
+ final double distance, final String units) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Contains contains(final String propertyName, final Geometry
geometry) {
+ final PropertyName name = property(propertyName);
+ final Literal geom = literal(geometry);
+ return contains(name, geom);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Contains contains(final Expression left, final Expression right) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Crosses crosses(final String propertyName, final Geometry geometry)
{
+ final PropertyName name = property(propertyName);
+ final Literal geom = literal(geometry);
+ return crosses(name, geom);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Crosses crosses(final Expression left, final Expression right) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Disjoint disjoint(final String propertyName, final Geometry
geometry) {
+ final PropertyName name = property(propertyName);
+ final Literal geom = literal(geometry);
+ return disjoint(name, geom);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Disjoint disjoint(final Expression left, final Expression right) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public DWithin dwithin(final String propertyName, final Geometry geometry,
+ final double distance, final String units) {
+ final PropertyName name = property(propertyName);
+ final Literal geom = literal(geometry);
+ return dwithin(name, geom, distance, units);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public DWithin dwithin(final Expression left, final Expression right,
+ final double distance, final String units) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Equals equals(final String propertyName, final Geometry geometry) {
+ final PropertyName name = property(propertyName);
+ final Literal geom = literal(geometry);
+ return equal(name, geom);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Equals equal(final Expression left, final Expression right) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Intersects intersects(final String propertyName, final Geometry
geometry) {
+ final PropertyName name = property(propertyName);
+ final Literal geom = literal(geometry);
+ return intersects(name, geom);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Intersects intersects(final Expression left, final Expression
right) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Overlaps overlaps(final String propertyName, final Geometry
geometry) {
+ final PropertyName name = property(propertyName);
+ final Literal geom = literal(geometry);
+ return overlaps(name, geom);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Overlaps overlaps(final Expression left, final Expression right) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Touches touches(final String propertyName, final Geometry geometry)
{
+ final PropertyName name = property(propertyName);
+ final Literal geom = literal(geometry);
+ return touches(name, geom);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Touches touches(final Expression left, final Expression right) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Within within(final String propertyName, final Geometry geometry) {
+ final PropertyName name = property(propertyName);
+ final Literal geom = literal(geometry);
+ return within(name, geom);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Within within(final Expression left, final Expression right) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ // IDENTIFIERS
/////////////////////////////////////////////////////////////
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public FeatureId featureId(final String id) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public GmlObjectId gmlObjectId(final String id) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ // FILTERS
/////////////////////////////////////////////////////////////////
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public And and(final Filter filter1, final Filter filter2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public And and(final List<Filter> filters) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Or or(final Filter filter1, final Filter filter2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Or or(final List<Filter> filters) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Not not(final Filter filter) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Id id(final Set<? extends Identifier> ids) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyName property(final GenericName name) {
+ return property(name.toString());
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyName property(final String name) {
+ return new DefaultPropertyName(name);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsBetween between(final Expression expr,
+ final Expression lower, final Expression upper) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsEqualTo equals(final Expression expr1, final Expression
expr2) {
+ return equal(expr1, expr2, true, MatchAction.ANY);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsEqualTo equal(final Expression expr1,
+ final Expression expr2, final boolean matchCase, MatchAction
matchAction) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsNotEqualTo notEqual(final Expression expr1, final
Expression expr2) {
+ return notEqual(expr1, expr2,false, MatchAction.ANY);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsNotEqualTo notEqual(final Expression expr1,
+ final Expression expr2, final boolean matchCase, final MatchAction
matchAction) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsGreaterThan greater(final Expression expr1,
+ final Expression expr2) {
+ return greater(expr1,expr2,false, MatchAction.ANY);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsGreaterThan greater(final Expression expr1,
+ final Expression expr2, final boolean matchCase, final MatchAction
matchAction) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsGreaterThanOrEqualTo greaterOrEqual(
+ final Expression expr1, final Expression expr2) {
+ return greaterOrEqual(expr1, expr2,false, MatchAction.ANY);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsGreaterThanOrEqualTo greaterOrEqual(
+ final Expression expr1, final Expression expr2, final boolean
matchCase, final MatchAction matchAction) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsLessThan less(final Expression expr1, final Expression
expr2) {
+ return less(expr1, expr2, false, MatchAction.ANY);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsLessThan less(final Expression expr1,
+ final Expression expr2, final boolean matchCase, MatchAction
matchAction) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsLessThanOrEqualTo lessOrEqual(
+ final Expression expr1, final Expression expr2) {
+ return lessOrEqual(expr1, expr2, false, MatchAction.ANY);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsLessThanOrEqualTo lessOrEqual(final Expression expr1,
+ final Expression expr2, final boolean matchCase, final MatchAction
matchAction) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsLike like(final Expression expr, final String pattern) {
+ return like(expr, pattern, "*", "?", "\\");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsLike like(final Expression expr, final String pattern,
+ final String wildcard, final String singleChar, final String
escape) {
+ return like(expr,pattern,wildcard,singleChar,escape,false);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsLike like(final Expression expr, final String pattern,
+ final String wildcard, final String singleChar,
+ final String escape, final boolean matchCase) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsNull isNull(final Expression expr) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public PropertyIsNil isNil(Expression expr) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ // TEMPORAL FILTER
/////////////////////////////////////////////////////////
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public After after(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public AnyInteracts anyInteracts(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Before before(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Begins begins(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public BegunBy begunBy(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public During during(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Ends ends(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public EndedBy endedBy(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Meets meets(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public MetBy metBy(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public OverlappedBy overlappedBy(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public TContains tcontains(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public TEquals tequals(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public TOverlaps toverlaps(Expression expr1, Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ // EXPRESSIONS
/////////////////////////////////////////////////////////////
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Add add(final Expression expr1, final Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Divide divide(final Expression expr1, final Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Multiply multiply(final Expression expr1, final Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Subtract subtract(final Expression expr1, final Expression expr2) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Function function(final String name, final Expression ...
parameters) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Literal literal(final Object value) {
+ return new DefaultLiteral(value);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Literal literal(final byte value) {
+ return new DefaultLiteral(value);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Literal literal(final short value) {
+ return new DefaultLiteral(value);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Literal literal(final int value) {
+ return new DefaultLiteral(value);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Literal literal(final long value) {
+ return new DefaultLiteral(value);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Literal literal(final float value) {
+ return new DefaultLiteral(value);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Literal literal(final double value) {
+ return new DefaultLiteral(value);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Literal literal(final char value) {
+ return new DefaultLiteral(value);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Literal literal(final boolean value) {
+ return new DefaultLiteral(value);
+ }
+
+ // SORT BY
/////////////////////////////////////////////////////////////////
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public SortBy sort(final String propertyName, final SortOrder order) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ // CAPABILITIES
////////////////////////////////////////////////////////////
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Operator operator(final String name) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public SpatialOperator spatialOperator(final String name,
+ final GeometryOperand[] geometryOperands) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public FunctionName functionName(final String name, final int nargs) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Functions functions(final FunctionName[] functionNames) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public SpatialOperators spatialOperators(final SpatialOperator[]
spatialOperators) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public ComparisonOperators comparisonOperators(final Operator[]
comparisonOperators) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public ArithmeticOperators arithmeticOperators(final boolean simple,
+ final Functions functions) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public ScalarCapabilities scalarCapabilities(final ComparisonOperators
comparison,
+ final ArithmeticOperators arithmetic, final boolean logical) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public SpatialCapabilities spatialCapabilities(
+ final GeometryOperand[] geometryOperands, final SpatialOperators
spatial) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public IdCapabilities idCapabilities(final boolean eid, final boolean fid)
{
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public FilterCapabilities capabilities(final String version,
+ final ScalarCapabilities scalar, final SpatialCapabilities spatial,
+ final TemporalCapabilities temporal, final IdCapabilities id) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public TemporalCapabilities temporalCapabilities(TemporalOperand[]
temporalOperands, TemporalOperators temporal) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+}
Added:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultLiteral.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultLiteral.java?rev=1738798&view=auto
==============================================================================
---
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultLiteral.java
(added)
+++
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultLiteral.java
Tue Apr 12 13:13:18 2016
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import org.apache.sis.util.ObjectConverters;
+import org.apache.sis.util.UnconvertibleObjectException;
+import org.opengis.filter.expression.ExpressionVisitor;
+import org.opengis.filter.expression.Literal;
+
+/**
+ * Immutable literal expression.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @param <T> literal value type
+ * @since 0.7
+ * @version 0.7
+ * @module
+ */
+public class DefaultLiteral<T> extends AbstractExpression implements Literal {
+
+ private static final long serialVersionUID = 3240145927452086297L;
+
+ private final T value;
+
+ /**
+ *
+ * @param value literal value
+ */
+ public DefaultLiteral(final T value) {
+ this.value = value;
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public T evaluate(final Object candidate) {
+ return value;
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Object accept(final ExpressionVisitor visitor, final Object
extraData) {
+ return visitor.visit(this, extraData);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public T getValue() {
+ return value;
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public String toString() {
+ return value == null ? "NULL" : value.toString();
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final DefaultLiteral<T> other = (DefaultLiteral<T>) obj;
+
+ if (this.value == null && other.value == null) {
+ return true;
+ }
+ if (this.value == null) {
+ return false;
+ }
+ if (other.value == null) {
+ return false;
+ }
+
+ final Object otherVal;
+ try{
+ otherVal = ObjectConverters.convert(other.value,
this.value.getClass());
+ }catch(UnconvertibleObjectException ex){
+ //type can not be matched
+ return false;
+ }
+ return this.value.equals(otherVal);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public int hashCode() {
+ int hash = 3;
+ hash = 89 * hash + (this.value != null ? this.value.hashCode() : 0);
+ return hash;
+ }
+
+}
Added:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultPropertyName.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultPropertyName.java?rev=1738798&view=auto
==============================================================================
---
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultPropertyName.java
(added)
+++
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultPropertyName.java
Tue Apr 12 13:13:18 2016
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import java.util.Map;
+import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
+import org.opengis.feature.Feature;
+import org.opengis.feature.PropertyNotFoundException;
+import org.opengis.filter.expression.ExpressionVisitor;
+import org.opengis.filter.expression.PropertyName;
+
+/**
+ * Immutable property name expression.
+ * A property name does not store any value, it acts as an indirection to a
+ * property value of the evaluated feature.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @since 0.7
+ * @version 0.7
+ * @module
+ */
+public class DefaultPropertyName extends AbstractExpression implements
PropertyName {
+
+ private static final long serialVersionUID = -8474562134021521300L;
+
+ private final String property;
+
+ /**
+ *
+ * @param property attribute name
+ */
+ public DefaultPropertyName(final String property) {
+ ensureNonNull("property name", property);
+ this.property = property;
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public String getPropertyName() {
+ return property;
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Object evaluate(final Object candidate) {
+
+ if(candidate instanceof Feature){
+ try{
+ return ((Feature) candidate).getPropertyValue(property);
+ }catch(PropertyNotFoundException ex){
+ return null;
+ }
+ }else if(candidate instanceof Map){
+ return ((Map) candidate).get(property);
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Object accept(final ExpressionVisitor visitor, final Object
extraData) {
+ return visitor.visit(this, extraData);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public String toString() {
+ return "{"+property+"}";
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final DefaultPropertyName other = (DefaultPropertyName) obj;
+ if ((this.property == null) ? (other.property != null) :
!this.property.equals(other.property)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 73 * hash + (this.property != null ? this.property.hashCode() :
0);
+ return hash;
+ }
+}
Added:
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultLiteralTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultLiteralTest.java?rev=1738798&view=auto
==============================================================================
---
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultLiteralTest.java
(added)
+++
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultLiteralTest.java
Tue Apr 12 13:13:18 2016
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import java.util.Date;
+import static org.apache.sis.test.Assert.*;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+import org.opengis.filter.FilterFactory2;
+import org.opengis.filter.expression.Literal;
+
+/**
+ * Tests {@link DefaultLiteral}.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @since 0.7
+ * @version 0.7
+ * @module
+ */
+public class DefaultLiteralTest extends TestCase {
+
+ /**
+ * Test factory.
+ */
+ @Test
+ public void testConstructor() {
+ final FilterFactory2 FF = new DefaultFilterFactory();
+
+ assertNotNull(FF.literal(true));
+ assertNotNull(FF.literal("a text string"));
+ assertNotNull(FF.literal('x'));
+ assertNotNull(FF.literal(122));
+ assertNotNull(FF.literal(45.56d));
+ }
+
+ /**
+ * Tests value and evaluation.
+ */
+ @Test
+ public void testEvaluate() {
+
+ final Literal literal = new DefaultLiteral(12.45);
+ assertEquals(12.45, (Double)literal.getValue(), STRICT);
+ assertEquals(12.45, (Double)literal.evaluate(null), STRICT);
+ assertEquals(12.45, literal.evaluate(null,Double.class), STRICT);
+ assertEquals("12.45", literal.evaluate(null,String.class));
+ assertEquals(null, literal.evaluate(null,Date.class));
+ }
+
+ /**
+ * Tests serialization.
+ */
+ @Test
+ public void testSerialize() {
+
+ assertSerializedEquals(new DefaultLiteral(true));
+ assertSerializedEquals(new DefaultLiteral("a text string"));
+ assertSerializedEquals(new DefaultLiteral('x'));
+ assertSerializedEquals(new DefaultLiteral(122));
+ assertSerializedEquals(new DefaultLiteral(45.56d));
+ }
+
+}
Added:
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultPropertyNameTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultPropertyNameTest.java?rev=1738798&view=auto
==============================================================================
---
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultPropertyNameTest.java
(added)
+++
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/filter/DefaultPropertyNameTest.java
Tue Apr 12 13:13:18 2016
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.filter;
+
+import java.util.HashMap;
+import java.util.Map;
+import static org.apache.sis.test.Assert.*;
+import org.apache.sis.test.TestCase;
+import org.apache.sis.util.iso.Names;
+import org.junit.Test;
+import org.opengis.filter.FilterFactory2;
+import org.opengis.filter.expression.PropertyName;
+
+/**
+ * Tests {@link DefaultPropertyName}.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @since 0.7
+ * @version 0.7
+ * @module
+ */
+public class DefaultPropertyNameTest extends TestCase {
+
+ /**
+ * Test factory.
+ */
+ @Test
+ public void testConstructor() {
+ final FilterFactory2 FF = new DefaultFilterFactory();
+
+ assertNotNull(FF.property(Names.parseGenericName(null, ":", "type")));
+ assertNotNull(FF.property("type"));
+ }
+
+ /**
+ * Tests evaluation.
+ */
+ @Test
+ public void testEvaluate() {
+ final Map candidate = new HashMap();
+
+ final PropertyName prop = new DefaultPropertyName("type");
+ assertEquals("type", prop.getPropertyName());
+
+ assertEquals(null, prop.evaluate(candidate));
+ assertEquals(null, prop.evaluate(null));
+
+ candidate.put("type", "road");
+ assertEquals("road", prop.evaluate(candidate));
+ assertEquals("road", prop.evaluate(candidate,String.class));
+
+ candidate.put("type", "45.1");
+ assertEquals("45.1", prop.evaluate(candidate));
+ assertEquals("45.1", prop.evaluate(candidate,null));
+ assertEquals("45.1", prop.evaluate(candidate,String.class));
+ assertEquals(45.1, prop.evaluate(candidate,Double.class), STRICT);
+
+ }
+
+ /**
+ * Tests serialization.
+ */
+ @Test
+ public void testSerialize() {
+ assertSerializedEquals(new DefaultPropertyName("type"));
+ }
+
+}
+
Modified:
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java?rev=1738798&r1=1738797&r2=1738798&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
[UTF-8] Tue Apr 12 13:13:18 2016
@@ -47,6 +47,8 @@ import org.junit.BeforeClass;
org.apache.sis.feature.BoundsOperationTest.class,
org.apache.sis.feature.FeatureFormatTest.class,
org.apache.sis.feature.FeaturesTest.class,
+ org.apache.sis.filter.DefaultLiteralTest.class,
+ org.apache.sis.filter.DefaultPropertyNameTest.class,
org.apache.sis.internal.feature.AttributeConventionTest.class,
org.apache.sis.internal.feature.FeatureTypeBuilderTest.class,
org.apache.sis.internal.feature.AttributeTypeBuilderTest.class