public class XMLDB extends Object
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
| Modifier and Type | Method and Description |
|---|---|
void |
addNode1(String node1_id)
Method description
|
static XMLDB |
createDB(String db_file,
String root_name,
String node1_name)
Method description
|
DBElement |
findNode1(String node1_id)
Method description
|
List<String> |
getAllNode1s()
Method description
|
long |
getAllNode1sCount()
Method description
|
Object |
getData(String node1_id,
String key)
Describe
getData method here. |
Object |
getData(String node1_id,
String subnode,
String key)
Describe
getData method here. |
Object |
getData(String node1_id,
String subnode,
String key,
Object def)
Describe
getData method here. |
double |
getDataDouble(String node1_id,
String subnode,
String key,
double def)
Method description
|
double[] |
getDataDoubleList(String node1_id,
String subnode,
String key)
Method description
|
int |
getDataInt(String node1_id,
String subnode,
String key,
int def)
Method description
|
int[] |
getDataIntList(String node1_id,
String subnode,
String key)
Method description
|
String[] |
getDataList(String node1_id,
String subnode,
String key)
Describe
getDataList method here. |
String |
getDBFileName()
Method description
|
String[] |
getKeys(String node1_id)
Describe
getKeys method here. |
String[] |
getKeys(String node1_id,
String subnode)
Describe
getKeys method here. |
protected DBElement |
getNode(String node1_id,
String subnode,
boolean auto_create)
Method description
|
protected DBElement |
getNode1(String node1_id)
Method description
|
String[] |
getSubnodes(String node1_id)
Describe
getSubnodes method here. |
String[] |
getSubnodes(String node1_id,
String subnode)
Describe
getSubnodes method here. |
protected void |
loadDB()
Method description
|
void |
removeData(String node1_id,
String key)
Describe
removeData method here. |
void |
removeData(String node1_id,
String subnode,
String key)
Describe
removeData method here. |
void |
removeNode1(String node1_id)
Method description
|
void |
removeSubnode(String node1_id,
String subnode)
Describe
removeSubnode method here. |
protected void |
saveDB()
Method description
|
void |
setData(String node1_id,
String key,
Object value)
Describe
setData method here. |
void |
setData(String node1_id,
String subnode,
String key,
Object value)
Describe
setData method here. |
protected void |
setupNewDB(String db_file,
String root_name,
String node1_name)
Method description
|
void |
sync()
Method description
|
public XMLDB(String db_file) throws IOException, XMLDBException
db_file - IOExceptionXMLDBExceptionpublic static XMLDB createDB(String db_file, String root_name, String node1_name)
db_file - root_name - node1_name - public String getDBFileName()
protected void setupNewDB(String db_file, String root_name, String node1_name)
db_file - root_name - node1_name - protected void loadDB()
throws IOException,
XMLDBException
IOExceptionXMLDBExceptionprotected void saveDB()
public final long getAllNode1sCount()
public final DBElement findNode1(String node1_id)
node1_id - protected final DBElement getNode1(String node1_id) throws NodeNotFoundException
node1_id - NodeNotFoundExceptionpublic void addNode1(String node1_id) throws NodeExistsException
node1_id - NodeExistsExceptionpublic void removeNode1(String node1_id) throws NodeNotFoundException
node1_id - NodeNotFoundExceptionprotected final DBElement getNode(String node1_id, String subnode, boolean auto_create) throws NodeNotFoundException
node1_id - subnode - auto_create - NodeNotFoundExceptionpublic void setData(String node1_id, String subnode, String key, Object value) throws NodeNotFoundException
setData method here.node1_id - a String valuesubnode - a String valuekey - a String valuevalue - a String valueNodeNotFoundExceptionpublic void setData(String node1_id, String key, Object value) throws NodeNotFoundException
setData method here.node1_id - a String valuekey - a String valuevalue - a String valueNodeNotFoundExceptionpublic String[] getDataList(String node1_id, String subnode, String key) throws NodeNotFoundException
getDataList method here.node1_id - a String valuesubnode - a String valuekey - a String valueString[] valueNodeNotFoundException - if an error occurspublic int[] getDataIntList(String node1_id, String subnode, String key) throws NodeNotFoundException
node1_id - subnode - key - NodeNotFoundExceptionpublic double[] getDataDoubleList(String node1_id, String subnode, String key) throws NodeNotFoundException
node1_id - subnode - key - NodeNotFoundExceptionpublic Object getData(String node1_id, String subnode, String key, Object def) throws NodeNotFoundException
getData method here.node1_id - a String valuesubnode - a String valuekey - a String valuedef - a String valueString valueNodeNotFoundExceptionpublic int getDataInt(String node1_id, String subnode, String key, int def) throws NodeNotFoundException
node1_id - subnode - key - def - NodeNotFoundExceptionpublic double getDataDouble(String node1_id, String subnode, String key, double def) throws NodeNotFoundException
node1_id - subnode - key - def - NodeNotFoundExceptionpublic Object getData(String node1_id, String subnode, String key) throws NodeNotFoundException
getData method here.node1_id - a String valuesubnode - a String valuekey - a String valueString valueNodeNotFoundExceptionpublic Object getData(String node1_id, String key) throws NodeNotFoundException
getData method here.node1_id - a String valuekey - a String valueString valueNodeNotFoundExceptionpublic String[] getSubnodes(String node1_id, String subnode) throws NodeNotFoundException
getSubnodes method here.node1_id - a String valuesubnode - a String valueString[] valueNodeNotFoundExceptionpublic String[] getSubnodes(String node1_id) throws NodeNotFoundException
getSubnodes method here.node1_id - a String valueString[] valueNodeNotFoundExceptionpublic String[] getKeys(String node1_id, String subnode) throws NodeNotFoundException
getKeys method here.node1_id - a String valuesubnode - a String valueString[] valueNodeNotFoundExceptionpublic String[] getKeys(String node1_id) throws NodeNotFoundException
getKeys method here.node1_id - a String valueString[] valueNodeNotFoundExceptionpublic void removeData(String node1_id, String subnode, String key) throws NodeNotFoundException
removeData method here.node1_id - a String valuesubnode - a String valuekey - a String valueNodeNotFoundExceptionpublic void removeData(String node1_id, String key) throws NodeNotFoundException
removeData method here.node1_id - a String valuekey - a String valueNodeNotFoundExceptionpublic void removeSubnode(String node1_id, String subnode) throws NodeNotFoundException
removeSubnode method here.node1_id - a String valuesubnode - a String valueNodeNotFoundExceptionpublic void sync()
throws IOException
IOExceptionCopyright © 2014 Tigase. All rights reserved.