Class Substring

All Implemented Interfaces:
Callable, FunctionItem, GroundedValue, Item, Sequence

public class Substring extends SystemFunction implements Callable
This class implements the XPath substring() function
  • Constructor Details

    • Substring

      public Substring()
  • Method Details

    • typeCheckCaller

      public Expression typeCheckCaller(FunctionCall caller, ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
      Type-check the expression. This also calls preEvaluate() to evaluate the function if all the arguments are constant; functions that do not require this behavior can override the preEvaluate method.
      Overrides:
      typeCheckCaller in class SystemFunction
      Parameters:
      caller - the function call expression calling this function
      visitor - the expression visitor
      contextInfo - static context information relating to the call
      Returns:
      a type-checked replacement for the supplied function call
      Throws:
      XPathException - if an error is detected
    • substring

      public static StringValue substring(StringValue sv, NumericValue start)
      Implement the substring function with two arguments.
      Parameters:
      sv - the string value
      start - the numeric offset (1-based) of the first character to be included in the result (if not an integer, the XPath rules apply)
      Returns:
      the substring starting at this position.
    • substring

      public static StringValue substring(StringValue sv, NumericValue start, NumericValue len)
      Implement the substring function with three arguments.
      Parameters:
      sv - the string value
      start - the numeric offset (1-based) of the first character to be included in the result (if not an integer, the XPath rules apply)
      len - the length of the required substring (again, XPath rules apply)
      Returns:
      the substring starting at this position.
    • call

      public StringValue call(XPathContext context, Sequence[] arguments) throws XPathException
      Evaluate the expression
      Specified by:
      call in interface Callable
      Parameters:
      context - the dynamic evaluation context
      arguments - the values of the arguments, supplied as Sequences
      Returns:
      the result of the evaluation, in the form of a Sequence
      Throws:
      XPathException - if a dynamic error occurs during the evaluation of the expression
    • getElaborator

      public Elaborator getElaborator()
      Make an elaborator for a system function call on this function
      Overrides:
      getElaborator in class SystemFunction
      Returns:
      a suitable elaborator; or null if no custom elaborator is available