org.basex.data
Class Data

java.lang.Object
  extended by org.basex.data.Data
Direct Known Subclasses:
DiskData, MemData

public abstract class Data
extends java.lang.Object

This class provides access to the database. The storage representation depends on the underlying implementation. Note that the methods of this class are optimized for performance. They won't check if you ask for wrong data. If you request a text node, e.g., get sure your pre value actually points to a text node. The same applies to the update operations; if you write an attribute to an element node, your database will get messed up.

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

Field Summary
static byte ATTR
          Node kind: Attribute.
 Names atts
          Attribute name index.
static byte COMM
          Node kind: Comment.
 int contentID
          Index Reference for content tag.
 boolean deepfs
          File system indicator.
 int dirID
          Index Reference for directory tag.
static byte DOC
          Node kind: Document.
static byte ELEM
          Node kind: Element.
 int fileID
          Index Reference for file tag.
 MetaData meta
          Meta data.
 int nameID
          Index Reference for name tag.
static byte PI
          Node kind: Processing instruction.
 int size
          Table size.
 int sizeID
          Index Reference for size attribute.
 int suffixID
          Index Reference for suffix attribute.
 Names tags
          Tag index.
static byte TEXT
          Node kind: Text.
 int timeID
          Index Reference for time attribute.
 
Constructor Summary
Data()
           
 
Method Summary
 byte[] atom(int pre)
          Returns an atomized content for any node kind.
 double atomNum(int pre)
          Returns a atomized numeric content for any node kind.
 byte[] attName(int pre)
          Returns an attribute name.
 int attNameID(byte[] tok)
          Returns an id for the specified attribute name.
abstract  int attNameID(int pre)
          Returns an attribute name id (reference to the attribute name index).
abstract  double attNum(int pre)
          Returns an attribute value as double value.
abstract  int attSize(int pre, int kind)
          Returns a number of attributes.
abstract  byte[] attValue(int pre)
          Returns an attribute value.
 byte[] attValue(int att, int pre)
          Finds the specified attribute and returns its value.
abstract  void close()
          Closes the current database.
abstract  void closeIndex(Index.TYPE index)
          Closes the specified index.
abstract  void delete(int pre)
          Deletes a node and its descendants.
abstract  void flush()
          Flushes the table data.
abstract  int[][] ftIDs(byte[] fulltext, FTOption ftOption)
          Returns the indexed id references for the specified fulltext token.
abstract  int id(int pre)
          Returns a unique node id.
 int[] ids(Index.TYPE type, byte[] token)
          Returns the indexed id references for the specified token.
abstract  void info(PrintOutput out)
          Returns info on the index structures.
 void initNames()
          Dissolves the references to often used tag names and attributes.
abstract  void insert(int pre, int par, byte[] val, byte kind)
          Inserts a tag name, text node, comment or processing instruction.
abstract  void insert(int pre, int par, byte[] name, byte[] val)
          Inserts an attribute.
abstract  void insert(int pre, int par, Data d)
          Insert a data instance at the specified pre value.
abstract  int kind(int pre)
          Returns a node kind.
 boolean noLeaf(int id)
          Returns if the specified tag is no leaf element.
abstract  int nrFTIDs(byte[] token)
          Returns the number of indexed id references for the specified token.
 int nrIDs(Index.TYPE type, byte[] token)
          Returns the number of indexed id references for the specified token.
 int nrTags(int id)
          Returns the number of occurrences of the specified tag.
abstract  void openIndex(Index.TYPE type, Index ind)
          Opens the specified index.
abstract  int parent(int pre, int kind)
          Returns a pre value of the parent node.
abstract  int pre(int id)
          Returns a pre value.
abstract  int size(int pre, int kind)
          Returns a size value (number of descendant table entries).
 byte[] tag(int pre)
          Returns a tag name.
 int tagID(byte[] tok)
          Returns an id for the specified tag.
abstract  int tagID(int pre)
          Returns a tag id (reference to the tag index).
abstract  byte[] text(int pre)
          Returns a text.
abstract  int textLen(int pre)
          Returns a text length.
abstract  double textNum(int pre)
          Returns a text as double value.
abstract  void update(int pre, byte[] val)
          Updates a tag name, text node, comment or processing instruction.
abstract  void update(int pre, byte[] name, byte[] val)
          Updates an attribute name and value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTR

public static final byte ATTR
Node kind: Attribute.

See Also:
Constant Field Values

atts

public Names atts
Attribute name index.


COMM

public static final byte COMM
Node kind: Comment.

See Also:
Constant Field Values

contentID

public int contentID
Index Reference for content tag.


deepfs

public boolean deepfs
File system indicator.


dirID

public int dirID
Index Reference for directory tag.


DOC

public static final byte DOC
Node kind: Document.

See Also:
Constant Field Values

ELEM

public static final byte ELEM
Node kind: Element.

See Also:
Constant Field Values

fileID

public int fileID
Index Reference for file tag.


meta

public MetaData meta
Meta data.


nameID

public int nameID
Index Reference for name tag.


PI

public static final byte PI
Node kind: Processing instruction.

See Also:
Constant Field Values

size

public int size
Table size.


sizeID

public int sizeID
Index Reference for size attribute.


suffixID

public int suffixID
Index Reference for suffix attribute.


tags

public Names tags
Tag index.


TEXT

public static final byte TEXT
Node kind: Text.

See Also:
Constant Field Values

timeID

public int timeID
Index Reference for time attribute.

Constructor Detail

Data

public Data()
Method Detail

atom

public final byte[] atom(int pre)
Returns an atomized content for any node kind. The atomized value can be an attribute value or XML content.

Parameters:
pre - pre value
Returns:
atomized value

atomNum

public final double atomNum(int pre)
Returns a atomized numeric content for any node kind. The atomized value can be an attribute value or XML content.

Parameters:
pre - pre value
Returns:
atomized value

attName

public final byte[] attName(int pre)
Returns an attribute name.

Parameters:
pre - pre value
Returns:
name reference

attNameID

public final int attNameID(byte[] tok)
Returns an id for the specified attribute name.

Parameters:
tok - token to be found
Returns:
name reference

attNameID

public abstract int attNameID(int pre)
Returns an attribute name id (reference to the attribute name index).

Parameters:
pre - pre value
Returns:
token reference

attNum

public abstract double attNum(int pre)
Returns an attribute value as double value.

Parameters:
pre - pre value
Returns:
numeric value

attSize

public abstract int attSize(int pre,
                            int kind)
Returns a number of attributes.

Parameters:
pre - pre value
kind - node kind
Returns:
number of attributes

attValue

public abstract byte[] attValue(int pre)
Returns an attribute value.

Parameters:
pre - pre value
Returns:
atomized value

attValue

public final byte[] attValue(int att,
                             int pre)
Finds the specified attribute and returns its value.

Parameters:
att - attribute to be found
pre - pre value
Returns:
attribute value

close

public abstract void close()
                    throws java.io.IOException
Closes the current database.

Throws:
java.io.IOException - in case the database could not be closed

closeIndex

public abstract void closeIndex(Index.TYPE index)
                         throws java.io.IOException
Closes the specified index.

Parameters:
index - index to be closed
Throws:
java.io.IOException - in case the index could not be closed

delete

public abstract void delete(int pre)
Deletes a node and its descendants.

Parameters:
pre - pre value of the node to delete

flush

public abstract void flush()
Flushes the table data.


ftIDs

public abstract int[][] ftIDs(byte[] fulltext,
                              FTOption ftOption)
Returns the indexed id references for the specified fulltext token.

Parameters:
fulltext - token to be looked up
ftOption - fulltext options
Returns:
id array

id

public abstract int id(int pre)
Returns a unique node id.

Parameters:
pre - pre value
Returns:
node id

ids

public final int[] ids(Index.TYPE type,
                       byte[] token)
Returns the indexed id references for the specified token.

Parameters:
type - index to be looked up
token - token to be found
Returns:
id array

info

public abstract void info(PrintOutput out)
                   throws java.io.IOException
Returns info on the index structures.

Parameters:
out - output stream
Throws:
java.io.IOException - I/O exception

initNames

public final void initNames()
Dissolves the references to often used tag names and attributes.


insert

public abstract void insert(int pre,
                            int par,
                            byte[] val,
                            byte kind)
Inserts a tag name, text node, comment or processing instruction.

Parameters:
pre - pre value
par - parent of node
val - value to be inserted
kind - node kind

insert

public abstract void insert(int pre,
                            int par,
                            byte[] name,
                            byte[] val)
Inserts an attribute.

Parameters:
pre - pre value
par - parent of node
name - attribute name
val - attribute value

insert

public abstract void insert(int pre,
                            int par,
                            Data d)
Insert a data instance at the specified pre value. Note that the specified data instance must differ from this instance.

Parameters:
pre - pre value
par - parent of node
d - data instance to copy from

kind

public abstract int kind(int pre)
Returns a node kind.

Parameters:
pre - pre value
Returns:
node kind

noLeaf

public final boolean noLeaf(int id)
Returns if the specified tag is no leaf element.

Parameters:
id - id of the tag name
Returns:
result of check

nrFTIDs

public abstract int nrFTIDs(byte[] token)
Returns the number of indexed id references for the specified token.

Parameters:
token - token to be looked up
Returns:
id array

nrIDs

public final int nrIDs(Index.TYPE type,
                       byte[] token)
Returns the number of indexed id references for the specified token.

Parameters:
type - index type.
token - text to be found
Returns:
id array

nrTags

public final int nrTags(int id)
Returns the number of occurrences of the specified tag.

Parameters:
id - id of the tag name
Returns:
number of occurrences

openIndex

public abstract void openIndex(Index.TYPE type,
                               Index ind)
                        throws java.io.IOException
Opens the specified index.

Parameters:
type - index to be opened
ind - index instance
Throws:
java.io.IOException - in case the index could not be opened

parent

public abstract int parent(int pre,
                           int kind)
Returns a pre value of the parent node.

Parameters:
pre - pre value
kind - node kind
Returns:
pre value of the parent node

pre

public abstract int pre(int id)
Returns a pre value.

Parameters:
id - unique node id
Returns:
pre value or -1 if id was not found

size

public abstract int size(int pre,
                         int kind)
Returns a size value (number of descendant table entries).

Parameters:
pre - pre value
kind - node kind
Returns:
size value

tag

public final byte[] tag(int pre)
Returns a tag name.

Parameters:
pre - pre value
Returns:
name reference

tagID

public final int tagID(byte[] tok)
Returns an id for the specified tag.

Parameters:
tok - token to be found
Returns:
name reference

tagID

public abstract int tagID(int pre)
Returns a tag id (reference to the tag index).

Parameters:
pre - pre value
Returns:
token reference

text

public abstract byte[] text(int pre)
Returns a text.

Parameters:
pre - pre value
Returns:
atomized value

textLen

public abstract int textLen(int pre)
Returns a text length.

Parameters:
pre - pre value
Returns:
atomized value

textNum

public abstract double textNum(int pre)
Returns a text as double value.

Parameters:
pre - pre value
Returns:
numeric value

update

public abstract void update(int pre,
                            byte[] val)
Updates a tag name, text node, comment or processing instruction.

Parameters:
pre - pre of the text node to change
val - value to be updated

update

public abstract void update(int pre,
                            byte[] name,
                            byte[] val)
Updates an attribute name and value.

Parameters:
pre - pre of node to insert after
name - attribute name
val - attribute value