org.basex.data
Class Nodes

java.lang.Object
  extended by org.basex.data.Nodes
All Implemented Interfaces:
Result

public final class Nodes
extends java.lang.Object
implements Result

This class stores node references of a database in an ascending order. Instances of this class are used in the Context class to reference the currently used, marked, and copied nodes.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
 Data data
          Root node.
 FTPosData ftpos
          Full-text position data (for visualization).
 int[] pres
          Pre values container.
 boolean root
          Root flag (nodes represent all document nodes of the database).
 int[] sorted
          Sorted pre values.
 
Constructor Summary
Nodes(Data d)
          Constructor, specifying a database instance.
Nodes(int[] n)
          Constructor, which should only used by test classes.
Nodes(int[] n, Data d)
          Constructor, specifying a node set and a database instance.
Nodes(int[] n, Data d, FTPosData ft)
          Constructor, specifying a node set, a database instance, and full-text positions.
Nodes(int n, Data d)
          Constructor, specifying a single node and a database instance.
Nodes(Nodes nds)
          Copy constructor.
 
Method Summary
 Nodes checkRoot()
          Checks if the node set contains all root nodes of the data instance.
 boolean contains(int p)
          Checks if the specified node is contained in the array.
 int find(int p)
          Returns the position of the specified node or the negative value - 1 of the position where it should have been found.
 boolean sameAs(Result r)
          Compares results for equality.
 ArrayOutput serialize()
          Serializes the result, using the standard serializer, and returns the cached result.
 void serialize(Serializer ser)
          Serializes the complete result.
 void serialize(Serializer ser, int n)
          Serializes the specified result.
 long size()
          Number of values, stored in the result instance.
 void toggle(int p)
          Adds or removes the specified pre node.
 java.lang.String toString()
           
 void union(int[] p)
          Merges the specified array with the existing pre nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ftpos

public final FTPosData ftpos
Full-text position data (for visualization).


root

public boolean root
Root flag (nodes represent all document nodes of the database).


data

public Data data
Root node.


pres

public int[] pres
Pre values container.


sorted

public int[] sorted
Sorted pre values.

Constructor Detail

Nodes

public Nodes(Data d)
Constructor, specifying a database instance.

Parameters:
d - data reference

Nodes

public Nodes(int n,
             Data d)
Constructor, specifying a single node and a database instance.

Parameters:
n - single node
d - data reference

Nodes

public Nodes(int[] n,
             Data d)
Constructor, specifying a node set and a database instance.

Parameters:
n - node set
d - data reference

Nodes

public Nodes(int[] n,
             Data d,
             FTPosData ft)
Constructor, specifying a node set, a database instance, and full-text positions.

Parameters:
n - node set
d - data reference
ft - ft position data

Nodes

public Nodes(int[] n)
Constructor, which should only used by test classes. No database reference is specified.

Parameters:
n - node set

Nodes

public Nodes(Nodes nds)
Copy constructor.

Parameters:
nds - nodes to copy
Method Detail

size

public long size()
Description copied from interface: Result
Number of values, stored in the result instance.

Specified by:
size in interface Result
Returns:
number of values

sameAs

public boolean sameAs(Result r)
Description copied from interface: Result
Compares results for equality.

Specified by:
sameAs in interface Result
Parameters:
r - result to be compared
Returns:
true if results are equal

checkRoot

public Nodes checkRoot()
Checks if the node set contains all root nodes of the data instance. If yes, returns null.

Returns:
self reference

contains

public boolean contains(int p)
Checks if the specified node is contained in the array.

Parameters:
p - pre value
Returns:
true if the node was found

find

public int find(int p)
Returns the position of the specified node or the negative value - 1 of the position where it should have been found.

Parameters:
p - pre value
Returns:
true if the node was found

toggle

public void toggle(int p)
Adds or removes the specified pre node.

Parameters:
p - pre value

union

public void union(int[] p)
Merges the specified array with the existing pre nodes.

Parameters:
p - pre value

serialize

public void serialize(Serializer ser)
               throws java.io.IOException
Description copied from interface: Result
Serializes the complete result.

Specified by:
serialize in interface Result
Parameters:
ser - serializer
Throws:
java.io.IOException - I/O exception

serialize

public void serialize(Serializer ser,
                      int n)
               throws java.io.IOException
Description copied from interface: Result
Serializes the specified result.

Specified by:
serialize in interface Result
Parameters:
ser - serializer
n - offset of result to serialize
Throws:
java.io.IOException - I/O exception

serialize

public ArrayOutput serialize()
                      throws java.io.IOException
Description copied from interface: Result
Serializes the result, using the standard serializer, and returns the cached result.

Specified by:
serialize in interface Result
Returns:
serialized value
Throws:
java.io.IOException - I/O exception

toString

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