Class ReplaceValue


public final class ReplaceValue extends NodeUpdate

ReplaceValue primitive. Replaces the value of a node.

If the target T is an element node this primitive represents a replaceElementContent expression (see XQUF). The children of T are deleted and a single (optional) text node is inserted as the only child of T. The primitive for replaceElementContent is substituted by [delete children(T), insertInto(T)].

After the end of the snapshot, T has either no child node at all (if the given text node has been empty), or the given (non-empty) text node as a single child. Attributes of T are not affected by a replaceElementContent expression.

If T is a text node and the new text value is empty, T is deleted.

Author:
BaseX Team 2005-21, BSD License, Lukas Kircher
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final boolean
    States if this primitive represents a replaceElementContent expression.

    Fields inherited from class org.basex.query.up.primitives.node.NodeUpdate

    pre

    Fields inherited from class org.basex.query.up.primitives.DataUpdate

    data

    Fields inherited from class org.basex.query.up.primitives.Update

    info, type
  • Constructor Summary

    Constructors
    Constructor
    Description
    ReplaceValue(int pre, Data data, InputInfo ii, byte[] value)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds the atomic update operations for this update primitive to the given list.
    void
    merge(Update update)
    Merges two update operations pointing to the same target.
    void
    Prepares this update primitive before execution.
    int
    Returns the number of update operations.
    Substitutes the update primitive if necessary.
     
    void
    Updates the name pool, which is used to find duplicate attributes and namespace conflicts.

    Methods inherited from class org.basex.query.up.primitives.node.NodeUpdate

    node

    Methods inherited from class org.basex.query.up.primitives.DataUpdate

    data

    Methods inherited from class org.basex.query.up.primitives.Update

    info

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • rec

      public final boolean rec
      States if this primitive represents a replaceElementContent expression.
  • Constructor Details

    • ReplaceValue

      public ReplaceValue(int pre, Data data, InputInfo ii, byte[] value)
      Constructor.
      Parameters:
      pre - target node PRE value
      data - target data reference
      ii - input info
      value - new value
  • Method Details

    • prepare

      public void prepare(MemData memData, QueryContext qc)
      Description copied from class: NodeUpdate
      Prepares this update primitive before execution. This includes e.g. the preparation of insertion sequences.
      Specified by:
      prepare in class NodeUpdate
      Parameters:
      memData - temporary data instance
      qc - query context
    • merge

      public void merge(Update update) throws QueryException
      Description copied from class: Update
      Merges two update operations pointing to the same target.
      Specified by:
      merge in class Update
      Parameters:
      update - operation to merge with
      Throws:
      QueryException - exception
    • size

      public int size()
      Description copied from class: Update
      Returns the number of update operations.
      Specified by:
      size in class Update
      Returns:
      number of updates
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • addAtomics

      public void addAtomics(AtomicUpdateCache auc)
      Description copied from class: NodeUpdate
      Adds the atomic update operations for this update primitive to the given list.
      Specified by:
      addAtomics in class NodeUpdate
      Parameters:
      auc - list of atomic updates
    • substitute

      public NodeUpdate[] substitute(MemData tmp)
      Description copied from class: NodeUpdate
      Substitutes the update primitive if necessary. For instance a 'Replace Value of' primitive called on a target T with T being an element results in a 'Replace Element Content' primitive with target T. As this is ugly to process it is substituted by delete primitives for every child of T and an 'Insert into' primitive if the length of the (optional!) text node is greater zero. When a primitive is substituted it is still added to the list itself to be able to throw exceptions when necessary. I.e. for multiple replaces on the same target node. These update primitives don't produce atomic updates, hence this won't affect the database.
      Overrides:
      substitute in class NodeUpdate
      Parameters:
      tmp - temporary mem data
      Returns:
      An array that contains the substituting primitives or this update primitive if no substitution is necessary.
    • update

      public void update(NamePool pool)
      Description copied from class: NodeUpdate
      Updates the name pool, which is used to find duplicate attributes and namespace conflicts.
      Specified by:
      update in class NodeUpdate
      Parameters:
      pool - name pool