Class FunctionLiteral

java.lang.Object
net.sf.saxon.expr.Expression
net.sf.saxon.expr.Literal
net.sf.saxon.functions.hof.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 Details Link icon

    • FunctionLiteral Link icon

      public FunctionLiteral(FunctionItem value)
      Create a literal as a wrapper around a Value
      Parameters:
      value - the value of this literal
  • Method Details Link icon

    • getGroundedValue Link icon

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

      public Expression simplify() throws XPathException
      Simplify an expression
      Overrides:
      simplify in class Expression
      Returns:
      for a Value, this always returns the value unchanged
      Throws:
      XPathException - if an error is discovered during expression rewriting
    • typeCheck Link icon

      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 Link icon

      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)
    • computeCardinality Link icon

      protected 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. May also return StaticProperty.ALLOWS_ZERO if the result is known to be an empty sequence, or StaticProperty.ALLOWS_MANY if if is known to return a sequence of length two or more.
    • computeSpecialProperties Link icon

      protected int computeSpecialProperties()
      Compute the static properties of this expression (other than its type). For a Value, the only special property is StaticProperty.NO_NODES_NEWLY_CREATED.
      Overrides:
      computeSpecialProperties in class Literal
      Returns:
      the value StaticProperty.NO_NODES_NEWLY_CREATED
    • isVacuousExpression Link icon

      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 Link icon

      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
    • setRetainedStaticContext Link icon

      public void setRetainedStaticContext(RetainedStaticContext rsc)
      Set the retained static context
      Overrides:
      setRetainedStaticContext in class Expression
      Parameters:
      rsc - the static context to be retained
    • equals Link icon

      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.
    • computeHashCode Link icon

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

      public 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 Link icon

      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.