Class 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
    • Field Summary

      • Fields inherited from class com.complexible.stardog.plan.filter.AbstractExpression

        mArgs
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractFunction​(int theNumReqArgs, java.lang.String... theURIs)  
      protected AbstractFunction​(AbstractFunction theFunction)  
      protected AbstractFunction​(com.google.common.collect.Range<java.lang.Integer> theNumReqArgs, java.lang.String... theURIs)  
      protected AbstractFunction​(java.util.List<com.complexible.stardog.plan.filter.Expression> theExpressions, int theNumReqArgs, java.lang.String... theURIs)
      Create a new 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
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean assertArrayLiteral​(Value theValue)
      Assert that the literal is an array literal.
      protected boolean assertBNode​(Value theValue)
      Assert that the value is a BNode
      protected boolean assertDecimalLiteral​(Value theValue)
      Assert that the literal is a decimal literal.
      static boolean assertIntegerLiteral​(Value theValue)
      Assert that the literal is an integer literal.
      protected boolean assertIRI​(Value theValue)
      Assert that the value is a URI
      static boolean assertLiteral​(Value theValue)
      Assert that the value is a literal
      protected boolean assertLiteral​(Value theValue, java.util.function.Predicate<Datatype> theDatatypeChecker)  
      protected boolean assertNumericLiteral​(Value theValue)
      Assert that the literal is a numeric literal
      static boolean assertPathLiteral​(Value theValue)  
      protected boolean assertRequiredArgs​(int theArgs)
      Validate that the arguments passed to the function match the expected number
      protected boolean assertSimpleLiteral​(Value theValue)
      Assert that the value is a simple literal
      protected boolean assertStatement​(Value theValue)
      Assert that the value is a Statement
      static boolean assertStringLiteral​(Value theValue)
      Assert that the value is a String literal
      protected boolean assertTypedLiteral​(Value theValue, Datatype theDatatype)
      Assert that the literal has the provided datatype
      boolean equals​(java.lang.Object o)
      com.complexible.stardog.plan.filter.expr.ValueOrError evaluate​(com.complexible.stardog.plan.filter.expr.ValueOrError... theValues)
      Directly evaluate the function for the given arguments
      com.complexible.stardog.plan.filter.expr.ValueOrError evaluate​(com.complexible.stardog.plan.filter.ValueSolution theArgs)
      com.complexible.stardog.plan.filter.expr.ValueOrError evaluate​(Value... theValues)
      Directly evaluate the function for the given arguments
      java.lang.String getName()
      Return the string that uniquely identifies this Expression, which should be a fully qualified URI.
      java.util.List<java.lang.String> getNames()
      Return all the strings that uniquely identifies this Function.
      int hashCode()
      protected abstract com.complexible.stardog.plan.filter.expr.ValueOrError internalEvaluate​(Value... theArgs)
      Evaluate the function
      void setArgs​(java.util.List<com.complexible.stardog.plan.filter.Expression> theArgs)
      java.lang.String toString()
      • Methods inherited from class com.complexible.stardog.plan.filter.AbstractExpression

        getArg, getArgs, 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, replaceArg
    • 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:
        setArgs in interface com.complexible.stardog.plan.filter.Expression
        Overrides:
        setArgs in class com.complexible.stardog.plan.filter.AbstractExpression
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class com.complexible.stardog.plan.filter.AbstractExpression
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class com.complexible.stardog.plan.filter.AbstractExpression
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class com.complexible.stardog.plan.filter.AbstractExpression
      • getName

        public final java.lang.String getName()
        Return the string that uniquely identifies this Expression, which should be a fully qualified URI. This URI is what is used to reference this Expression in a SPARQL query.
        Specified by:
        getName in interface Function
        Returns:
        the URI
      • getNames

        public final java.util.List<java.lang.String> getNames()
        Return all the strings that uniquely identifies this Function. A function may have different names in different namespaces.
        Specified by:
        getNames in interface Function
        Returns:
        all aliases of this Function
        See Also:
        Function.getName()
      • evaluate

        public final com.complexible.stardog.plan.filter.expr.ValueOrError evaluate​(com.complexible.stardog.plan.filter.ValueSolution theArgs)
        Specified by:
        evaluate in interface com.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 a Statement
        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
      • assertLiteral

        protected final boolean assertLiteral​(Value theValue,
                                              java.util.function.Predicate<Datatype> theDatatypeChecker)