com.saxonica.functions.hof

## Class FunctionLiteral

- java.lang.Object
- - net.sf.saxon.expr.Expression
  - - net.sf.saxon.expr.Literal
    - - com.saxonica.functions.hof.FunctionLiteral

- All Implemented Interfaces:
    Serializable, SourceLocator, LocationProvider, SaxonLocator, InstructionInfo, Locator

      public class FunctionLiteral
      extends Literal

  A FunctionLiteral is a wrapper around a FunctionItem; it is an expression, whose value is the function item that it wraps.
  See Also:
    Serialized Form

- - ### Field Summary

    - ### 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
    `FunctionLiteral(FunctionItem value)` Create a literal as a wrapper around a Value

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `computeCardinality()` Determine the cardinality
    `int` | `computeSpecialProperties()` Compute the static properties of this expression (other than its type).
    `Expression` | `copy()` Copy an expression.
    `boolean` | `equals(Object obj)` Determine whether two literals are equal, when considered as expressions.
    `void` | `explain(ExpressionPresenter out)` Diagnostic print of expression structure.
    `ExpressionCompiler` | `getExpressionCompiler()` Return the compiler of the FunctionLiteral expression
    `ItemType` | `getItemType(TypeHierarchy th)` Determine the data type of the items in the expression, if possible
    `FunctionItem` | `getValue()` Get the value represented by this Literal
    `int` | `hashCode()` Return a hash code to support the equals() function
    `boolean` | `isVacuousExpression()` Determine whether this is a vacuous expression as defined in the XQuery update specification
    `Expression` | `optimize(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType)` Optimize an expression
    `Expression` | `simplify(ExpressionVisitor visitor)` Simplify an expression
    `Expression` | `typeCheck(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType)` TypeCheck an expression

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

      `addToPathMap, effectiveBooleanValue, evaluateAsString, evaluateItem, evaluatePendingUpdates, getDependencies, getIntegerBounds, getStreamability, isAtomic, isConstantBoolean, isConstantOne, isEmptySequence, isSubtreeExpression, iterate, iterate, makeEmptySequence, makeLiteral, process, toPattern, toStreamingPattern, toString`

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

      `adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, doPromotion, dynamicError, explain, getCardinality, getColumnNumber, getColumnNumber, getConstructType, getContainer, getEvaluationMethod, getExecutable, getExpressionName, getHostLanguage, getImplementationMethod, getIntrinsicDependencies, getLineNumber, getLineNumber, getLocationId, getLocationProvider, getObjectName, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getStreamingAdjunct, getSystemId, getSystemId, hasVariableBinding, implementsStaticTypeCheck, isUpdatingExpression, iterateEvents, iterateSubExpressionInfo, iterateSubExpressions, markTailFunctionCalls, promote, replaceSubExpression, resetLocalStaticProperties, setContainer, setEvaluationMethod, setFiltered, setFlattened, setLocationId, staticTypeCheck, suppressValidation, typeError`

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

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

- - ### Constructor Detail

    - #### FunctionLiteral

          public FunctionLiteral(FunctionItem value)

      Create a literal as a wrapper around a Value
      Parameters:
        `value` - the value of this literal

  - ### Method Detail

    - #### getValue

          public FunctionItem getValue()

      Get the value represented by this Literal
      Overrides:
        `getValue` in class `Literal`
      Returns:
        the constant value

    - #### simplify

          public Expression simplify(ExpressionVisitor visitor)
                              throws XPathException

      Simplify an expression
      Overrides:
        `simplify` in class `Literal`
      Parameters:
        `visitor` - an expression visitor
      Returns:
        for a Value, this always returns the value unchanged
      Throws:
        `XPathException` - if an error is discovered during expression rewriting

    - #### typeCheck

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

      TypeCheck an expression
      Overrides:
        `typeCheck` in class `Literal`
      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:
        for a Value, this always returns the value unchanged
      Throws:
        `XPathException` - if an error is discovered during this phase (typically a type error)

    - #### optimize

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

      Optimize an expression
      Overrides:
        `optimize` in class `Literal`
      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:
        for a Value, this always returns the value unchanged
      Throws:
        `XPathException` - if an error is discovered during this phase (typically a type error)

    - #### getItemType

          public ItemType getItemType(TypeHierarchy th)

      Determine the data type of the items in the expression, if possible
      Overrides:
        `getItemType` in class `Literal`
      Parameters:
        `th` - The TypeHierarchy. Can be null if the target is an AtomicValue.
      Returns:
        for the default implementation: AnyItemType (not known)

    - #### computeCardinality

          public int computeCardinality()

      Determine the cardinality
      Overrides:
        `computeCardinality` in class `Literal`
      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()

      Compute the static properties of this expression (other than its type). For a Value, the only special property is `StaticProperty.NON_CREATIVE`.
      Overrides:
        `computeSpecialProperties` in class `Literal`
      Returns:
        the value `StaticProperty.NON_CREATIVE`

    - #### isVacuousExpression

          public boolean isVacuousExpression()

      Determine whether this is a vacuous expression as defined in the XQuery update specification
      Overrides:
        `isVacuousExpression` in class `Literal`
      Returns:
        true if this expression is vacuous

    - #### copy

          public Expression copy()

      Copy an expression. This makes a deep copy.
      Overrides:
        `copy` in class `Literal`
      Returns:
        the copy of the original expression

    - #### equals

          public boolean equals(Object obj)

      Determine whether two literals are equal, when considered as expressions.
      Overrides:
        `equals` in class `Literal`
      Parameters:
        `obj` - the other expression
      Returns:
        true if the two literals are equal. The test here requires (a) identity in the sense defined by XML Schema (same value in the same value space), and (b) identical type annotations. For example the literal xs:int(3) is not equal (as an expression) to xs:short(3), because the two expressions are not interchangeable.

    - #### hashCode

          public int hashCode()

      Return a hash code to support the equals() function
      Overrides:
        `hashCode` in class `Literal`

    - #### getExpressionCompiler

          public ExpressionCompiler getExpressionCompiler()

      Return the compiler of the FunctionLiteral expression
      Overrides:
        `getExpressionCompiler` in class `Literal`
      Returns:
        the relevant ExpressionCompiler

    - #### explain

          public void explain(ExpressionPresenter out)

      Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
      Overrides:
        `explain` in class `Literal`
      Parameters:
        `out` - the expression presenter used to display the structure

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