Class BaseGeometryFunction
- java.lang.Object
-
- org.locationtech.jtstest.geomfunction.BaseGeometryFunction
-
- All Implemented Interfaces:
java.lang.Comparable
,GeometryFunction
- Direct Known Subclasses:
StaticMethodGeometryFunction
public abstract class BaseGeometryFunction extends java.lang.Object implements GeometryFunction, java.lang.Comparable
A base for implementations ofGeometryFunction
which provides most of the required structure. Extenders must supply the behaviour for the actual function invocation.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
category
protected java.lang.String
description
protected java.lang.String
name
protected java.lang.String[]
parameterNames
protected java.lang.Class[]
parameterTypes
protected java.lang.Class
returnType
-
Constructor Summary
Constructors Constructor Description BaseGeometryFunction(java.lang.String category, java.lang.String name, java.lang.String[] parameterNames, java.lang.Class[] parameterTypes, java.lang.Class returnType)
BaseGeometryFunction(java.lang.String category, java.lang.String name, java.lang.String description, java.lang.String[] parameterNames, java.lang.Class[] parameterTypes, java.lang.Class returnType)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private static int
compareTo(java.lang.Class c1, java.lang.Class c2)
int
compareTo(java.lang.Object o)
boolean
equals(java.lang.Object obj)
Two functions are the same if they have the same signature (name, parameter types and return type).static int
firstScalarParamIndex(GeometryFunction func)
java.lang.String
getCategory()
Gets the category name of this functionjava.lang.String
getDescription()
Gets the description of this functionprotected static java.lang.Double
getDoubleOrNull(java.lang.Object[] args, int index)
protected static java.lang.Integer
getIntegerOrNull(java.lang.Object[] args, int index)
java.lang.String
getName()
Gets the name of this functionjava.lang.String[]
getParameterNames()
Gets the parameter names for this functionjava.lang.Class[]
getParameterTypes()
Gets the types of the other function arguments, if any.java.lang.Class
getReturnType()
Gets the return type of this functionjava.lang.String
getSignature()
Gets a string representing the signature of this function.abstract java.lang.Object
invoke(Geometry geom, java.lang.Object[] args)
Invokes this function.boolean
isBinary()
static boolean
isBinaryGeomFunction(GeometryFunction func)
-
-
-
Field Detail
-
category
protected java.lang.String category
-
name
protected java.lang.String name
-
description
protected java.lang.String description
-
parameterNames
protected java.lang.String[] parameterNames
-
parameterTypes
protected java.lang.Class[] parameterTypes
-
returnType
protected java.lang.Class returnType
-
-
Constructor Detail
-
BaseGeometryFunction
public BaseGeometryFunction(java.lang.String category, java.lang.String name, java.lang.String[] parameterNames, java.lang.Class[] parameterTypes, java.lang.Class returnType)
-
BaseGeometryFunction
public BaseGeometryFunction(java.lang.String category, java.lang.String name, java.lang.String description, java.lang.String[] parameterNames, java.lang.Class[] parameterTypes, java.lang.Class returnType)
-
-
Method Detail
-
isBinaryGeomFunction
public static boolean isBinaryGeomFunction(GeometryFunction func)
-
firstScalarParamIndex
public static int firstScalarParamIndex(GeometryFunction func)
-
getCategory
public java.lang.String getCategory()
Description copied from interface:GeometryFunction
Gets the category name of this function- Specified by:
getCategory
in interfaceGeometryFunction
- Returns:
- the category name of the function
-
getName
public java.lang.String getName()
Description copied from interface:GeometryFunction
Gets the name of this function- Specified by:
getName
in interfaceGeometryFunction
- Returns:
- the name of the function
-
getDescription
public java.lang.String getDescription()
Description copied from interface:GeometryFunction
Gets the description of this function- Specified by:
getDescription
in interfaceGeometryFunction
- Returns:
- the name of the function
-
getParameterNames
public java.lang.String[] getParameterNames()
Description copied from interface:GeometryFunction
Gets the parameter names for this function- Specified by:
getParameterNames
in interfaceGeometryFunction
- Returns:
- the names of the function parameters
-
getParameterTypes
public java.lang.Class[] getParameterTypes()
Gets the types of the other function arguments, if any.- Specified by:
getParameterTypes
in interfaceGeometryFunction
- Returns:
- the types
-
getReturnType
public java.lang.Class getReturnType()
Description copied from interface:GeometryFunction
Gets the return type of this function- Specified by:
getReturnType
in interfaceGeometryFunction
- Returns:
- the type of the value returned by this function
-
isBinary
public boolean isBinary()
- Specified by:
isBinary
in interfaceGeometryFunction
-
getSignature
public java.lang.String getSignature()
Description copied from interface:GeometryFunction
Gets a string representing the signature of this function.- Specified by:
getSignature
in interfaceGeometryFunction
- Returns:
- the string for the function signature
-
getDoubleOrNull
protected static java.lang.Double getDoubleOrNull(java.lang.Object[] args, int index)
-
getIntegerOrNull
protected static java.lang.Integer getIntegerOrNull(java.lang.Object[] args, int index)
-
invoke
public abstract java.lang.Object invoke(Geometry geom, java.lang.Object[] args)
Description copied from interface:GeometryFunction
Invokes this function. Note that any exceptions returned must beRuntimeException
s.- Specified by:
invoke
in interfaceGeometryFunction
- Parameters:
geom
- the target geometryargs
- the other arguments to the function- Returns:
- the value computed by the function
-
equals
public boolean equals(java.lang.Object obj)
Two functions are the same if they have the same signature (name, parameter types and return type).- Specified by:
equals
in interfaceGeometryFunction
- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
-- Returns:
- true if this object is the same as the obj argument
-
compareTo
public int compareTo(java.lang.Object o)
- Specified by:
compareTo
in interfacejava.lang.Comparable
-
compareTo
private static int compareTo(java.lang.Class c1, java.lang.Class c2)
-
-