org.basex.query.up.primitives
Class UpdatePrimitive

java.lang.Object
  extended by org.basex.query.up.primitives.Operation
      extended by org.basex.query.up.primitives.UpdatePrimitive
Direct Known Subclasses:
DeleteNode, NodeCopy, RenameNode, ReplaceValue

public abstract class UpdatePrimitive
extends Operation

Base class for all update primitives.

Author:
BaseX Team 2005-12, BSD License, Lukas Kircher

Field Summary
 int targetPre
          Target node pre value.
 PrimitiveType type
          Primitive Type.
 
Fields inherited from class org.basex.query.up.primitives.Operation
data, info
 
Method Summary
abstract  void addAtomics(AtomicUpdateList l)
          Adds the atomic update operations for this update primitive to the given list.
 Data getData()
          Returns the target data reference.
 InputInfo getInfo()
          Input info.
 DBNode getTargetNode()
          Creates a DBNode instance from the target node information.
abstract  void merge(UpdatePrimitive p)
          Merges two update primitives, as they have the same target node.
abstract  UpdatePrimitive[] substitute(MemData tmp)
          Substitutes the update primitive if necessary.
abstract  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.Operation
size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

targetPre

public final int targetPre
Target node pre value.


type

public final PrimitiveType type
Primitive Type.

Method Detail

getTargetNode

public final DBNode getTargetNode()
Creates a DBNode instance from the target node information.

Specified by:
getTargetNode in class Operation
Returns:
DBNode

getData

public Data getData()
Description copied from class: Operation
Returns the target data reference.

Specified by:
getData in class Operation
Returns:
data

getInfo

public InputInfo getInfo()
Description copied from class: Operation
Input info.

Specified by:
getInfo in class Operation
Returns:
input info

merge

public abstract void merge(UpdatePrimitive p)
                    throws QueryException
Merges two update primitives, as they have the same target node.

Parameters:
p - primitive to merge with
Throws:
QueryException - exception

update

public abstract void update(NamePool pool)
Updates the name pool, which is used to find duplicate attributes and namespace conflicts.

Parameters:
pool - name pool

addAtomics

public abstract void addAtomics(AtomicUpdateList l)
Adds the atomic update operations for this update primitive to the given list.

Parameters:
l - list of atomic updates

substitute

public abstract UpdatePrimitive[] substitute(MemData tmp)
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.

Parameters:
tmp - temporary mem data
Returns:
An array that contains the substituting primitives or this update primitive if no substitution is necessary.