org.basex.query.up.primitives
Class UpdatePrimitive

java.lang.Object
  extended by org.basex.query.up.primitives.UpdatePrimitive
Direct Known Subclasses:
DeletePrimitive, NewValue, NodeCopy, Put, ReplaceElemContent

public abstract class UpdatePrimitive
extends Object

Abstract XQuery Update Primitive.

Author:
Workgroup DBIS, University of Konstanz 2005-10, ISC License, Lukas Kircher

Field Summary
 Nod node
          Target node of update expression.
 
Method Summary
abstract  void apply(int add)
          Applies the update operation represented by this primitive to the database.
static MemData buildDB(NodIter ch, MemData md)
          Builds new data instance from iterator.
 void merge(UpdatePrimitive p)
          Merges if possible two update primitives of the same type if they have the same target node.
static boolean mergeTexts(Data d, int a, int b)
          Merges two adjacent text nodes in a database.
 void prepare()
          Prepares the update.
abstract  PrimitiveType type()
          Returns the type of the update primitive.
 void update(NamePool pool)
          Updates the name pool, which is used for finding duplicate attributes and namespace conflicts.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

node

public final Nod node
Target node of update expression.

Method Detail

type

public abstract PrimitiveType type()
Returns the type of the update primitive.

Returns:
type

apply

public abstract void apply(int add)
                    throws QueryException
Applies the update operation represented by this primitive to the database. If an 'insert before' primitive is applied to a target node t, the pre value of t changes. Thus the number of inserted nodes is added to the pre value of t for all following update operations.

Parameters:
add - size to add
Throws:
QueryException - query exception

prepare

public void prepare()
             throws QueryException
Prepares the update.

Throws:
QueryException - query exception

merge

public void merge(UpdatePrimitive p)
           throws QueryException
Merges if possible two update primitives of the same type if they have the same target node.

Parameters:
p - primitive to be merged with
Throws:
QueryException - query exception

update

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

Parameters:
pool - name pool

mergeTexts

public static boolean mergeTexts(Data d,
                                 int a,
                                 int b)
Merges two adjacent text nodes in a database. The two node arguments must be ordered ascending, otherwise the text of the two nodes is concatenated in the wrong order.

Parameters:
d - data reference
a - node pre value
b - node pre value
Returns:
true if nodes have been merged

buildDB

public static MemData buildDB(NodIter ch,
                              MemData md)
                       throws QueryException
Builds new data instance from iterator.

Parameters:
ch - sequence iterator
md - memory data reference
Returns:
new data instance
Throws:
QueryException - query exception