Class AbstractFunction
- java.lang.Object
-
- com.complexible.stardog.plan.filter.AbstractExpression
-
- com.complexible.stardog.plan.filter.functions.AbstractFunction
-
- All Implemented Interfaces:
Copyable<com.complexible.stardog.plan.filter.Expression>,com.complexible.stardog.plan.filter.Expression,Function
public abstract class AbstractFunction extends com.complexible.stardog.plan.filter.AbstractExpression implements Function
Abstract stub implementation of a Function. Checks that the arguments to the function meet the expected number of arguments before evaluating the function.
- Since:
- 0.1
- Version:
- 6.0
- Author:
- Michael Grove
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractFunction(int theNumReqArgs, java.lang.String... theURIs)protectedAbstractFunction(AbstractFunction theFunction)protectedAbstractFunction(com.google.common.collect.Range<java.lang.Integer> theNumReqArgs, java.lang.String... theURIs)protectedAbstractFunction(java.util.List<com.complexible.stardog.plan.filter.Expression> theExpressions, int theNumReqArgs, java.lang.String... theURIs)Create a new AbstractFunctionprotectedAbstractFunction(java.util.List<com.complexible.stardog.plan.filter.Expression> theExpressions, com.google.common.collect.Range<java.lang.Integer> theRange, java.lang.String... theURIs)Create a new AbstractFunction
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static booleanassertArrayLiteral(Value theValue)Assert that the literal is an array literal.protected booleanassertBNode(Value theValue)Assert that the value is a BNodeprotected booleanassertDecimalLiteral(Value theValue)Assert that the literal is a decimal literal.static booleanassertIntegerLiteral(Value theValue)Assert that the literal is an integer literal.protected booleanassertIRI(Value theValue)Assert that the value is a URIstatic booleanassertLiteral(Value theValue)Assert that the value is a literalprotected booleanassertLiteral(Value theValue, java.util.function.Predicate<Datatype> theDatatypeChecker)protected booleanassertNumericLiteral(Value theValue)Assert that the literal is a numeric literalstatic booleanassertPathLiteral(Value theValue)protected booleanassertRequiredArgs(int theArgs)Validate that the arguments passed to the function match the expected numberprotected booleanassertSimpleLiteral(Value theValue)Assert that the value is a simple literalprotected booleanassertStatement(Value theValue)Assert that the value is aStatementstatic booleanassertStringLiteral(Value theValue)Assert that the value is a String literalprotected booleanassertTypedLiteral(Value theValue, Datatype theDatatype)Assert that the literal has the provided datatypebooleanequals(java.lang.Object o)com.complexible.stardog.plan.filter.expr.ValueOrErrorevaluate(com.complexible.stardog.plan.filter.expr.ValueOrError... theValues)Directly evaluate the function for the given argumentscom.complexible.stardog.plan.filter.expr.ValueOrErrorevaluate(com.complexible.stardog.plan.filter.ValueSolution theArgs)com.complexible.stardog.plan.filter.expr.ValueOrErrorevaluate(Value... theValues)Directly evaluate the function for the given argumentsjava.lang.StringgetName()Return the string that uniquely identifies thisExpression, which should be a fully qualified URI.java.util.List<java.lang.String>getNames()Return all the strings that uniquely identifies thisFunction.com.google.common.collect.Range<java.lang.Integer>getRequiredArgCount()inthashCode()protected abstract com.complexible.stardog.plan.filter.expr.ValueOrErrorinternalEvaluate(Value... theArgs)Evaluate the functionvoidsetArgs(java.util.List<com.complexible.stardog.plan.filter.Expression> theArgs)java.lang.StringtoString()-
Methods inherited from class com.complexible.stardog.plan.filter.AbstractExpression
getArg, getArgs, getArgsCount, getFirstArg, getSecondArg, getThirdArg, replaceArg
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.complexible.stardog.plan.filter.Expression
accept, couldRaiseError, getArgs, getCategory, replaceArg
-
Methods inherited from interface com.complexible.stardog.plan.filter.functions.Function
copy, getDescription, initialize, isDeterministic
-
-
-
-
Constructor Detail
-
AbstractFunction
protected AbstractFunction(int theNumReqArgs, java.lang.String... theURIs)
-
AbstractFunction
protected AbstractFunction(com.google.common.collect.Range<java.lang.Integer> theNumReqArgs, java.lang.String... theURIs)
-
AbstractFunction
protected AbstractFunction(java.util.List<com.complexible.stardog.plan.filter.Expression> theExpressions, int theNumReqArgs, java.lang.String... theURIs)Create a new AbstractFunction- Parameters:
theNumReqArgs- the number of required arguments.theURIs- the URIs of the function. These are the URI's which identify this function in a SPARQL query.
-
AbstractFunction
protected AbstractFunction(java.util.List<com.complexible.stardog.plan.filter.Expression> theExpressions, com.google.common.collect.Range<java.lang.Integer> theRange, java.lang.String... theURIs)Create a new AbstractFunction- Parameters:
theRange- the range of valid #'s of arguments to the function.theURIs- the URIs of the function. These are the URI's which identify this function in a SPARQL query.
-
AbstractFunction
protected AbstractFunction(AbstractFunction theFunction)
-
-
Method Detail
-
setArgs
public void setArgs(java.util.List<com.complexible.stardog.plan.filter.Expression> theArgs)
- Specified by:
setArgsin interfacecom.complexible.stardog.plan.filter.Expression- Overrides:
setArgsin classcom.complexible.stardog.plan.filter.AbstractExpression
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classcom.complexible.stardog.plan.filter.AbstractExpression
-
hashCode
public int hashCode()
- Overrides:
hashCodein classcom.complexible.stardog.plan.filter.AbstractExpression
-
toString
public java.lang.String toString()
- Overrides:
toStringin classcom.complexible.stardog.plan.filter.AbstractExpression
-
getName
public final java.lang.String getName()
Return the string that uniquely identifies thisExpression, which should be a fully qualified URI. This URI is what is used to reference thisExpressionin a SPARQL query.
-
getNames
public final java.util.List<java.lang.String> getNames()
Return all the strings that uniquely identifies thisFunction. A function may have different names in different namespaces.- Specified by:
getNamesin interfaceFunction- Returns:
- all aliases of this
Function - See Also:
Function.getName()
-
getRequiredArgCount
public com.google.common.collect.Range<java.lang.Integer> getRequiredArgCount()
-
evaluate
public final com.complexible.stardog.plan.filter.expr.ValueOrError evaluate(com.complexible.stardog.plan.filter.ValueSolution theArgs)
- Specified by:
evaluatein interfacecom.complexible.stardog.plan.filter.Expression
-
evaluate
public com.complexible.stardog.plan.filter.expr.ValueOrError evaluate(com.complexible.stardog.plan.filter.expr.ValueOrError... theValues)
Directly evaluate the function for the given arguments- Parameters:
theValues- the arguments to the function- Returns:
- the return value of the function
-
evaluate
public com.complexible.stardog.plan.filter.expr.ValueOrError evaluate(Value... theValues)
Directly evaluate the function for the given arguments- Parameters:
theValues- the arguments to the function- Returns:
- the return value of the function
-
internalEvaluate
protected abstract com.complexible.stardog.plan.filter.expr.ValueOrError internalEvaluate(Value... theArgs)
Evaluate the function- Parameters:
theArgs- the arguments to the function- Returns:
- the return value of the function
-
assertRequiredArgs
protected boolean assertRequiredArgs(int theArgs)
Validate that the arguments passed to the function match the expected number- Parameters:
theArgs- the arguments to validate
-
assertIRI
protected final boolean assertIRI(Value theValue)
Assert that the value is a URI- Parameters:
theValue- the value- Returns:
- true iff the value as a URI
-
assertStatement
protected final boolean assertStatement(Value theValue)
Assert that the value is aStatement- Parameters:
theValue- the value- Returns:
- true iff the value as a statement
-
assertBNode
protected final boolean assertBNode(Value theValue)
Assert that the value is a BNode- Parameters:
theValue- the value- Returns:
- true iff the value is a BNode
-
assertLiteral
public static final boolean assertLiteral(Value theValue)
Assert that the value is a literal- Parameters:
theValue- the value- Returns:
- true iff the value is a Literal
-
assertStringLiteral
public static final boolean assertStringLiteral(Value theValue)
Assert that the value is a String literal- Parameters:
theValue- the value- Returns:
- true if the value is a String literal
-
assertTypedLiteral
protected final boolean assertTypedLiteral(Value theValue, Datatype theDatatype)
Assert that the literal has the provided datatype- Parameters:
theValue- the value- Returns:
- true if the value has the provided datatype
-
assertNumericLiteral
protected final boolean assertNumericLiteral(Value theValue)
Assert that the literal is a numeric literal- Parameters:
theValue- the value- Returns:
- true if the value is a numeric literall
-
assertDecimalLiteral
protected final boolean assertDecimalLiteral(Value theValue)
Assert that the literal is a decimal literal. The datatype of the literal should be xsd:decimal or another type derived from xsd:decimal.- Parameters:
theValue- the value- Returns:
- true if the value is a decimal literal
-
assertIntegerLiteral
public static final boolean assertIntegerLiteral(Value theValue)
Assert that the literal is an integer literal. The datatype of the literal should be xsd:integer or another type derived from xsd:integer.- Parameters:
theValue- the value- Returns:
- true if the value is a integer literal
-
assertArrayLiteral
public static final boolean assertArrayLiteral(Value theValue)
Assert that the literal is an array literal.- Parameters:
theValue- the value- Returns:
- true if the value is a array literal
-
assertPathLiteral
public static final boolean assertPathLiteral(Value theValue)
-
assertSimpleLiteral
protected final boolean assertSimpleLiteral(Value theValue)
Assert that the value is a simple literal- Parameters:
theValue- the value- Returns:
- true if the value is a integer literal
-
-