Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.basex.data
Class Data

    java.lang.Object
      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 will not check if you request wrong data. If you ask for 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-09, ISC License, Christian Gruen

Nested Class Summary
`static class` | `Data.Type` Index types.

Field Summary
`static byte` | `ATTR` Node kind: Attribute.
`Names` | `atts` Attribute name index.
`static byte` | `COMM` Node kind: Comment.
`static byte` | `DOC` Node kind: Document.
`static byte` | `ELEM` Node kind: Element.
`DeepFS` | `fs` File system indicator.
`MetaData` | `meta` Meta data.
`int` | `nameID` Index Reference for name tag.
`Namespaces` | `ns` Namespace index.
`PathSummary` | `path` Path Summary.
`static byte` | `PI` Node kind: Processing instruction.
`int` | `sizeID` Index References.
`Names` | `tags` Tag index.
`static byte` | `TEXT` Node kind: Text.

Constructor Summary
`Data()`

Method Summary
`byte[]` | `atom(int pre)` Returns an atomized content for any node kind.
`abstract int` | `attLen(int pre)` Returns an attribute value length.
`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 int` | `attNS(int pre)` Returns an attribute namespace (reference to the attribute namespace).
`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.
`void` | `close()` Closes the current database.
`abstract void` | `closeIndex(Data.Type index)` Closes the specified index.
`abstract void` | `delete(int pre)` Deletes a node and its descendants.
`int[]` | `doc()` Returns the document nodes.
`abstract void` | `flush()` Flushes the table data.
`abstract int` | `getLock()` Returns the locking situation of the data.
`abstract int` | `id(int pre)` Returns a unique node id.
`IndexIterator` | `ids(IndexToken token)` Returns the indexed id references for the specified token.
`byte[]` | `info(Data.Type type)` Returns info on the specified index structure.
`void` | `init()` Dissolves the references to often used tag names and attributes.
`abstract void` | `insert(int pre, int par, byte[] name, byte[] val)` Inserts an attribute.
`abstract void` | `insert(int pre, int par, byte[] val, int kind)` Inserts a tag name, text node, comment or processing instruction.
`abstract void` | `insert(int pre, int par, Data d)` Inserts a data instance at the specified pre value.
`abstract int` | `kind(int pre)` Returns a node kind.
`int` | `nrIDs(IndexToken token)` Returns the number of indexed id references for the specified token.
`abstract int[]` | `ns(int pre)` Returns namespace key and value ids.
`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 void` | `setIndex(Data.Type type, Index ind)` Assigns the specified index.
`abstract void` | `setLock(int l)` Locks and unlocks the data reference.
`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 int` | `tagNS(int pre)` Returns a tag namespace (reference to the tag namespace).
`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.
`java.lang.String` | `toString()`
`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, wait, wait, wait`

Field Detail

### 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

### TEXT

    public static final byte TEXT

  Node kind: Text.

  See Also:
    Constant Field Values

### ATTR

    public static final byte ATTR

  Node kind: Attribute.

  See Also:
    Constant Field Values

### COMM

    public static final byte COMM

  Node kind: Comment.

  See Also:
    Constant Field Values

### PI

    public static final byte PI

  Node kind: Processing instruction.

  See Also:
    Constant Field Values

### meta

    public MetaData meta

  Meta data.

### tags

    public Names tags

  Tag index.

### atts

    public Names atts

  Attribute name index.

### ns

    public Namespaces ns

  Namespace index.

### path

    public PathSummary path

  Path Summary.

### fs

    public DeepFS fs

  File system indicator.

### nameID

    public int nameID

  Index Reference for name tag.

### sizeID

    public int sizeID

  Index References.

Constructor Detail

### Data

    public Data()

Method Detail

### init

    public void init()
              throws java.io.IOException

  Dissolves the references to often used tag names and attributes.

  Throws:
    `java.io.IOException` - I/O exception

### close

    public final void close()
                     throws java.io.IOException

  Closes the current database.

  Throws:
    `java.io.IOException` - I/O exception

### flush

    public abstract void flush()

  Flushes the table data.

### closeIndex

    public abstract void closeIndex(Data.Type index)
                             throws java.io.IOException

  Closes the specified index.

  Parameters:
    `index` - index to be closed
  Throws:
    `java.io.IOException` - I/O exception

### setIndex

    public abstract void setIndex(Data.Type type,
                                  Index ind)

  Assigns the specified index.

  Parameters:
    `type` - index to be opened
    `ind` - index instance

### id

    public abstract int id(int pre)

  Returns a unique node id.

  Parameters:
    `pre` - pre value
  Returns:
    node id

### 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

### kind

    public abstract int kind(int pre)

  Returns a node kind.

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

### 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

### 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

### tagID

    public abstract int tagID(int pre)

  Returns a tag id (reference to the tag index).

  Parameters:
    `pre` - pre value
  Returns:
    token reference

### tagID

    public final int tagID(byte[] tok)

  Returns an id for the specified tag.

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

### tag

    public final byte[] tag(int pre)

  Returns a tag name.

  Parameters:
    `pre` - pre value
  Returns:
    name reference

### tagNS

    public abstract int tagNS(int pre)

  Returns a tag namespace (reference to the tag namespace).

  Parameters:
    `pre` - pre value
  Returns:
    token reference

### ns

    public abstract int[] ns(int pre)

  Returns namespace key and value ids.

  Parameters:
    `pre` - pre value
  Returns:
    key and value ids

### text

    public abstract byte[] text(int pre)

  Returns a text.

  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

### textLen

    public abstract int textLen(int pre)

  Returns a text length.

  Parameters:
    `pre` - pre value
  Returns:
    length

### attName

    public final byte[] attName(int pre)

  Returns an attribute name.

  Parameters:
    `pre` - pre value
  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

### attNameID

    public final int attNameID(byte[] tok)

  Returns an id for the specified attribute name.

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

### attNS

    public abstract int attNS(int pre)

  Returns an attribute namespace (reference to the attribute namespace).

  Parameters:
    `pre` - pre value
  Returns:
    token reference

### attValue

    public abstract byte[] attValue(int pre)

  Returns an attribute value.

  Parameters:
    `pre` - pre value
  Returns:
    atomized value

### attLen

    public abstract int attLen(int pre)

  Returns an attribute value length.

  Parameters:
    `pre` - pre value
  Returns:
    length

### attNum

    public abstract double attNum(int pre)

  Returns an attribute value as double value.

  Parameters:
    `pre` - pre value
  Returns:
    numeric 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

### 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

### ids

    public final IndexIterator ids(IndexToken token)

  Returns the indexed id references for the specified token.

  Parameters:
    `token` - index token reference
  Returns:
    id array

### nrIDs

    public final int nrIDs(IndexToken token)

  Returns the number of indexed id references for the specified token.

  Parameters:
    `token` - text to be found
  Returns:
    id array

### info

    public final byte[] info(Data.Type type)

  Returns info on the specified index structure.

  Parameters:
    `type` - index type
  Returns:
    info

### doc

    public final int[] doc()

  Returns the document nodes.

  Returns:
    root nodes

### 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

### 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

### delete

    public abstract void delete(int pre)

  Deletes a node and its descendants.

  Parameters:
    `pre` - pre value of the node to delete

### insert

    public abstract void insert(int pre,
                                int par,
                                byte[] val,
                                int 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)

  Inserts a data instance at the specified pre value. Note that the specified data instance must differ from this instance.

  Parameters:
    `pre` - value at which to insert new data
    `par` - parent pre value of node
    `d` - data instance to copy from

### getLock

    public abstract int getLock()

  Returns the locking situation of the data.

  Returns:
    locked flag

### setLock

    public abstract void setLock(int l)

  Locks and unlocks the data reference.

  Parameters:
    `l` - int kind of lock 1 = read lock 2 = write lock

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD