Class Node

java.lang.Object
org.apache.sis.internal.filter.Node
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BinaryFunction, FilterNode, GeometryConverter, LeafExpression, SpatialFunction, UnaryFunction

public abstract class Node extends Object implements Serializable
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 Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • SCOPE

      private static final org.opengis.util.LocalName SCOPE
      Scope of all names defined by SIS convention.
      See Also:
  • Constructor Details

    • Node

      protected Node()
      Creates a new expression, operator or filter.
  • Method Details

    • createType

      protected static <T> DefaultAttributeType<T> createType(Class<T> type, Object name)
      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 of type.
      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

      private Object 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 implements Expression.
      • CodeList if this node implements Filter.
      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 the equals(Object) and hashCode() methods.
      Returns:
      the name of this function.
    • createName

      protected static org.opengis.util.ScopedName createName(String tip)
      Creates a name in the "SIS" scope. This is a helper method for #getFunctionName() implementations.
      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

      protected static <R, G> Expression<? super R,?> unwrap(Expression<R,GeometryWrapper<G>> expression)
      If the given exception was wrapped by toGeometryWrapper(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

      protected static <G> Geometries<G> getGeometryLibrary(Expression<?,GeometryWrapper<G>> expression)
      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

      protected abstract Collection<?> 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

      private void toTree(TreeTable.Node root, Map<Object,Boolean> visited)
      Builds a tree representation of this node, including all children. This method expects an initially empty node, which will be set to the name of this node. Then all children will be appended recursively, with a check against cyclic graph.
      Parameters:
      root - where to create a tree representation of this node.
      visited - nodes already visited. This method will write in this map.
    • toString

      public final String 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.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this filter.
    • hashCode

      public int hashCode()
      Returns a hash code value computed from the class and the children.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Returns true if the given object is an instance of the same class with the equal children.
      Overrides:
      equals in class Object
      Parameters:
      other - the other object to compare with this node.
      Returns:
      whether the two object are equal.
    • warning

      protected final void warning(Exception e, boolean recoverable)
      Reports that an operation failed because of the given exception. This method assumes that the warning occurred in a test(…) or apply(…) method.
      Parameters:
      e - the exception that occurred.
      recoverable - true if the caller has been able to fallback on a default value, or false if the caller has to return null.
      See Also: