org.eclipse.rdf4j.query.algebra.evaluation.function.xsd

## Class CastFunction

- java.lang.Object
- - org.eclipse.rdf4j.query.algebra.evaluation.function.xsd.CastFunction

- All Implemented Interfaces:
    Function
  Direct Known Subclasses:
    BooleanCast, DateTimeCast, DecimalCast, DoubleCast, FloatCast, IntegerCastFunction, StringCast

      public abstract class CastFunction
      extends Object
      implements Function

  Abstract superclass for `Function`s that cast an argument to an XML Schema datatype.
  Author:
    Jeen Broekstra
  See Also:
    `XSD`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CastFunction()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract Literal` | `convert(ValueFactory vf, Value v)` Convert the supplied value to a literal of the function output datatype.
    `Literal` | `evaluate(ValueFactory valueFactory, Value... args)` Evaluate the function over the supplied input arguments, using the supplied `ValueFactory` to produce the result.
    `String` | `getURI()`
    `protected abstract IRI` | `getXsdDatatype()` Get the specific XML Schema datatype which this function returns.
    `protected String` | `getXsdName()` Returns a prefixed name representation of the specific datatype that this function returns
    `protected abstract boolean` | `isValidForDatatype(String lexicalValue)` Verifies that the supplied lexical value is valid for the datatype.
    `protected ValueExprEvaluationException` | `typeError(Value arg, Throwable cause)` Creates a `ValueExprEvaluationException` that signals a type error.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.rdf4j.query.algebra.evaluation.function.Function

      `evaluate`

- - ### Constructor Detail

    - #### CastFunction

          public CastFunction()

  - ### Method Detail

    - #### getURI

          public final String getURI()

      Specified by:
        `getURI` in interface `Function`

    - #### evaluate

          public Literal evaluate(ValueFactory valueFactory,
                                  Value... args)
                           throws ValueExprEvaluationException

      Description copied from interface: `Function`
      Evaluate the function over the supplied input arguments, using the supplied `ValueFactory` to produce the result.
      Specified by:
        `evaluate` in interface `Function`
      Parameters:
        `valueFactory` - a `ValueFactory` to use for producing the function result.
        `args` - the function input arguments.
      Returns:
        the function result value.
      Throws:
        `ValueExprEvaluationException`

    - #### convert

          protected abstract Literal convert(ValueFactory vf,
                                             Value v)
                                      throws ValueExprEvaluationException

      Convert the supplied value to a literal of the function output datatype.
      Parameters:
        `vf` - the valueFactory to use
        `v` - a value that is not a string-typed literal, and not a literal of the same datatype as the function output datatype.
      Returns:
        a literal value of the function output datatype
      Throws:
        `ValueExprEvaluationException` - if an error occurs in conversion.

    - #### getXsdDatatype

          protected abstract IRI getXsdDatatype()

      Get the specific XML Schema datatype which this function returns.
      Returns:
        an XML Schema datatype IRI

    - #### getXsdName

          protected String getXsdName()

      Returns a prefixed name representation of the specific datatype that this function returns
      Returns:
        a prefixed name, e.g. 'xsd:integer'.

    - #### isValidForDatatype

          protected abstract boolean isValidForDatatype(String lexicalValue)

      Verifies that the supplied lexical value is valid for the datatype.
      Parameters:
        `lexicalValue` - a lexical value
      Returns:
        true if the lexical value is valid for the datatype, false otherwise.

    - #### typeError

          protected final ValueExprEvaluationException typeError(Value arg,
                                                                 Throwable cause)

      Creates a `ValueExprEvaluationException` that signals a type error.
      Parameters:
        `arg` - the function argument value.
        `cause` - root cause throwable. May be null.
      Returns:
        a `ValueExprEvaluationException` with a standardized message and wrapped cause.

Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.