org.basex.query.up.primitives
Class ReplaceValue

java.lang.Object
  extended by org.basex.query.up.primitives.Operation
      extended by org.basex.query.up.primitives.UpdatePrimitive
          extended by org.basex.query.up.primitives.ReplaceValue

public final class ReplaceValue
extends UpdatePrimitive

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 .

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-12, BSD License, Lukas Kircher

Field Summary
 boolean rec
          States if this primitive represents a replaceElementContent expression.
 byte[] value
          New value.
 
Fields inherited from class org.basex.query.up.primitives.UpdatePrimitive
targetPre, type
 
Fields inherited from class org.basex.query.up.primitives.Operation
data, info
 
Constructor Summary
ReplaceValue(int p, Data d, InputInfo i, byte[] v)
          Constructor.
 
Method Summary
 void addAtomics(AtomicUpdateList l)
          Adds the atomic update operations for this update primitive to the given list.
 void merge(UpdatePrimitive p)
          Merges two update primitives, as they have the same target node.
 int size()
          Returns the total number of node operations.
 UpdatePrimitive[] substitute(MemData tmp)
          Substitutes the update primitive if necessary.
 java.lang.String toString()
           
 void update(NamePool pool)
          Updates the name pool, which is used to find duplicate attributes and namespace conflicts.
 
Methods inherited from class org.basex.query.up.primitives.UpdatePrimitive
getData, getInfo, getTargetNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

public final byte[] value
New value.


rec

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

Constructor Detail

ReplaceValue

public ReplaceValue(int p,
                    Data d,
                    InputInfo i,
                    byte[] v)
Constructor.

Parameters:
p - target node PRE value
d - target data reference
i - input info
v - new value
Method Detail

merge

public void merge(UpdatePrimitive p)
           throws QueryException
Description copied from class: UpdatePrimitive
Merges two update primitives, as they have the same target node.

Specified by:
merge in class UpdatePrimitive
Parameters:
p - primitive to merge with
Throws:
QueryException - exception

size

public int size()
Description copied from class: Operation
Returns the total number of node operations.

Specified by:
size in class Operation
Returns:
number of updates

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

addAtomics

public void addAtomics(AtomicUpdateList l)
Description copied from class: UpdatePrimitive
Adds the atomic update operations for this update primitive to the given list.

Specified by:
addAtomics in class UpdatePrimitive
Parameters:
l - list of atomic updates

substitute

public UpdatePrimitive[] substitute(MemData tmp)
Description copied from class: UpdatePrimitive
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.

Specified by:
substitute in class UpdatePrimitive
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: UpdatePrimitive
Updates the name pool, which is used to find duplicate attributes and namespace conflicts.

Specified by:
update in class UpdatePrimitive
Parameters:
pool - name pool