Package org.apache.sis.internal.filter
Class Node
java.lang.Object
org.apache.sis.internal.filter.Node
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
BinaryFunction
,FilterNode
,GeometryConverter
,LeafExpression
,SpatialFunction
,UnaryFunction
Base class of Apache SIS implementation of OGC expressions, comparators or filters.
Node
instances are associated together in a tree, which can be formatted
by toString()
.- Since:
- 1.1
- Version:
- 1.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.opengis.util.LocalName
Scope of all names defined by SIS convention.private static final long
For cross-version compatibility. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static org.opengis.util.ScopedName
createName
(String tip) Creates a name in the "SIS" scope.protected static <T> DefaultAttributeType
<T> createType
(Class<T> type, Object name) Creates an attribute type for values of the given type and name.boolean
Returnstrue
if the given object is an instance of the same class with the equal children.protected abstract Collection
<?> Returns the children of this node, or an empty collection if none.private Object
Returns the name of the function or filter to be called.protected static <G> Geometries
<G> getGeometryLibrary
(Expression<?, GeometryWrapper<G>> expression) Returns a handler for the library of geometric objects used by the given expression.int
hashCode()
Returns a hash code value computed from the class and the children.protected char
symbol()
Returns the mathematical symbol for this binary function.protected static <R,
G> Expression <R, GeometryWrapper<G>> toGeometryWrapper
(Geometries<G> library, Expression<R, ?> expression) Returns an expression whose results is a geometry wrapper.final String
toString()
Returns a string representation of this node.private void
toTree
(TreeTable.Node root, Map<Object, Boolean> visited) Builds a tree representation of this node, including all children.protected static <R,
G> Expression <? super R, ?> unwrap
(Expression<R, GeometryWrapper<G>> expression) If the given exception was wrapped bytoGeometryWrapper(Geometries, Expression)
, returns the original expression.protected final void
Reports that an operation failed because of the given exception.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
SCOPE
private static final org.opengis.util.LocalName SCOPEScope of all names defined by SIS convention.- See Also:
-
-
Constructor Details
-
Node
protected Node()Creates a new expression, operator or filter.
-
-
Method Details
-
createType
Creates an attribute type for values of the given type and name. The attribute is mandatory, unbounded and has no default value.- Type Parameters:
T
- compile-time value oftype
.- Parameters:
type
- type of values in the attribute.name
- name of the attribute to create.- Returns:
- an attribute of the given type and name.
- See Also:
-
symbol
protected char symbol()Returns the mathematical symbol for this binary function. For comparison operators, the symbol should be one of < > ≤ ≥ = ≠. For arithmetic operators, the symbol should be one of + − × ÷.- Returns:
- the mathematical symbol, or 0 if none.
-
getDisplayName
Returns the name of the function or filter to be called. For example, this might be"sis:cos"
or"sis:atan2"
. The type depend on the implemented interface:ScopedName
if this node implementsExpression
.CodeList
if this node implementsFilter
.
Note for implementers: implementations typically return a hard-coded value. If the returned value may vary for the same class, then implementers should override also theequals(Object)
andhashCode()
methods.- Returns:
- the name of this function.
-
createName
Creates a name in the "SIS" scope. This is a helper method forinvalid reference
#getFunctionName()
- Parameters:
tip
- the expression name in SIS namespace.- Returns:
- an expression name in the SIS namespace.
-
toGeometryWrapper
protected static <R,G> Expression<R,GeometryWrapper<G>> toGeometryWrapper(Geometries<G> library, Expression<R, ?> expression) Returns an expression whose results is a geometry wrapper.- Type Parameters:
R
- the type of resources (e.g.Feature
) used as inputs.G
- the geometry implementation type.- Parameters:
library
- the geometry library to use.expression
- the expression providing source values.- Returns:
- an expression whose results is a geometry wrapper.
- Throws:
IllegalArgumentException
- if the given expression is already a wrapper but for another geometry implementation.
-
unwrap
If the given exception was wrapped bytoGeometryWrapper(Geometries, Expression)
, returns the original expression. Otherwise returns the given expression.- Type Parameters:
R
- the type of resources (e.g.Feature
) used as inputs.G
- the geometry implementation type.- Parameters:
expression
- the expression to unwrap.- Returns:
- the unwrapped expression.
-
getGeometryLibrary
Returns a handler for the library of geometric objects used by the given expression. The given expression should be the first parameter (as requested by SQLMM specification), otherwise the error message will not be accurate.- Type Parameters:
G
- the type of geometry created by the expression.- Parameters:
expression
- the expression for which to get the geometry library.- Returns:
- the geometry library (never
null
).
-
getChildren
Returns the children of this node, or an empty collection if none. This is used for information purpose, for example in order to build a string representation.- Returns:
- the children of this node, or an empty collection if none.
-
toTree
Builds a tree representation of this node, including all children. This method expects an initially empty node, which will be set to theinvalid reference
name
- Parameters:
root
- where to create a tree representation of this node.visited
- nodes already visited. This method will write in this map.
-
toString
Returns a string representation of this node. This representation can be printed to the standard output stream (for example) if it uses a monospaced font and supports Unicode. -
hashCode
public int hashCode()Returns a hash code value computed from the class and the children. -
equals
Returnstrue
if the given object is an instance of the same class with the equal children. -
warning
Reports that an operation failed because of the given exception. This method assumes that the warning occurred in atest(…)
orapply(…)
method.- Parameters:
e
- the exception that occurred.recoverable
-true
if the caller has been able to fallback on a default value, orfalse
if the caller has to returnnull
.- See Also:
-