net.sf.saxon.functions

## Class SystemFunctionCall

- java.lang.Object
- - net.sf.saxon.expr.Expression
  - - net.sf.saxon.expr.FunctionCall
    - - net.sf.saxon.functions.SystemFunctionCall

- All Implemented Interfaces:
    Serializable, SourceLocator, LocationProvider, SaxonLocator, Callable, InstructionInfo, Locator
  Direct Known Subclasses:
    Abs, Adjust, Aggregate, Available, AvailableEnvironmentVariables, BaseURI, BooleanFn, Ceiling, CodepointEqual, CodepointsToString, CollatingFunction, Collection, CompileTimeFunction, Component, Concat, CurrentDateTime, CurrentGroup, CurrentGroupingKey, DateTimeConstructor, Doc, DocAvailable, DocumentFn, DocumentUriFn, EnvironmentVariable, Error, EscapeURI, False, FilterFn, Floor, FoldLeftFn, FoldRightFn, ForEachFn, ForEachPairFn, FormatDate, FormatInteger, FormatNumber, FunctionArity, FunctionLookup, FunctionName, GenerateId, HasChildren, Id, Idref, Innermost, InScopePrefixes, Insert, KeyFn, Lang, Last, LocalNameFn, LowerCase, Matches, NameFn, NamespaceForPrefix, NamespaceUriFn, Nilled, NodeNameFn, NormalizeSpace_0, NormalizeSpace_1, NormalizeUnicode, NotFn, NumberFn, Outermost, ParseJsonFn, ParseXml, ParseXmlFragment, Path, Position, Put, QNameFn, RegexGroup, Remove, Replace, ResolveQName, ResolveURI, Reverse, Root, Round, RoundHalfToEven, Serialize, SerializeJsonFn, SnapshotFn, StringFn, StringJoin, StringLength, StringToCodepoints, Subsequence, Substring, SystemProperty, Tokenize, Trace, Translate, TreatFn, True, UnparsedEntity, UnparsedText, UpperCase, UriCollection

      public abstract class SystemFunctionCall
      extends FunctionCall
      implements Callable

  Abstract superclass for calls to functions in the standard function library
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `operation`

    - ### Fields inherited from class net.sf.saxon.expr.FunctionCall

      `argument`

    - ### Fields inherited from class net.sf.saxon.expr.Expression

      `EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, EVENT_FEED_METHOD, INHERITED_CONTEXT, INSPECTION_CONTEXT, ITEM_FEED_METHOD, ITERATE_METHOD, locationId, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, NAVIGATION_CONTEXT, NODE_VALUE_CONTEXT, PROCESS_METHOD, PUSH_SELECTION, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, W3C_CONSUMING, W3C_FREE_RANGING, W3C_GROUP_CONSUMING, W3C_MOTIONLESS, WATCH_METHOD`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SystemFunctionCall()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addContextDocumentArgument(int pos, String augmentedName)` Add an implicit argument referring to the context document.
    `PathMap.PathMapNodeSet` | `addDocToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodes)` Add a representation of a doc() call or similar function to a PathMap.
    `void` | `bindStaticContext(StaticContext env)` Bind aspects of the static context on which the particular function depends
    `void` | `checkArguments(ExpressionVisitor visitor)` Method called during static type checking
    `int` | `computeCardinality()` Determine the cardinality of the function.
    `int` | `computeSpecialProperties()` Determine the special properties of this expression.
    `Expression` | `copy()` Copy an expression.
    `static boolean` | `equalOrNull(Object x, Object y)` Return true if two objects are equal or if both are null
    `boolean` | `equals(Object o)` Determine whether two expressions are equivalent
    `protected NodeInfo` | `getContextNode(XPathContext context)` Helper method for subclasses: get the context item if it is a node, throwing appropriate errors if not
    `Callable` | `getConvertingCallable()`
    `NodeInfo` | `getDefaultArgumentNode(XPathContext context, Sequence[] arguments, String funcName)`
    `StandardFunction.Entry` | `getDetails()` Get the details of the function signature
    `String` | `getErrorCodeForTypeErrors()` Return the error code to be used for type errors.
    `FunctionItemType` | `getFunctionItemType(TypeHierarchy th)` Get the item type of the function item
    `int` | `getImplementationMethod()` An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
    `ItemType` | `getItemType(TypeHierarchy th)` Determine the item type of the value returned by the function
    `int` | `getOperation()`
    `protected SequenceType` | `getRequiredType(int arg)` Get the required type of the nth argument
    `Iterator<SubExpressionInfo>` | `iterateSubExpressionInfo()` Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.
    `static FunctionCall` | `makeSystemFunction(String name, Expression[] arguments)` Make a system function call (one in the standard function namespace).
    `Expression` | `optimize(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType)` Perform optimisation of an expression and its subexpressions.
    `void` | `setDetails(StandardFunction.Entry entry)` Set the details of this type of function
    `protected void` | `useContextItemAsDefault(ExpressionVisitor visitor)` Set "." as the default value for the first and only argument.

    - ### Methods inherited from class net.sf.saxon.expr.FunctionCall

      `addExternalFunctionCallToPathMap, checkArgumentCount, explain, getArguments, getDisplayName, getExpressionName, getFunctionName, getNumberOfArguments, hashCode, iterateSubExpressions, preEvaluate, promote, replaceSubExpression, setArguments, setFunctionName, simplify, simplifyArguments, toString, typeCheck`

    - ### Methods inherited from class net.sf.saxon.expr.Expression

      `addToPathMap, adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, evaluatePendingUpdates, explain, getCardinality, getColumnNumber, getColumnNumber, getConstructType, getContainer, getDependencies, getEvaluationMethod, getExecutable, getExpressionCompiler, getHostLanguage, getIntegerBounds, getIntrinsicDependencies, getLineNumber, getLineNumber, getLocationId, getLocationProvider, getObjectName, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getStreamability, getStreamingAdjunct, getSystemId, getSystemId, hasVariableBinding, implementsStaticTypeCheck, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterate, iterateEvents, markTailFunctionCalls, process, resetLocalStaticProperties, setContainer, setEvaluationMethod, setFiltered, setFlattened, setLocationId, staticTypeCheck, suppressValidation, toPattern, toStreamingPattern, typeError`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface net.sf.saxon.expr.Callable

      `call`

- - ### Field Detail

    - #### operation

          protected int operation

  - ### Constructor Detail

    - #### SystemFunctionCall

          public SystemFunctionCall()

  - ### Method Detail

    - #### getConvertingCallable

          public Callable getConvertingCallable()

    - #### makeSystemFunction

          public static FunctionCall makeSystemFunction(String name,
                                        Expression[] arguments)

      Make a system function call (one in the standard function namespace).
      Parameters:
        `name` - The local name of the function.
        `arguments` - the arguments to the function call
      Returns:
        a FunctionCall that implements this function, if it exists, or null if the function is unknown.

    - #### setDetails

          public void setDetails(StandardFunction.Entry entry)

      Set the details of this type of function
      Parameters:
        `entry` - information giving details of the function signature

    - #### getDetails

          public StandardFunction.Entry getDetails()

      Get the details of the function signature
      Returns:
        information about the function signature

    - #### getOperation

          public int getOperation()

    - #### getFunctionItemType

          public FunctionItemType getFunctionItemType(TypeHierarchy th)

      Get the item type of the function item
      Parameters:
        `th` - the type hierarchy cache
      Returns:
        the function item's type

    - #### getImplementationMethod

          public int getImplementationMethod()

      An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided directly. The other methods will always be available indirectly, using an implementation that relies on one of the other methods.
      Overrides:
        `getImplementationMethod` in class `Expression`
      Returns:
        the implementation method, for example `Expression.ITERATE_METHOD` or `Expression.EVALUATE_METHOD` or `Expression.PROCESS_METHOD`

    - #### getDefaultArgumentNode

          public NodeInfo getDefaultArgumentNode(XPathContext context,
                                        Sequence[] arguments,
                                        String funcName)
                                          throws XPathException

      Throws:
        `XPathException`

    - #### bindStaticContext

          public void bindStaticContext(StaticContext env)
                                 throws XPathException

      Bind aspects of the static context on which the particular function depends
      Parameters:
        `env` - the static context of the function call
      Throws:
        `XPathException` - if execution with this static context will inevitably fail

    - #### checkArguments

          public void checkArguments(ExpressionVisitor visitor)
                              throws XPathException

      Method called during static type checking
      Specified by:
        `checkArguments` in class `FunctionCall`
      Parameters:
        `visitor` - the expression visitor
      Throws:
        `XPathException` - if the arguments are incorrect

    - #### optimize

          public Expression optimize(ExpressionVisitor visitor,
                            ExpressionVisitor.ContextItemType contextItemType)
                              throws XPathException

      Perform optimisation of an expression and its subexpressions.

      This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.

      Overrides:
        `optimize` in class `FunctionCall`
      Parameters:
        `visitor` - an expression visitor
        `contextItemType` - the static type of "." at the point where this expression is invoked. The parameter is set to null if it is known statically that the context item will be undefined. If the type of the context item is not known statically, the argument is set to `Type.ITEM_TYPE`
      Returns:
        the original expression, rewritten if appropriate to optimize execution
      Throws:
        `XPathException` - if an error is discovered during this phase (typically a type error)

    - #### copy

          public Expression copy()

      Copy an expression. This makes a deep copy.
      Specified by:
        `copy` in class `Expression`
      Returns:
        the copy of the original expression

    - #### iterateSubExpressionInfo

          public Iterator<SubExpressionInfo> iterateSubExpressionInfo()

      Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.
      Overrides:
        `iterateSubExpressionInfo` in class `Expression`
      Returns:
        an iterator containing the sub-expressions of this expression

    - #### equals

          public boolean equals(Object o)

      Determine whether two expressions are equivalent
      Overrides:
        `equals` in class `FunctionCall`

    - #### equalOrNull

          public static boolean equalOrNull(Object x,
                            Object y)

      Return true if two objects are equal or if both are null
      Parameters:
        `x` - the first object
        `y` - the second object
      Returns:
        true if both x and y are null or if x.equals(y)

    - #### getErrorCodeForTypeErrors

          public String getErrorCodeForTypeErrors()

      Return the error code to be used for type errors. This is overridden for functions such as exactly-one(), one-or-more(), ...
      Returns:
        the error code to be used for type errors in the function call. Normally XPTY0004, but different codes are used for functions such as exactly-one()

    - #### getRequiredType

          protected SequenceType getRequiredType(int arg)

      Get the required type of the nth argument
      Parameters:
        `arg` - the number of the argument whose type is requested, zero-based
      Returns:
        the required type of the argument as defined in the function signature

    - #### getItemType

          public ItemType getItemType(TypeHierarchy th)

      Determine the item type of the value returned by the function
      Specified by:
        `getItemType` in class `Expression`
      Parameters:
        `th` - the type hierarchy cache
      Returns:
        a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)

    - #### computeCardinality

          public int computeCardinality()

      Determine the cardinality of the function.
      Specified by:
        `computeCardinality` in class `Expression`
      Returns:
        the computed cardinality, as one of the values `StaticProperty.ALLOWS_ZERO_OR_ONE`, `StaticProperty.EXACTLY_ONE`, `StaticProperty.ALLOWS_ONE_OR_MORE`, `StaticProperty.ALLOWS_ZERO_OR_MORE`

    - #### computeSpecialProperties

          public int computeSpecialProperties()

      Determine the special properties of this expression. The general rule is that a system function call is non-creative if its return type is atomic, or if all its arguments are non-creative. This is overridden for the generate-id() function, which is considered creative if its operand is creative (because the result depends on the identity of the operand)
      Overrides:
        `computeSpecialProperties` in class `Expression`
      Returns:
        the special properties, as a bit-significant integer

    - #### useContextItemAsDefault

          protected final void useContextItemAsDefault(ExpressionVisitor visitor)

      Set "." as the default value for the first and only argument. Called from subclasses.
      Parameters:
        `visitor` - the expression visitor

    - #### addContextDocumentArgument

          protected final void addContextDocumentArgument(int pos,
                                        String augmentedName)
                                                   throws XPathException

      Add an implicit argument referring to the context document. Called by functions such as id() and key() that take the context document as an implicit argument
      Parameters:
        `pos` - the position of the argument whose default value is ".", zero-based
        `augmentedName` - the name to be used for the function call with its extra argument. There are some cases where user function calls cannot supply the argument directly (notably unparsed-entity-uri() and unparsed-entity-public-id()) and in these cases a synthesized function name is used for the new function call.
      Throws:
        `XPathException` - if a static error is found

    - #### addDocToPathMap

          public PathMap.PathMapNodeSet addDocToPathMap(PathMap pathMap,
                                               PathMap.PathMapNodeSet pathMapNodes)

      Add a representation of a doc() call or similar function to a PathMap. This is a convenience method called by the addToPathMap() methods for doc(), document(), collection() and similar functions. These all create a new root expression in the path map.
      Parameters:
        `pathMap` - the PathMap to which the expression should be added
        `pathMapNodes` - the node in the PathMap representing the focus at the point where this expression is called. Set to null if this expression appears at the top level.
      Returns:
        the pathMapNode representing the focus established by this expression, in the case where this expression is the first operand of a path expression or filter expression

    - #### getContextNode

          protected NodeInfo getContextNode(XPathContext context)
                                     throws XPathException

      Helper method for subclasses: get the context item if it is a node, throwing appropriate errors if not
      Parameters:
        `context` - the XPath dynamic context
      Returns:
        the context item if it exists and is a node
      Throws:
        `XPathException` - if there is no context item or if the context item is not a node

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.