You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2018/05/05 16:20:56 UTC
svn commit: r1830990 - in /sis/branches/JDK8:
core/sis-feature/src/main/java/org/apache/sis/filter/
core/sis-feature/src/main/java/org/apache/sis/internal/feature/
core/sis-utility/src/main/java/org/apache/sis/util/
core/sis-utility/src/main/java/org/a...
Author: desruisseaux
Date: Sat May 5 16:20:55 2018
New Revision: 1830990
URL: http://svn.apache.org/viewvc?rev=1830990&view=rev
Log:
Make Expression/Filter implementations package-private.
The intent is to force the use of a FilterFactory, because those factories may be DataStore-specific.
Added:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractComparisonOperator.java
- copied, changed from r1830989, sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractBinaryComparisonOperator.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/package-info.java (with props)
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java
- copied, changed from r1830955, sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractExpression.java
Removed:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractBinaryComparisonOperator.java
Modified:
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/DefaultPropertyIsEqualTo.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultPropertyName.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultSortBy.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/package-info.java
sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/JoinFeatureSet.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SimpleQuery.java
sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/SimpleQueryTest.java
Copied: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractComparisonOperator.java (from r1830989, sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractBinaryComparisonOperator.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractComparisonOperator.java?p2=sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractComparisonOperator.java&p1=sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractBinaryComparisonOperator.java&r1=1830989&r2=1830990&rev=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractBinaryComparisonOperator.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractComparisonOperator.java [UTF-8] Sat May 5 16:20:55 2018
@@ -16,50 +16,103 @@
*/
package org.apache.sis.filter;
+import java.io.Serializable;
import org.opengis.filter.BinaryComparisonOperator;
import org.opengis.filter.MatchAction;
import org.opengis.filter.expression.Expression;
+
/**
+ * Base class for filters that compare exactly two values against each other.
+ * The nature of the comparison is dependent on the subclass.
*
- * @author Johann Sorel (Geomatys)
+ * @author Johann Sorel (Geomatys)
* @version 1.0
* @since 1.0
* @module
*/
-abstract class AbstractBinaryComparisonOperator implements BinaryComparisonOperator {
-
- protected final Expression exp1;
- protected final Expression exp2;
+abstract class AbstractComparisonOperator implements BinaryComparisonOperator, Serializable {
+ /**
+ * For cross-version compatibility.
+ */
+ private static final long serialVersionUID = -1401452229232869720L;
+
+ /**
+ * The first of the two expressions to be compared by this operator.
+ *
+ * @see #getExpression1()
+ */
+ protected final Expression expression1;
+
+ /**
+ * The second of the two expressions to be compared by this operator.
+ *
+ * @see #getExpression2()
+ */
+ protected final Expression expression2;
+
+ /**
+ * Whether comparisons are case sensitive.
+ *
+ * @see #isMatchingCase()
+ */
protected final boolean matchCase;
+
+ /**
+ * Specifies how the comparison predicate shall be evaluated for a collection of values.
+ *
+ * @see #getMatchAction()
+ */
protected final MatchAction matchAction;
- public AbstractBinaryComparisonOperator(Expression exp1, Expression exp2, boolean matchCase, MatchAction matchAction) {
- this.exp1 = exp1;
- this.exp2 = exp2;
- this.matchCase = matchCase;
+ /**
+ * Creates a new binary comparison operator.
+ */
+ AbstractComparisonOperator(final Expression expression1, final Expression expression2,
+ final boolean matchCase, final MatchAction matchAction)
+ {
+ this.expression1 = expression1;
+ this.expression2 = expression2;
+ this.matchCase = matchCase;
this.matchAction = matchAction;
}
+ /**
+ * Returns the first of the two expressions to be compared by this operator.
+ */
@Override
- public Expression getExpression1() {
- return exp1;
+ public final Expression getExpression1() {
+ return expression1;
}
+ /**
+ * Returns the second of the two expressions to be compared by this operator.
+ */
@Override
- public Expression getExpression2() {
- return exp2;
+ public final Expression getExpression2() {
+ return expression2;
}
+ /**
+ * Specifies whether comparisons are case sensitive.
+ *
+ * @return {@code true} if the comparisons are case sensitive, otherwise {@code false}.
+ */
@Override
- public boolean isMatchingCase() {
+ public final boolean isMatchingCase() {
return matchCase;
}
+ /**
+ * Specifies how the comparison predicate shall be evaluated for a collection of values.
+ * Values can be {@link MatchAction#ALL ALL} if all values in the collection shall satisfy the predicate,
+ * {@link MatchAction#ANY ANY} if any of the value in the collection can satisfy the predicate, or
+ * {@link MatchAction#ONE ONE} if only one of the values in the collection shall satisfy the predicate.
+ *
+ * @return how the comparison predicate shall be evaluated for a collection of values.
+ */
@Override
- public MatchAction getMatchAction() {
+ public final MatchAction getMatchAction() {
return matchAction;
}
-
-
}
Modified: 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=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractExpression.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractExpression.java [UTF-8] Sat May 5 16:20:55 2018
@@ -16,54 +16,50 @@
*/
package org.apache.sis.filter;
-import java.io.Serializable;
-import org.opengis.filter.expression.Expression;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.ObjectConverters;
import org.apache.sis.util.UnconvertibleObjectException;
+import org.apache.sis.internal.feature.FeatureExpression;
+
+// Branch-dependent imports
import org.opengis.feature.FeatureType;
-import org.opengis.feature.IdentifiedType;
-import org.opengis.feature.PropertyType;
+import org.opengis.filter.expression.Expression;
/**
- * Override evaluate(Object,Class) by using the converters system.
+ * Base class of Apache SIS implementation of OGC expressions operating on feature instances.
+ * This base class adds an additional method, {@link #expectedType(FeatureType)}, for fetching
+ * in advance the expected type of expression results.
*
* @author Johann Sorel (Geomatys)
- * @version 0.8
- * @since 0.8
+ * @version 1.0
+ * @since 1.0
* @module
*/
-public abstract class AbstractExpression implements Expression,Serializable {
+abstract class AbstractExpression implements Expression, FeatureExpression {
+ /**
+ * Creates a new expression.
+ */
+ protected AbstractExpression() {
+ }
+
/**
- * Use SIS object converters to convert the default result object
- * to the wished class.
+ * Evaluates the expression for producing a result of the given type.
+ * The default implementation evaluate the expression in the default
+ * way and attempt to convert the result.
*
- * @param candidate to evaluate
- * @param target wanted class
+ * @param feature to feature to evaluate with this expression.
+ * @param target the desired type for the expression result.
*/
@Override
- public <T> T evaluate(final Object candidate, final Class<T> target) {
+ public <T> T evaluate(final Object feature, final Class<T> target) {
ArgumentChecks.ensureNonNull("target", target);
- final Object value = evaluate(candidate);
+ final Object value = evaluate(feature);
try {
return ObjectConverters.convert(value, target);
} catch (UnconvertibleObjectException ex) {
+ // TODO: should report the exception somewhere.
return null;
}
}
-
- /**
- * Estimate the produced type of this expression when a feature will
- * be evaluated.
- * <p>
- * The resulting type must be static, an AttributeType or FeatureAssociationRole
- * but not an Operation.
- * </p>
- *
- * @param type expected evaluated feature type
- * @return expected expression result type
- */
- public abstract PropertyType expectedType(FeatureType type);
-
}
Modified: 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=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultFilterFactory.java [UTF-8] Sat May 5 16:20:55 2018
@@ -91,16 +91,20 @@ import org.opengis.filter.temporal.TOver
import org.opengis.geometry.Envelope;
import org.opengis.geometry.Geometry;
import org.opengis.util.GenericName;
+import org.apache.sis.util.ArgumentChecks;
+
/**
* Default implementation of GeoAPI filter factory.
*
* @author Johann Sorel (Geomatys)
- * @version 0.8
- * @since 0.8
+ * @version 1.0
+ * @since 1.0
* @module
*/
public class DefaultFilterFactory implements FilterFactory2 {
+ public DefaultFilterFactory() {
+ }
// SPATIAL FILTERS /////////////////////////////////////////////////////////
@@ -721,6 +725,7 @@ public class DefaultFilterFactory implem
*/
@Override
public Literal literal(final Object value) {
+ ArgumentChecks.ensureNonNull("value", value);
return new DefaultLiteral<>(value);
}
Modified: 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=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultLiteral.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultLiteral.java [UTF-8] Sat May 5 16:20:55 2018
@@ -16,97 +16,133 @@
*/
package org.apache.sis.filter;
-import java.util.Objects;
-import org.apache.sis.feature.builder.FeatureTypeBuilder;
-import org.opengis.feature.AttributeType;
+import java.util.Collections;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentHashMap;
+import java.io.Serializable;
+import org.opengis.util.LocalName;
import org.opengis.feature.FeatureType;
-import org.opengis.filter.expression.ExpressionVisitor;
+import org.opengis.feature.AttributeType;
import org.opengis.filter.expression.Literal;
+import org.opengis.filter.expression.ExpressionVisitor;
+import org.apache.sis.feature.DefaultAttributeType;
+import org.apache.sis.util.Classes;
+import org.apache.sis.util.iso.Names;
/**
- * Immutable literal expression.
+ * A constant, literal value that can be used in expressions.
+ * The {@link #evaluate(Object)} method ignore the argument and always returns {@link #getValue()}.
*
* @author Johann Sorel (Geomatys)
- * @version 0.8
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 1.0
*
- * @param <T> literal value type.
+ * @param <T> the literal value type.
*
- * @since 0.8
+ * @since 1.0
* @module
*/
-public class DefaultLiteral<T> extends AbstractExpression implements Literal {
-
+final class DefaultLiteral<T> extends AbstractExpression implements Literal, Serializable {
+ /**
+ * For cross-version compatibility.
+ */
private static final long serialVersionUID = 3240145927452086297L;
+ /**
+ * The name of attribute types associated with literals.
+ */
+ private static final LocalName NAME = Names.createLocalName(null, null, "Literal");
+
+ /**
+ * A cache of {@link AttributeType} instances for literal classes. Used for avoiding to create many duplicated
+ * instances for the common case where the literal is a very common type like {@link String} or {@link Integer}.
+ */
+ private static final ConcurrentMap<Class<?>, AttributeType<?>> TYPES = new ConcurrentHashMap<>();
+
+ /**
+ * The constant value to be returned by {@link #getValue()}.
+ */
private final T value;
- private final AttributeType<T> resultType;
/**
- *
- * @param value literal value
+ * Creates a new literal holding the given constant value.
+ * It is caller responsibility to ensure that the given argument is non-null.
*/
- public DefaultLiteral(final T value) {
+ DefaultLiteral(final T value) {
this.value = value;
- resultType = (AttributeType<T>) new FeatureTypeBuilder().addAttribute(value.getClass()).setName("Literal").build();
}
/**
- * {@inheritDoc }
+ * Returns the constant value held by this object.
*/
@Override
- public T evaluate(final Object candidate) {
+ public T getValue() {
return value;
}
/**
- * {@inheritDoc }
+ * Returns the constant value held by this object.
*/
@Override
- public AttributeType<T> expectedType(FeatureType type) {
- return resultType;
+ public T evaluate(Object ignored) {
+ return value;
}
/**
- * {@inheritDoc }
+ * Returns the type of values produced by this expression.
*/
@Override
- public Object accept(final ExpressionVisitor visitor, final Object extraData) {
- return visitor.visit(this, extraData);
+ public AttributeType<?> expectedType(FeatureType ignored) {
+ final Class<?> valueType = value.getClass();
+ AttributeType<?> type = TYPES.get(valueType);
+ if (type == null) {
+ final Class<?> standardType = Classes.getStandardType(valueType);
+ type = TYPES.computeIfAbsent(standardType, DefaultLiteral::newType);
+ if (valueType != standardType) {
+ TYPES.put(valueType, type);
+ }
+ }
+ return type;
}
/**
- * {@inheritDoc }
+ * Invoked when a new attribute type need to be created for the given standard type.
*/
- @Override
- public T getValue() {
- return value;
+ private static <T> AttributeType<T> newType(final Class<T> standardType) {
+ return new DefaultAttributeType<>(Collections.singletonMap(DefaultAttributeType.NAME_KEY, NAME),
+ standardType, 1, 1, null, (AttributeType<?>[]) null);
}
/**
- * {@inheritDoc }
+ * Accepts a visitor.
*/
@Override
- public String toString() {
- return String.valueOf(value);
+ public Object accept(final ExpressionVisitor visitor, final Object extraData) {
+ return visitor.visit(this, extraData);
}
/**
- * {@inheritDoc }
+ * Compares this literal with the given object for equality.
*/
@Override
public boolean equals(final Object obj) {
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
- return Objects.equals(value, ((DefaultLiteral<?>) obj).value);
+ return (obj instanceof Literal) && value.equals(((DefaultLiteral) obj).value);
}
/**
- * {@inheritDoc }
+ * Returns a hash-code value for this literal.
*/
@Override
public int hashCode() {
- return Objects.hashCode(value) + 3;
+ return value.hashCode() ^ (int) serialVersionUID;
+ }
+
+ /**
+ * Returns a string representation of this literal.
+ */
+ @Override
+ public String toString() {
+ return value.toString();
}
}
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultPropertyIsEqualTo.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultPropertyIsEqualTo.java?rev=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultPropertyIsEqualTo.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultPropertyIsEqualTo.java [UTF-8] Sat May 5 16:20:55 2018
@@ -30,9 +30,9 @@ import org.opengis.filter.expression.Exp
* @since 1.0
* @module
*/
-public class DefaultPropertyIsEqualTo extends AbstractBinaryComparisonOperator implements PropertyIsEqualTo {
+final class DefaultPropertyIsEqualTo extends AbstractComparisonOperator implements PropertyIsEqualTo {
- public DefaultPropertyIsEqualTo(Expression exp1, Expression exp2, boolean matchCase, MatchAction matchAction) {
+ DefaultPropertyIsEqualTo(Expression exp1, Expression exp2, boolean matchCase, MatchAction matchAction) {
super(exp1, exp2, matchCase, matchAction);
}
@@ -41,8 +41,8 @@ public class DefaultPropertyIsEqualTo ex
*/
@Override
public boolean evaluate(Object object) {
- final Object r1 = exp1.evaluate(object);
- final Object r2 = exp2.evaluate(object);
+ final Object r1 = expression1.evaluate(object);
+ final Object r2 = expression2.evaluate(object);
//TODO be more relax on equality testing, for example Date,TimeStamp,Instant or numerics
return Objects.equals(r1, r2);
}
@@ -54,5 +54,4 @@ public class DefaultPropertyIsEqualTo ex
public Object accept(FilterVisitor visitor, Object extraData) {
return visitor.visit(this, extraData);
}
-
}
Modified: 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=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultPropertyName.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultPropertyName.java [UTF-8] Sat May 5 16:20:55 2018
@@ -18,17 +18,18 @@ package org.apache.sis.filter;
import java.util.Map;
import java.util.Objects;
-import org.apache.sis.feature.builder.FeatureTypeBuilder;
+import java.io.Serializable;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.collection.BackingStoreException;
+import org.apache.sis.feature.builder.FeatureTypeBuilder;
// Branch-dependent imports
import org.opengis.feature.Feature;
import org.opengis.feature.FeatureType;
import org.opengis.feature.IdentifiedType;
import org.opengis.feature.Operation;
-import org.opengis.feature.PropertyNotFoundException;
import org.opengis.feature.PropertyType;
+import org.opengis.feature.PropertyNotFoundException;
import org.opengis.filter.expression.ExpressionVisitor;
import org.opengis.filter.expression.PropertyName;
@@ -39,12 +40,14 @@ import org.opengis.filter.expression.Pro
* property value of the evaluated feature.
*
* @author Johann Sorel (Geomatys)
- * @version 0.8
- * @since 0.8
+ * @version 1.0
+ * @since 1.0
* @module
*/
-public class DefaultPropertyName extends AbstractExpression implements PropertyName {
-
+final class DefaultPropertyName extends AbstractExpression implements PropertyName, Serializable {
+ /**
+ * For cross-version compatibility.
+ */
private static final long serialVersionUID = -8474562134021521300L;
private final String property;
@@ -53,7 +56,7 @@ public class DefaultPropertyName extends
*
* @param property attribute name
*/
- public DefaultPropertyName(final String property) {
+ DefaultPropertyName(final String property) {
ArgumentChecks.ensureNonNull("property", property);
this.property = property;
}
@@ -103,7 +106,7 @@ public class DefaultPropertyName extends
}
/**
- * {@inheritDoc }
+ * Accepts a visitor.
*/
@Override
public Object accept(final ExpressionVisitor visitor, final Object extraData) {
@@ -111,29 +114,26 @@ public class DefaultPropertyName extends
}
/**
- * {@inheritDoc }
+ * Returns a hash-code value for this property.
*/
@Override
- public String toString() {
- return '{' + property + '}';
+ public boolean equals(final Object obj) {
+ return (obj instanceof DefaultPropertyName) && property.equals(((DefaultPropertyName) obj).property);
}
/**
- * {@inheritDoc }
+ * Returns a hash-code value for this property.
*/
@Override
- public boolean equals(final Object obj) {
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
- return Objects.equals(property, ((DefaultPropertyName) obj).property);
+ public int hashCode() {
+ return Objects.hashCode(property) ^ (int) serialVersionUID;
}
/**
- * {@inheritDoc }
+ * Returns a string representation of this property.
*/
@Override
- public int hashCode() {
- return Objects.hashCode(property) + 7;
+ public String toString() {
+ return '{' + property + '}';
}
}
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultSortBy.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultSortBy.java?rev=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultSortBy.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/DefaultSortBy.java [UTF-8] Sat May 5 16:20:55 2018
@@ -16,36 +16,52 @@
*/
package org.apache.sis.filter;
-import java.util.Objects;
-import org.opengis.filter.expression.PropertyName;
+import java.io.Serializable;
+
+// Branch-dependent imports
import org.opengis.filter.sort.SortBy;
import org.opengis.filter.sort.SortOrder;
+import org.opengis.filter.expression.PropertyName;
+
/**
- * Immutable SortBy.
+ * Defines a sort order based on a property and ascending/descending order.
*
* @author Johann Sorel (Geomatys)
* @version 1.0
* @since 1.0
* @module
*/
-public class DefaultSortBy implements SortBy {
+final class DefaultSortBy implements SortBy, Serializable {
+ /**
+ * For cross-version compatibility.
+ */
+ private static final long serialVersionUID = 5434026034835575812L;
+ /**
+ * The property on which to apply sorting.
+ */
private final PropertyName property;
+
+ /**
+ * The desired order: {@code ASCENDING} or {@code DESCENDING}.
+ */
private final SortOrder order;
/**
+ * Creates a new {@code SortBy} filter.
+ * It is caller responsibility to ensure that no argument is null.
*
- * @param property sort by property applied on.
- * @param order sorting order
+ * @param property property on which to apply sorting.
+ * @param order the desired order: {@code ASCENDING} or {@code DESCENDING}.
*/
- public DefaultSortBy(PropertyName property, SortOrder order) {
+ DefaultSortBy(final PropertyName property, final SortOrder order) {
this.property = property;
- this.order = order;
+ this.order = order;
}
/**
- * {@inheritDoc }
+ * Returns the property to sort by.
*/
@Override
public PropertyName getPropertyName() {
@@ -53,37 +69,34 @@ public class DefaultSortBy implements So
}
/**
- * {@inheritDoc }
+ * Returns the sort order: {@code ASCENDING} or {@code DESCENDING}.
*/
@Override
public SortOrder getSortOrder() {
return order;
}
+ /**
+ * Computes a hash code value for this filter.
+ */
@Override
public int hashCode() {
- int hash = 7;
- hash = 41 * hash + Objects.hashCode(this.property);
- hash = 41 * hash + Objects.hashCode(this.order);
- return hash;
+ return property.hashCode() + 41 * order.hashCode();
}
+ /**
+ * Compares this filter with the given object for equality.
+ */
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
+ if (obj instanceof DefaultSortBy) {
+ final DefaultSortBy other = (DefaultSortBy) obj;
+ return property.equals(other.property)
+ && order.equals(other.order);
}
- final DefaultSortBy other = (DefaultSortBy) obj;
- if (!Objects.equals(this.property, other.property)) {
- return false;
- }
- return Objects.equals(this.order, other.order);
+ return false;
}
-
}
Added: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/package-info.java?rev=1830990&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/package-info.java (added)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/package-info.java [UTF-8] Sat May 5 16:20:55 2018
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+/**
+ * Filters features according their properties.
+ * A <cite>filter expression</cite> is a construct used to constraint a feature set to a subset.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 1.0
+ * @since 1.0
+ * @module
+ */
+package org.apache.sis.filter;
Propchange: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Copied: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java (from r1830955, 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/internal/feature/FeatureExpression.java?p2=sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java&p1=sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractExpression.java&r1=1830955&r2=1830990&rev=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/filter/AbstractExpression.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/FeatureExpression.java [UTF-8] Sat May 5 16:20:55 2018
@@ -14,56 +14,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.filter;
+package org.apache.sis.internal.feature;
-import java.io.Serializable;
-import org.opengis.filter.expression.Expression;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.ObjectConverters;
-import org.apache.sis.util.UnconvertibleObjectException;
+// Branch-dependent imports
import org.opengis.feature.FeatureType;
-import org.opengis.feature.IdentifiedType;
import org.opengis.feature.PropertyType;
/**
- * Override evaluate(Object,Class) by using the converters system.
+ * OGC expressions or other functions operating on feature instances.
+ * This interface adds an additional method, {@link #expectedType(FeatureType)},
+ * for fetching in advance the expected type of expression results.
*
* @author Johann Sorel (Geomatys)
- * @version 0.8
- * @since 0.8
+ * @version 1.0
+ * @since 1.0
* @module
*/
-public abstract class AbstractExpression implements Expression,Serializable {
+public interface FeatureExpression {
/**
- * Use SIS object converters to convert the default result object
- * to the wished class.
+ * Returns the expected type of values produced by this expression when a feature of the given
+ * type is evaluated. The resulting type shall describe a "static" property, i.e. it can be an
+ * {@link org.opengis.feature.AttributeType} or a {@link org.opengis.feature.FeatureAssociationRole}
+ * but not an {@link org.opengis.feature.Operation}.
*
- * @param candidate to evaluate
- * @param target wanted class
+ * @param type the type of features on which to apply this expression.
+ * @return expected expression result type.
*/
- @Override
- public <T> T evaluate(final Object candidate, final Class<T> target) {
- ArgumentChecks.ensureNonNull("target", target);
- final Object value = evaluate(candidate);
- try {
- return ObjectConverters.convert(value, target);
- } catch (UnconvertibleObjectException ex) {
- return null;
- }
- }
-
- /**
- * Estimate the produced type of this expression when a feature will
- * be evaluated.
- * <p>
- * The resulting type must be static, an AttributeType or FeatureAssociationRole
- * but not an Operation.
- * </p>
- *
- * @param type expected evaluated feature type
- * @return expected expression result type
- */
- public abstract PropertyType expectedType(FeatureType type);
-
+ PropertyType expectedType(FeatureType type);
}
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java?rev=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java [UTF-8] Sat May 5 16:20:55 2018
@@ -26,7 +26,7 @@
* may change in incompatible ways in any future version without notice.
*
* @author Johann Sorel (Geomatys)
- * @version 0.7
+ * @version 1.0
* @since 0.7
* @module
*/
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java?rev=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java [UTF-8] Sat May 5 16:20:55 2018
@@ -28,8 +28,11 @@ import java.lang.reflect.Method;
import java.lang.reflect.WildcardType;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Modifier;
+import org.opengis.annotation.UML;
import static org.apache.sis.util.collection.Containers.hashMapCapacity;
+import static org.apache.sis.internal.system.Modules.INTERNAL_CLASSNAME_PREFIX;
/**
@@ -50,7 +53,7 @@ import static org.apache.sis.util.collec
* </ul>
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 0.5
+ * @version 1.0
* @since 0.3
* @module
*/
@@ -274,6 +277,39 @@ public final class Classes extends Stati
}
/**
+ * Returns the first type or super-type (including interface) considered "standard" in Apache SIS sense.
+ * This method applies the following heuristic rules, in that order:
+ *
+ * <ul>
+ * <li>If the given type implements at least one interface having the {@link UML} annotation,
+ * then the first annotated interface is returned.</li>
+ * <li>Otherwise the first public class or parent class is returned.</li>
+ * </ul>
+ *
+ * Those heuristic rules may be adjusted in any future Apache SIS version.
+ *
+ * @param <T> the compile-time type argument.
+ * @param type the type for which to get the standard interface or class. May be {@code null}.
+ * @return a standard interface implemented by {@code type}, or otherwise the most specific public class.
+ * Is {@code null} if the given {@code type} argument was null.
+ *
+ * @since 1.0
+ */
+ public static <T> Class<? super T> getStandardType(final Class<T> type) {
+ for (final Class<? super T> candidate : getAllInterfaces(type)) {
+ if (candidate.isAnnotationPresent(UML.class)) {
+ return candidate;
+ }
+ }
+ for (Class<? super T> candidate = type; candidate != null; candidate = candidate.getSuperclass()) {
+ if (Modifier.isPublic(candidate.getModifiers()) && !candidate.getName().startsWith(INTERNAL_CLASSNAME_PREFIX)) {
+ return candidate;
+ }
+ }
+ return type;
+ }
+
+ /**
* Returns every interfaces implemented, directly or indirectly, by the given class or interface.
* This is similar to {@link Class#getInterfaces()} except that this method searches recursively
* in the super-interfaces. For example if the given type is {@link java.util.ArrayList}, then
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java?rev=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java [UTF-8] Sat May 5 16:20:55 2018
@@ -58,7 +58,7 @@ import org.apache.sis.internal.util.Unmo
* from multiple threads.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
*
* @param <S> the type of the source of warnings.
*
@@ -278,7 +278,7 @@ public class WarningListeners<S> impleme
*/
static boolean isPublic(final StackTraceElement e) {
final String classname = e.getClassName();
- if (classname.startsWith("java") || classname.contains(".internal.") ||
+ if (classname.startsWith("java") || classname.startsWith(Modules.INTERNAL_CLASSNAME_PREFIX) ||
classname.indexOf('$') >= 0 || e.getMethodName().indexOf('$') >= 0)
{
return false;
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/package-info.java?rev=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/package-info.java [UTF-8] Sat May 5 16:20:55 2018
@@ -38,7 +38,7 @@
* </ul>
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java?rev=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/ClassesTest.java [UTF-8] Sat May 5 16:20:55 2018
@@ -56,7 +56,7 @@ import org.opengis.referencing.operation
* Tests the {@link Classes} static methods.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.5
+ * @version 1.0
* @since 0.3
* @module
*/
@@ -124,6 +124,18 @@ public final strictfp class ClassesTest
private abstract static class T3 extends T2 implements Transformation {}
/**
+ * Tests {@link Classes#getStandardType(Class)}.
+ */
+ @Test
+ public void testGetStandardType() {
+ assertEquals(GeographicCRS.class, Classes.getStandardType(T1.class));
+ assertEquals(SingleCRS.class, Classes.getStandardType(T2.class));
+ assertEquals(Transformation.class, Classes.getStandardType(T3.class));
+ assertEquals(String.class, Classes.getStandardType(String.class));
+ assertEquals(CharSequence.class, Classes.getStandardType(CharSequence.class));
+ }
+
+ /**
* Tests {@link Classes#findCommonClass(Iterable)}
* and {@link Classes#findSpecializedClass(Iterable)}.
*/
Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/JoinFeatureSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/JoinFeatureSet.java?rev=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/JoinFeatureSet.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/JoinFeatureSet.java [UTF-8] Sat May 5 16:20:55 2018
@@ -23,8 +23,7 @@ import java.util.Spliterators;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import org.apache.sis.feature.builder.FeatureTypeBuilder;
-import org.apache.sis.filter.DefaultLiteral;
-import org.apache.sis.filter.DefaultPropertyIsEqualTo;
+import org.apache.sis.filter.DefaultFilterFactory;
import org.apache.sis.internal.feature.AttributeConvention;
import org.apache.sis.internal.storage.query.SimpleQuery;
import org.apache.sis.metadata.iso.DefaultMetadata;
@@ -39,6 +38,7 @@ import org.apache.sis.util.iso.SimpleInt
import org.apache.sis.util.logging.WarningListeners;
import org.opengis.feature.Feature;
import org.opengis.feature.FeatureType;
+import org.opengis.filter.FilterFactory;
import org.opengis.filter.MatchAction;
import org.opengis.filter.PropertyIsEqualTo;
import org.opengis.filter.expression.Expression;
@@ -60,7 +60,6 @@ import org.opengis.util.GenericName;
* @module
*/
public class JoinFeatureSet extends AbstractFeatureSet implements FeatureSet {
-
/**
* Join operation type.
*/
@@ -88,12 +87,15 @@ public class JoinFeatureSet extends Abst
private final Type joinType;
private final PropertyIsEqualTo condition;
+ private final FilterFactory factory;
+
//cache
private FeatureType type;
public JoinFeatureSet(final WarningListeners<DataStore> listeners, FeatureSet left,
- String leftAlias, FeatureSet right, String rightAlias, Type joinType, PropertyIsEqualTo condition) {
+ String leftAlias, FeatureSet right, String rightAlias, Type joinType, PropertyIsEqualTo condition)
+ {
super(listeners);
this.left = left;
this.right = right;
@@ -101,6 +103,7 @@ public class JoinFeatureSet extends Abst
this.rightAlias = rightAlias;
this.joinType = joinType;
this.condition = condition;
+ factory = new DefaultFilterFactory();
}
/**
@@ -156,7 +159,6 @@ public class JoinFeatureSet extends Abst
ftb.setName(leftName.tip().toString() + '-' + rightName.tip().toString());
type = ftb.build();
}
-
return type;
}
@@ -222,7 +224,6 @@ public class JoinFeatureSet extends Abst
id += right.getPropertyValue(AttributeConvention.IDENTIFIER_PROPERTY.toString());
f.setPropertyValue(rightAlias,right);
}
-
f.setPropertyValue(AttributeConvention.IDENTIFIER_PROPERTY.toString(), id);
return f;
}
@@ -295,31 +296,25 @@ public class JoinFeatureSet extends Abst
combined = toFeature(leftFeature, rightRes);
}
}
-
if (rightIterator != null && !rightIterator.hasNext()){
//no more results in right iterator, close iterator
rightStream.close();
rightStream = null;
rightIterator = null;
}
-
while (combined == null && leftIterator.hasNext()) {
leftFeature = leftIterator.next();
-
final Object leftValue = leftProperty.evaluate(leftFeature);
-
if (rightIterator == null) {
final SimpleQuery rightQuery = new SimpleQuery();
- rightQuery.setFilter(new DefaultPropertyIsEqualTo(rightProperty, new DefaultLiteral<>(leftValue), true, MatchAction.ALL));
+ rightQuery.setFilter(factory.equal(rightProperty, factory.literal(leftValue), true, MatchAction.ALL));
rightStream = right.subset(rightQuery).features(false);
rightIterator = rightStream.iterator();
}
-
while (combined == null && rightIterator.hasNext()) {
final Feature rightRow = rightIterator.next();
combined = toFeature(leftFeature, rightRow);
}
-
if (combined == null) {
//no more results in right iterator, close iterator
rightStream.close();
@@ -327,9 +322,7 @@ public class JoinFeatureSet extends Abst
rightIterator = null;
}
}
-
}
-
}
/**
@@ -354,7 +347,6 @@ public class JoinFeatureSet extends Abst
primeStream = right.features(false);
}
primeIterator = primeStream.iterator();
-
}
@Override
@@ -401,41 +393,35 @@ public class JoinFeatureSet extends Abst
nextFeature = checkValid(primeFeature, secondCandidate, leftJoint);
}
}
-
while (nextFeature == null && primeIterator.hasNext()) {
primeFeature = primeIterator.next();
-
if (secondIterator != null) {
secondStream.close();
secondStream = null;
secondIterator = null;
}
-
final Object primeValue;
if (leftJoint) {
primeValue = leftProperty.evaluate(primeFeature);
} else {
primeValue = rightProperty.evaluate(primeFeature);
}
-
if (secondIterator == null) {
final SimpleQuery query = new SimpleQuery();
if (leftJoint) {
- query.setFilter(new DefaultPropertyIsEqualTo(rightProperty, new DefaultLiteral<>(primeValue), true, MatchAction.ALL));
+ query.setFilter(factory.equal(rightProperty, factory.literal(primeValue), true, MatchAction.ALL));
secondStream = right.subset(query).features(false);
secondIterator = secondStream.iterator();
} else {
- query.setFilter(new DefaultPropertyIsEqualTo(leftProperty, new DefaultLiteral<>(primeValue), true, MatchAction.ALL));
+ query.setFilter(factory.equal(leftProperty, factory.literal(primeValue), true, MatchAction.ALL));
secondStream = left.subset(query).features(false);
secondIterator = secondStream.iterator();
}
}
-
while (nextFeature == null && secondIterator.hasNext()) {
final Feature rightRow = secondIterator.next();
nextFeature = checkValid(primeFeature, rightRow,leftJoint);
}
-
if (nextFeature == null) {
//outer left effect, no right match but still we must return the left side
if (leftJoint) {
@@ -444,9 +430,7 @@ public class JoinFeatureSet extends Abst
nextFeature = toFeature(null,primeFeature);
}
}
-
}
-
}
private Feature checkValid(final Feature left, final Feature right, final boolean leftJoin) throws DataStoreException{
@@ -456,10 +440,7 @@ public class JoinFeatureSet extends Abst
} else {
candidate = toFeature(right,left);
}
-
return candidate;
}
-
}
-
}
Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SimpleQuery.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SimpleQuery.java?rev=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SimpleQuery.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/query/SimpleQuery.java [UTF-8] Sat May 5 16:20:55 2018
@@ -21,22 +21,21 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import org.apache.sis.feature.builder.FeatureTypeBuilder;
-import org.apache.sis.filter.AbstractExpression;
-import org.apache.sis.storage.FeatureSet;
-import org.apache.sis.storage.Query;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.collection.BackingStoreException;
-import org.apache.sis.util.iso.Names;
import org.opengis.feature.AttributeType;
import org.opengis.feature.FeatureAssociationRole;
import org.opengis.feature.FeatureType;
-import org.opengis.feature.IdentifiedType;
import org.opengis.feature.PropertyType;
import org.opengis.filter.Filter;
import org.opengis.filter.expression.Expression;
import org.opengis.filter.sort.SortBy;
import org.opengis.util.GenericName;
+import org.apache.sis.feature.builder.FeatureTypeBuilder;
+import org.apache.sis.internal.feature.FeatureExpression;
+import org.apache.sis.storage.FeatureSet;
+import org.apache.sis.storage.Query;
+import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.collection.BackingStoreException;
+import org.apache.sis.util.iso.Names;
/**
* A simple query mimics SQL SELECT using OGC Filter and Expressions.
@@ -251,12 +250,11 @@ public class SimpleQuery implements Quer
*/
public PropertyType expectedType(FeatureType type) {
PropertyType resultType;
- if (expression instanceof AbstractExpression) {
- resultType = ((AbstractExpression) expression).expectedType(type);
+ if (expression instanceof FeatureExpression) {
+ resultType = ((FeatureExpression) expression).expectedType(type);
} else {
resultType = expression.evaluate(type, PropertyType.class);
}
-
if (alias != null) {
//rename result type
if (resultType instanceof AttributeType) {
@@ -267,7 +265,6 @@ public class SimpleQuery implements Quer
throw new BackingStoreException("Expression "+expression+" returned an unexpected property type result "+resultType);
}
}
-
return resultType;
}
@@ -299,7 +296,6 @@ public class SimpleQuery implements Quer
}
return true;
}
-
}
/**
@@ -339,7 +335,6 @@ public class SimpleQuery implements Quer
for (Column col : columns) {
ftb.addProperty(col.expectedType(source));
}
-
return ftb.build();
}
}
Modified: sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/SimpleQueryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/SimpleQueryTest.java?rev=1830990&r1=1830989&r2=1830990&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/SimpleQueryTest.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/query/SimpleQueryTest.java [UTF-8] Sat May 5 16:20:55 2018
@@ -19,10 +19,7 @@ package org.apache.sis.internal.storage.
import java.util.Arrays;
import java.util.stream.Collectors;
import org.apache.sis.feature.builder.FeatureTypeBuilder;
-import org.apache.sis.filter.DefaultLiteral;
-import org.apache.sis.filter.DefaultPropertyIsEqualTo;
-import org.apache.sis.filter.DefaultPropertyName;
-import org.apache.sis.filter.DefaultSortBy;
+import org.apache.sis.filter.DefaultFilterFactory;
import org.apache.sis.internal.storage.MemoryFeatureSet;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.FeatureSet;
@@ -120,11 +117,12 @@ public class SimpleQueryTest extends Tes
*/
@Test
public void testSortBy() throws DataStoreException {
+ final DefaultFilterFactory factory = new DefaultFilterFactory();
final SimpleQuery query = new SimpleQuery();
query.setSortBy(
- new DefaultSortBy(new DefaultPropertyName("value1"), SortOrder.ASCENDING),
- new DefaultSortBy(new DefaultPropertyName("value2"), SortOrder.DESCENDING)
+ factory.sort("value1", SortOrder.ASCENDING),
+ factory.sort("value2", SortOrder.DESCENDING)
);
final FeatureSet fs = SimpleQuery.executeOnCPU(FEATURESET, query);
@@ -144,9 +142,10 @@ public class SimpleQueryTest extends Tes
*/
@Test
public void testFilter() throws DataStoreException {
+ final DefaultFilterFactory factory = new DefaultFilterFactory();
final SimpleQuery query = new SimpleQuery();
- query.setFilter(new DefaultPropertyIsEqualTo(new DefaultPropertyName("value1"), new DefaultLiteral(2), true, MatchAction.ALL));
+ query.setFilter(factory.equal(factory.property("value1"), factory.literal(2), true, MatchAction.ALL));
final FeatureSet fs = SimpleQuery.executeOnCPU(FEATURESET, query);
final Feature[] result = fs.features(false).collect(Collectors.toList()).toArray(new Feature[0]);
@@ -162,12 +161,13 @@ public class SimpleQueryTest extends Tes
*/
@Test
public void testColumns() throws DataStoreException {
+ final DefaultFilterFactory factory = new DefaultFilterFactory();
final SimpleQuery query = new SimpleQuery();
query.setColumns(Arrays.asList(
- new SimpleQuery.Column(new DefaultPropertyName("value1"), (String)null),
- new SimpleQuery.Column(new DefaultPropertyName("value1"), "renamed1"),
- new SimpleQuery.Column(new DefaultLiteral<>("a literal"), "computed")
+ new SimpleQuery.Column(factory.property("value1"), (String)null),
+ new SimpleQuery.Column(factory.property("value1"), "renamed1"),
+ new SimpleQuery.Column(factory.literal("a literal"), "computed")
));
query.setLimit(1);
@@ -195,7 +195,5 @@ public class SimpleQueryTest extends Tes
assertEquals(3, result.getPropertyValue("value1"));
assertEquals(3, result.getPropertyValue("renamed1"));
assertEquals("a literal", result.getPropertyValue("computed"));
-
-
}
}