|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttigase.xml.db.XMLDB
public class XMLDB
XMLDB
is the main database access class.
It allows you to create new database in given file, open database from
given file, add, delete and retrieve data and data lists. All data or data
lists are stored in database nodes. There are three possible kinds of nodes
for each database:
root
' is used.node
' is used.node
' element name and this
can't be changed.All node1 nodes and subnodes can contains any number of
data associated with keys. With some keys there ca be more than one value
assigned. Such kind of data are called data lists.
Although element name for subnode can not be defined it is actually not
important. Because user database doesn't use subnode element names. He doesn't
even use neiher root node element name nor node1 element
name. database user uses node name what is quite different
from node element name. Let see example below:
<node name='roster'/>
In this example node element name is node and
node name is roster.
database users (actually developers) use only node names.
If you want to access subnode on some level you need to give full path to
this subnode. For example, let's assume we have following database:
<node name='tigase'> <node name='server'> </node> <node name='xmpp'> </node> </node>
If you need to access 'server
' subnode you need to call method
with '/tigase/server
' as subnode path and for subnode
'xmpp
' proper subnode path is of course
'/tigase/xmpp
'. If you skip subnode path or give
null
as a parameter you will be accessing data on node1
level. You can not access or save data on root node level.
Created: Tue Oct 26 15:27:33 2004
Constructor Summary | |
---|---|
XMLDB(java.lang.String db_file)
|
Method Summary | |
---|---|
void |
addNode1(java.lang.String node1_id)
|
static XMLDB |
createDB(java.lang.String db_file,
java.lang.String root_name,
java.lang.String node1_name)
|
DBElement |
findNode1(java.lang.String node1_id)
|
java.util.List<java.lang.String> |
getAllNode1s()
|
long |
getAllNode1sCount()
|
java.lang.Object |
getData(java.lang.String node1_id,
java.lang.String key)
Describe getData method here. |
java.lang.Object |
getData(java.lang.String node1_id,
java.lang.String subnode,
java.lang.String key)
Describe getData method here. |
java.lang.Object |
getData(java.lang.String node1_id,
java.lang.String subnode,
java.lang.String key,
java.lang.Object def)
Describe getData method here. |
double |
getDataDouble(java.lang.String node1_id,
java.lang.String subnode,
java.lang.String key,
double def)
|
double[] |
getDataDoubleList(java.lang.String node1_id,
java.lang.String subnode,
java.lang.String key)
|
int |
getDataInt(java.lang.String node1_id,
java.lang.String subnode,
java.lang.String key,
int def)
|
int[] |
getDataIntList(java.lang.String node1_id,
java.lang.String subnode,
java.lang.String key)
|
java.lang.String[] |
getDataList(java.lang.String node1_id,
java.lang.String subnode,
java.lang.String key)
Describe getDataList method here. |
java.lang.String |
getDBFileName()
|
java.lang.String[] |
getKeys(java.lang.String node1_id)
Describe getKeys method here. |
java.lang.String[] |
getKeys(java.lang.String node1_id,
java.lang.String subnode)
Describe getKeys method here. |
protected DBElement |
getNode(java.lang.String node1_id,
java.lang.String subnode,
boolean auto_create)
|
protected DBElement |
getNode1(java.lang.String node1_id)
|
java.lang.String[] |
getSubnodes(java.lang.String node1_id)
Describe getSubnodes method here. |
java.lang.String[] |
getSubnodes(java.lang.String node1_id,
java.lang.String subnode)
Describe getSubnodes method here. |
protected void |
loadDB()
|
void |
removeData(java.lang.String node1_id,
java.lang.String key)
Describe removeData method here. |
void |
removeData(java.lang.String node1_id,
java.lang.String subnode,
java.lang.String key)
Describe removeData method here. |
void |
removeNode1(java.lang.String node1_id)
|
void |
removeSubnode(java.lang.String node1_id,
java.lang.String subnode)
Describe removeSubnode method here. |
protected void |
saveDB()
|
void |
setData(java.lang.String node1_id,
java.lang.String key,
java.lang.Object value)
Describe setData method here. |
void |
setData(java.lang.String node1_id,
java.lang.String subnode,
java.lang.String key,
java.lang.Object value)
Describe setData method here. |
protected void |
setupNewDB(java.lang.String db_file,
java.lang.String root_name,
java.lang.String node1_name)
|
void |
sync()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLDB(java.lang.String db_file) throws java.io.IOException, XMLDBException
java.io.IOException
XMLDBException
Method Detail |
---|
public static XMLDB createDB(java.lang.String db_file, java.lang.String root_name, java.lang.String node1_name)
public java.lang.String getDBFileName()
protected void setupNewDB(java.lang.String db_file, java.lang.String root_name, java.lang.String node1_name)
protected void loadDB() throws java.io.IOException, XMLDBException
java.io.IOException
XMLDBException
protected void saveDB()
public final long getAllNode1sCount()
public final java.util.List<java.lang.String> getAllNode1s()
public final DBElement findNode1(java.lang.String node1_id)
protected final DBElement getNode1(java.lang.String node1_id) throws NodeNotFoundException
NodeNotFoundException
public void addNode1(java.lang.String node1_id) throws NodeExistsException
NodeExistsException
public void removeNode1(java.lang.String node1_id) throws NodeNotFoundException
NodeNotFoundException
protected final DBElement getNode(java.lang.String node1_id, java.lang.String subnode, boolean auto_create) throws NodeNotFoundException
NodeNotFoundException
public void setData(java.lang.String node1_id, java.lang.String subnode, java.lang.String key, java.lang.Object value) throws NodeNotFoundException
setData
method here.
node1_id
- a String
valuesubnode
- a String
valuekey
- a String
valuevalue
- a String
value
NodeNotFoundException
public void setData(java.lang.String node1_id, java.lang.String key, java.lang.Object value) throws NodeNotFoundException
setData
method here.
node1_id
- a String
valuekey
- a String
valuevalue
- a String
value
NodeNotFoundException
public java.lang.String[] getDataList(java.lang.String node1_id, java.lang.String subnode, java.lang.String key) throws NodeNotFoundException
getDataList
method here.
node1_id
- a String
valuesubnode
- a String
valuekey
- a String
value
String[]
value
NodeNotFoundException
- if an error occurspublic int[] getDataIntList(java.lang.String node1_id, java.lang.String subnode, java.lang.String key) throws NodeNotFoundException
NodeNotFoundException
public double[] getDataDoubleList(java.lang.String node1_id, java.lang.String subnode, java.lang.String key) throws NodeNotFoundException
NodeNotFoundException
public java.lang.Object getData(java.lang.String node1_id, java.lang.String subnode, java.lang.String key, java.lang.Object def) throws NodeNotFoundException
getData
method here.
node1_id
- a String
valuesubnode
- a String
valuekey
- a String
valuedef
- a String
value
String
value
NodeNotFoundException
public int getDataInt(java.lang.String node1_id, java.lang.String subnode, java.lang.String key, int def) throws NodeNotFoundException
NodeNotFoundException
public double getDataDouble(java.lang.String node1_id, java.lang.String subnode, java.lang.String key, double def) throws NodeNotFoundException
NodeNotFoundException
public java.lang.Object getData(java.lang.String node1_id, java.lang.String subnode, java.lang.String key) throws NodeNotFoundException
getData
method here.
node1_id
- a String
valuesubnode
- a String
valuekey
- a String
value
String
value
NodeNotFoundException
public java.lang.Object getData(java.lang.String node1_id, java.lang.String key) throws NodeNotFoundException
getData
method here.
node1_id
- a String
valuekey
- a String
value
String
value
NodeNotFoundException
public java.lang.String[] getSubnodes(java.lang.String node1_id, java.lang.String subnode) throws NodeNotFoundException
getSubnodes
method here.
node1_id
- a String
valuesubnode
- a String
value
String[]
value
NodeNotFoundException
public java.lang.String[] getSubnodes(java.lang.String node1_id) throws NodeNotFoundException
getSubnodes
method here.
node1_id
- a String
value
String[]
value
NodeNotFoundException
public java.lang.String[] getKeys(java.lang.String node1_id, java.lang.String subnode) throws NodeNotFoundException
getKeys
method here.
node1_id
- a String
valuesubnode
- a String
value
String[]
value
NodeNotFoundException
public java.lang.String[] getKeys(java.lang.String node1_id) throws NodeNotFoundException
getKeys
method here.
node1_id
- a String
value
String[]
value
NodeNotFoundException
public void removeData(java.lang.String node1_id, java.lang.String subnode, java.lang.String key) throws NodeNotFoundException
removeData
method here.
node1_id
- a String
valuesubnode
- a String
valuekey
- a String
value
NodeNotFoundException
public void removeData(java.lang.String node1_id, java.lang.String key) throws NodeNotFoundException
removeData
method here.
node1_id
- a String
valuekey
- a String
value
NodeNotFoundException
public void removeSubnode(java.lang.String node1_id, java.lang.String subnode) throws NodeNotFoundException
removeSubnode
method here.
node1_id
- a String
valuesubnode
- a String
value
NodeNotFoundException
public void sync() throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |