Class InsertExpression

All Implemented Interfaces:
ExportAgent, Locatable, IdentityComparable, Traceable

public class InsertExpression extends BasicUpdatingExpression
An insert expression in XQuery Update
  • Constructor Details

    • InsertExpression

      public InsertExpression(Expression source, Expression target, int position, int constructionMode, boolean inherit, boolean preserve)
      Create an InsertExpression
      Parameters:
      source - expression denoting the nodes to be inserted
      target - expression denoting the insertion point
      position - integer code indicating whether to insert before, after, first, last, or into.
      constructionMode - one of Validation.PRESERVE or Validation.STRIP
      inherit - true if namespaces are to be inherited
      preserve - true if namespaces are to be preserved
  • Method Details

    • getSourceExpression

      public Expression getSourceExpression()
    • setSourceExpression

      public void setSourceExpression(Expression sourceExpression)
    • getTargetExpression

      public Expression getTargetExpression()
    • setTargetExpression

      public void setTargetExpression(Expression targetExpression)
    • operands

      public Iterable<Operand> operands()
      Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression. Default implementation works off the results of iterateSubExpressions()

      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
    • typeCheck

      public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
      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.

      If the implementation returns a value other than "this", then it is required to ensure that the parent pointer and location information in the returned expression have been set up correctly. It should not rely on the caller to do this, although for historical reasons many callers do so.

      Overrides:
      typeCheck in class Expression
      Parameters:
      visitor - an expression visitor
      contextInfo - static information about the dynamic context
      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)
    • 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
    • getExpressionName

      public String getExpressionName()
      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.
    • 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.
    • getElaborator

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