Class FunctionLiteral

  • All Implemented Interfaces:
    ExportAgent, Locatable, IdentityComparable, Traceable

    public class FunctionLiteral
    extends Literal
    A FunctionLiteral is a wrapper around a FunctionItem; it is an expression, whose value is the function that it wraps. Note that a FunctionLiteral can be used only where the binding to a specific function is statically known. This works for constructor functions, for system functions that have no context dependency, and for references to user function (my:f#2) in XQuery, but not in XSLT where the reference cannot be fully resolved until separately-compiled packages are linked. In other cases a UserFunctionReference is used.
    • 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

      • getGroundedValue

        public FunctionItem getGroundedValue()
        Get the value represented by this Literal
        Overrides:
        getGroundedValue in class Literal
        Returns:
        the constant value
      • typeCheck

        public Expression typeCheck​(ExpressionVisitor visitor,
                                    ContextItemStaticInfo contextInfo)
                             throws XPathException
        TypeCheck an expression
        Overrides:
        typeCheck in class Literal
        Parameters:
        visitor - an expression visitor
        contextInfo - Information available statically about the context item: whether it is (possibly) absent; its static type; its streaming posture.
        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 FunctionItemType getItemType()
        Determine the data type of the items in the expression, if possible
        Overrides:
        getItemType in class Literal
        Returns:
        for the default implementation: AnyItemType (not known)
      • 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​(RebindingMap rebindings)
        Copy an expression. This makes a deep copy.
        Overrides:
        copy in class Literal
        Parameters:
        rebindings - variables to be re-bound
        Returns:
        the copy of the original expression
      • equals

        public boolean equals​(java.lang.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.
      • computeHashCode

        protected int computeHashCode()
        Return a hash code to support the equals() function
        Overrides:
        computeHashCode in class Literal
        Returns:
        a computed hash code
      • getExpressionName

        public java.lang.String getExpressionName()
        Get a name identifying the kind of expression, in terms meaningful to a user.
        Overrides:
        getExpressionName in class Literal
        Returns:
        a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in export() output displaying the expression.
      • export

        public void export​(ExpressionPresenter out)
                    throws XPathException
        Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
        Specified by:
        export in interface ExportAgent
        Overrides:
        export in class Literal
        Parameters:
        out - the expression presenter used to display the structure
        Throws:
        XPathException - if the export fails, for example if an expression is found that won't work in the target environment.