|
Framework Professional Edition Package |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface DB
DB interface allows access to a tree database, where each bundle has its own branch. Bundles are prevented from accessing data, located in another branch. Operations over the database are storing and reading of String, Boolean, Integer, Long, Byte, Short, Character, Double, Float objects and all primitive arrays; searching an entity - a node in the tree with or without associated value.
| Field Summary | |
|---|---|
static byte |
ALL
Defines ALL type. |
static byte |
BOOLEAN
Defines Boolean or boolean type. |
static byte |
BYTE
Defines Byte or byte type. |
static byte |
CHARACTER
Defines Character or char type. |
static byte |
DAMAGED
A write error has occured while writing this node FIXME: check usage, eclipse reports that it is not used anywhere |
static byte |
DOUBLE
Defines Double or double type. |
static byte |
EMPTY
Defines no type. |
static byte |
EXTERN
Defines Externalizable value type. |
static byte |
FLOAT
Defines Float or float type. |
static byte |
INT
Defines Integer or int type. |
static byte |
KEY
Defines KEY type. |
static byte |
LONG
Defines Long or long type. |
static byte |
NODE
Defines NODE type. |
static byte |
SHORT
Defines Short or short type. |
static byte |
STRING
Defines String type. |
| Method Summary | |
|---|---|
void |
delete(java.lang.String[] name)
Deletes the node name and all of its descendants from the DB. |
double |
getDoubleValue(java.lang.String[] name)
This method is used to directly read a value of a node that is of type DOUBLE |
int |
getIntValue(java.lang.String[] name)
This method is used to directly read a value of a node that is of type INT |
long |
getLongValue(java.lang.String[] name)
This method is used to directly read a value of a node that is of type LONG |
DBNode |
getNode(java.lang.String[] name)
Retrieves the node implementation. |
byte |
getType(java.lang.String[] name)
Gets the type of the node. |
java.lang.Object |
getValue(java.lang.String[] name)
Gets a value with key name. |
int |
getValue(java.lang.String[] name,
byte[] byteArray,
int off,
int length)
Reads length bytes from the value, associated
with the key name and writes them at off
position in the byteArray. |
void |
getValue(java.lang.String[] name,
com.prosyst.util.io.Externalizable value)
Reads an Externalizable value with key name. |
boolean |
isArray(java.lang.String[] name)
Checks if the value associated with this name is an array or not. |
boolean |
isPresent(java.lang.String[] name)
Checks if the key name is present in the DB. |
java.lang.String[] |
list(java.lang.String[] name,
byte listWhat)
Lists the private names of name node's children. |
void |
lock()
Lock the DB and prevents other applications from writing some node information. |
void |
move(java.lang.String[] name,
java.lang.String[] newParent)
Moves a subtree starting from name to a new parent - newParent |
void |
save()
Manually instructs the DB implementation to save its current state. |
void |
setValue(java.lang.String[] name,
double value)
Saves a double value, to the node with the specified name and automatically sets the node type to DOUBLE |
void |
setValue(java.lang.String[] name,
int value)
Saves an integer value, to the node with the specified name and automatically sets the node type to INT |
void |
setValue(java.lang.String[] name,
long value)
Saves a long value, to the node with the specified name and automatically sets the node type to LONG |
void |
setValue(java.lang.String[] name,
java.lang.Object val,
byte type)
Saves the value, associating it with the name. |
void |
unlock()
Unlock the DB and allows other threads to perform write operations. |
| Field Detail |
|---|
static final byte EMPTY
static final byte STRING
static final byte INT
static final byte SHORT
static final byte LONG
static final byte BOOLEAN
static final byte BYTE
static final byte CHARACTER
static final byte FLOAT
static final byte DOUBLE
static final byte EXTERN
Externalizable value type.
Used when storing or getting a value.
static final byte DAMAGED
static final byte NODE
static final byte KEY
static final byte ALL
| Method Detail |
|---|
void setValue(java.lang.String[] name,
java.lang.Object val,
byte type)
throws java.io.IOException
Externalizable, it must have implemented its writeObject method,
so that DB will be able to call it in order to save its data.
name - key to associate the value withval - value to save; may be:
String, Integer, Long, Boolean, Byte,
Short, Character, Double, Float, Externalizable,
or the corresponding primitive arrays if available.
Note that String[] and Externalizable[] types are not supported.type - data type, may be: STRING, INT, LONG
BOOLEAN, BYTE, SHORT, CHARACTER,
DOUBLE, FLOAT, EXTERN or EMPTY
java.io.IOException - If an IO error occurs.
java.lang.IllegalArgumentException - If the supplied type is not a valid one
java.lang.SecurityException - if Externalizable object creates
ObjectOutputStream that requires SerializablePermission
void setValue(java.lang.String[] name,
int value)
throws java.io.IOException
INT
name - key to associate the value withvalue - the value of the node
java.io.IOException - If an IO error occurs.
void setValue(java.lang.String[] name,
long value)
throws java.io.IOException
LONG
name - key to associate the value withvalue - the value of the node
java.io.IOException - If an IO error occurs.
void setValue(java.lang.String[] name,
double value)
throws java.io.IOException
DOUBLE
name - key to associate the value withvalue - the value of the node
java.io.IOException - If an IO error occurs.
java.lang.Object getValue(java.lang.String[] name)
throws java.io.IOException
name.
name - key with with the target value is associated with.
null if there is no
such node, or the node's type EMPTY.
java.io.IOException - If an I/O error occurs.
java.lang.IllegalArgumentException - If the node's type is EXTERN
void getValue(java.lang.String[] name,
com.prosyst.util.io.Externalizable value)
throws java.io.IOException,
java.lang.IllegalArgumentException
Externalizable value with key name. To be able
to read the data, DB needs an Externalizable object with readValue implemented.
name - key with with the target value is associated withvalue - an empty Externalizable instance, whose data will
be filled in by the DB, if it has properly
implemented its Externalizable.readObject(java.io.InputStream) method.
java.io.IOException - If an IO error occurs.
java.lang.IllegalArgumentException - if there is no such node, or the node's type is
EMPTY
int getValue(java.lang.String[] name,
byte[] byteArray,
int off,
int length)
throws java.io.IOException
length bytes from the value, associated
with the key name and writes them at off
position in the byteArray.
name - key, with which the target value is associated.byteArray - where data is read tooff - start position to write in byteArray length - count of bytes to read
EMPTY or
there is no such node
java.io.IOException - If an IO error occurs.
java.lang.IndexOutOfBoundsException - If length is not valid for the supplied
byteArray and length
int getIntValue(java.lang.String[] name)
throws java.io.IOException
INT
name - the name of the node
java.io.IOException - on I/O error
java.lang.IllegalArgumentException - if there is no such node, or the node type
is not INT
long getLongValue(java.lang.String[] name)
throws java.io.IOException
LONG
name - the name of the node
java.io.IOException - on I/O error
java.lang.IllegalArgumentException - if there is no such node, or the node type
is not LONG
double getDoubleValue(java.lang.String[] name)
throws java.io.IOException
DOUBLE
name - the name of the node
java.io.IOException - on I/O error
java.lang.IllegalArgumentException - if there is no such node, or the node type
is not DOUBLE
boolean isPresent(java.lang.String[] name)
throws java.io.IOException
name is present in the DB.
name - node to check if present
java.io.IOException - If an IO error occurs.
void delete(java.lang.String[] name)
throws java.io.IOException
name and all of its descendants from the DB.
name - node to be deleted
java.io.IOException - If an IO error occurs.
java.lang.String[] list(java.lang.String[] name,
byte listWhat)
throws java.io.IOException
name - node to list children of.listWhat - filter, may be: NODE, KEY, ALL
java.io.IOException - If an IO error occurs.
byte getType(java.lang.String[] name)
throws java.io.IOException
name - key of node.
STRING, INT, LONG
BOOLEAN, BYTE, SHORT, CHARACTER,
DOUBLE, FLOAT, EXTERN or EMPTY
java.io.IOException - If such node does not exist, or an IO error occurs.
boolean isArray(java.lang.String[] name)
throws java.io.IOException
name - key of node
java.io.IOException - if node does not exist or an IO error occurs.
void move(java.lang.String[] name,
java.lang.String[] newParent)
throws java.io.IOException
name to a new parent - newParent
name - The name of the root of the subtree to movenewParent - The name of the node, under which the subtree will be moved
java.io.IOException - If the target name node or the newParent node is
not present, or if the target name node is the DB root note,
or if an IO error occurs.
DBNode getNode(java.lang.String[] name)
throws java.io.IOException
name - the node name
java.io.IOException - on I/O errorvoid lock()
void unlock()
void save()
throws java.io.IOException
java.io.IOException
|
Framework Professional Edition Package |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||