Class SquareArrayConstructor

java.lang.Object
net.sf.saxon.expr.Expression
net.sf.saxon.ma.arrays.SquareArrayConstructor
All Implemented Interfaces:
Pingable, ExportAgent, Locatable, IdentityComparable, Traceable

public class SquareArrayConstructor extends Expression implements Pingable
An expression that delivers a fixed size array whose members are the result of evaluating corresponding expressions: [a,b,c,d]
  • Constructor Details

    • SquareArrayConstructor

      public SquareArrayConstructor(List<Expression> children)
      Create an array constructor with defined members
      Parameters:
      children - expressions defining the members (comma-separated subexpressions)
  • Method Details

    • setOperanda

      protected void setOperanda(OperandArray operanda)
      Set the data structure for the operands of this expression. This must be created during initialisation of the expression and must not be subsequently changed
      Parameters:
      operanda - the data structure for expression operands
    • getOperanda

      public OperandArray getOperanda()
      Get the data structure holding the operands of this expression.
      Returns:
      the data structure holding expression operands
    • getOperand

      public Operand getOperand(int i)
    • operands

      public Iterable<Operand> operands()
      Description copied from class: Expression
      Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.

      If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.

      Overrides:
      operands in class Expression
      Returns:
      an iterator containing the sub-expressions of this expression
    • getExpressionName

      public String getExpressionName()
      Description copied from class: Expression
      Get a name identifying the kind of expression, in terms meaningful to a user.
      Overrides:
      getExpressionName in class Expression
      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.
    • getStreamerName

      public String getStreamerName()
      Description copied from class: Expression
      Get the (partial) name of a class that supports streaming of this kind of expression
      Overrides:
      getStreamerName in class Expression
      Returns:
      the partial name of a class that can be instantiated to provide streaming support in Saxon-EE, or null if there is no such class
    • computeSpecialProperties

      protected int computeSpecialProperties()
      Description copied from class: Expression
      Compute the special properties of this expression. These properties are denoted by a bit-significant integer, possible values are in class StaticProperty. The "special" properties are properties other than cardinality and dependencies, and most of them relate to properties of node sequences, for example whether the nodes are in document order.
      Overrides:
      computeSpecialProperties in class Expression
      Returns:
      the special properties, as a bit-significant integer
    • equals

      public boolean equals(Object other)
      Is this expression the same as another expression?
      Overrides:
      equals in class Expression
      Parameters:
      other - the expression to be compared with this one
      Returns:
      true if the two expressions are statically equivalent
    • computeHashCode

      protected int computeHashCode()
      Hashcode supporting equals()
      Overrides:
      computeHashCode in class Expression
      Returns:
      a computed hash code
    • typeCheck

      public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
      Description copied from class: Expression
      Perform type checking of an expression and its subexpressions. This is the second phase of static optimization.

      This checks statically that the operands of the expression have the correct type; if necessary it generates code to do run-time type checking or type conversion. A static type error is reported only if execution cannot possibly succeed, that is, if a run-time type error is inevitable. The call may return a modified form of the expression.

      This method is called after all references to functions and variables have been resolved to the declaration of the function or variable. However, the types of such functions and variables may not be accurately known if they have not been explicitly declared.

      Overrides:
      typeCheck in class Expression
      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:
      the original expression, rewritten to perform necessary run-time type checks, and to perform other type-related optimizations
      Throws:
      XPathException - if an error is discovered during this phase (typically a type error)
    • optimize

      public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
      Description copied from class: Expression
      Perform optimisation of an expression and its subexpressions. This is the third and final phase of static optimization.

      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 Expression
      Parameters:
      visitor - an expression visitor
      contextInfo - 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(RebindingMap rebindings)
      Copy an expression. This makes a deep copy.
      Specified by:
      copy in class Expression
      Parameters:
      rebindings - variables that need to be re-bound
      Returns:
      the copy of the original expression
    • getItemType

      public final ItemType getItemType()
      Determine the data type of the items returned by this expression
      Specified by:
      getItemType in class Expression
      Returns:
      the data type
    • getStaticUType

      public UType getStaticUType(UType contextItemType)
      Get the static type of the expression as a UType, following precisely the type inference rules defined in the XSLT 3.0 specification.
      Overrides:
      getStaticUType in class Expression
      Parameters:
      contextItemType - the static type of the context item
      Returns:
      the static item type of the expression according to the XSLT 3.0 defined rules
    • computeCardinality

      protected final int computeCardinality()
      Determine the cardinality of the expression
      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. 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.
    • 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
      Specified by:
      export in class Expression
      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.
    • toShortString

      public String toShortString()
      Description copied from class: Expression
      Produce a short string identifying the expression for use in error messages
      Overrides:
      toShortString in class Expression
      Returns:
      a short string, sufficient to identify the expression
    • toString

      public String toString()
      Description copied from class: Expression

      The toString() method for an expression attempts to give a representation of the expression in an XPath-like form.

      For subclasses of Expression that represent XPath expressions, the result should always be a string that parses as an XPath 3.0 expression. The expression produced should be equivalent to the original making certain assumptions about the static context. In general the expansion will make no assumptions about namespace bindings, except that (a) the prefix "xs" is used to refer to the XML Schema namespace, and (b) the default function namespace is assumed to be the "fn" namespace.

      In the case of XSLT instructions and XQuery expressions, the toString() method gives an abstracted view of the syntax that is not designed in general to be parseable.

      Overrides:
      toString in class Expression
      Returns:
      a representation of the expression as a string
    • 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. This implementation provides both iterate() and process() methods natively.
      Specified by:
      getImplementationMethod in class Expression
      Returns:
      the implementation method, for example Expression.ITERATE_METHOD or Expression.EVALUATE_METHOD or Expression.PROCESS_METHOD
    • ping

      public void ping()
      Description copied from interface: Pingable
      Notify that an event has occurred; the recipient is expected to know what this means.
      Specified by:
      ping in interface Pingable
    • makeArray

      protected ArrayItem makeArray(List<GroundedValue> members)
      Construct an array, given a list of members
      Parameters:
      members - the members of the array
      Returns:
      the constructed array
    • evaluateItem

      public Item evaluateItem(XPathContext context) throws XPathException
      Evaluate an expression as a single item. This always returns either a single Item or null (denoting the empty sequence). No conversion is done. This method should not be used unless the static type of the expression is a subtype of "item" or "item?": that is, it should not be called if the expression may return a sequence. There is no guarantee that this condition will be detected.
      Overrides:
      evaluateItem in class Expression
      Parameters:
      context - The context in which the expression is to be evaluated
      Returns:
      the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
      Throws:
      XPathException - if any dynamic error occurs evaluating the expression
    • getElaborator

      public Elaborator getElaborator()
      Make an elaborator for this expression
      Overrides:
      getElaborator in class Expression
      Returns:
      an appropriate Elaborator