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 nodes.

Author:
Workgroup DBIS, University of Konstanz 2005-09, ISC License, Christian Gruen

Field Summary
 Data data
          Root Node.
 boolean doc
          Doc flag (all nodes refer to documents).
 FTPosData ftpos
          Full-text position data (for visualization).
 int[] nodes
          Pre values container.
 int[] sorted
          Sorted pre values.
 
Constructor Summary
Nodes(Data d)
          Node Set constructor.
Nodes(Data d, FTPosData ft)
          Node Set constructor.
Nodes(int[] n, Data d)
          Node Set constructor.
Nodes(int[] n, Data d, boolean r)
          Node Set constructor.
Nodes(int n, Data d)
          Node Set constructor.
 
Method Summary
 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 same(Result v)
          Compares values for equality.
 void serialize(Serializer ser)
          Serializes the complete result.
 void serialize(Serializer ser, int n)
          Serializes the specified result.
 void set(int[] n)
          Sets the specified nodes.
 int size()
          Number of values, stored in the result instance.
 void sort()
          Creates a sorted node array.
 void toggle(int p)
          The specified pre value is added to or removed from the node array.
 java.lang.String toString()
           
 void union(int[] p)
          The specified nodes are merged.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

doc

public boolean doc
Doc flag (all nodes refer to documents).


data

public Data data
Root Node.


ftpos

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


nodes

public int[] nodes
Pre values container.


sorted

public int[] sorted
Sorted pre values.

Constructor Detail

Nodes

public Nodes(Data d)
Node Set constructor.

Parameters:
d - data reference

Nodes

public Nodes(Data d,
             FTPosData ft)
Node Set constructor.

Parameters:
d - data reference
ft - ft position data

Nodes

public Nodes(int n,
             Data d)
Node Set constructor.

Parameters:
n - single node
d - data reference

Nodes

public Nodes(int[] n,
             Data d)
Node Set constructor.

Parameters:
n - node set
d - data reference

Nodes

public Nodes(int[] n,
             Data d,
             boolean r)
Node Set constructor.

Parameters:
n - node set
d - data reference
r - doc flag (all nodes refer to documents)
Method Detail

set

public void set(int[] n)
Sets the specified nodes.

Parameters:
n - values

size

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

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

same

public boolean same(Result v)
Description copied from interface: Result
Compares values for equality.

Specified by:
same in interface Result
Parameters:
v - value to be compared
Returns:
true if values are equal

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

sort

public void sort()
Creates a sorted node array. If the original array is already sorted, the same reference is used.


toggle

public void toggle(int p)
The specified pre value is added to or removed from the node array.

Parameters:
p - pre value

union

public void union(int[] p)
The specified nodes are merged.

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 - results offset to serialize
Throws:
java.io.IOException - I/O exception

toString

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