BTree | |||||
Home | BTree Guide | BTree Performance | Sample Applications | BTree Roadmap | Other Products |
This documentation is supplied as an example of the functionality available with the full distribution.
A sample application class is supplied with the Java implementation of the BTree which illustrates the basic BTree access methods provided. The demo allows you to add , get and remove data from a BTree as well as listing all the indices that start with a particular character sequence. On exiting from the screen (provided you use the exit bar at the bottom of the screen) your data will be saved but note that a brand new dataset will be opened the next time you run the code.
The most important methods in BTreeDemo relating to the use of the BTree are shown below -
This method illustrates the creation of the BTree prior to the addition of data.
private com.virtualmachinery.btree.interfaces.BTreeInterface getBTree() { if (ivjBTree == null) { try { ivjBTree = com.virtualmachinery.btree.btree.BTree.createNewTree("Test"); } catch (java.lang.Throwable ivjExc) { handleException(ivjExc); } } return ivjBTree; } |
This method illustrates the use of the put method. Note the handling of the BTreeInformation Exception which will be thrown if an index has already been added to the BTree.
public void addButton_ActionPerformed(String index, String data) { try { getBTree().put(index,data); } catch (com.virtualmachinery.btree.exceptions.BTreeInformationException be) { System.out.println(be); } catch (com.virtualmachinery.btree.exceptions.BTreeException be) { handleException(be); } } |
This method illustrates the use of the get method.
public void getButton_ActionPerformed(String index) { String dat=""; try { dat = getBTree().get(index); } catch (com.virtualmachinery.btree.exceptions.BTreeException be) { handleException(be); } if (dat !=null) { getdataText().setText(dat);} else { getdataText().setText("");} } |
This method illustrates the use of the getIndicesStartingWith method. The maximum limit is set to 1000 records.
public void refreshButton_ActionPerformed(String start) { try { String[] result = getBTree().getIndicesStartingWith(start, 1000); this.addItems(result); } catch (com.virtualmachinery.btree.exceptions.BTreeException be) { handleException(be); } } |
This method illustrates the use of the remove method. Note the handling of the BTreeInformation Exception which will be thrown if an attempt is made to remove a non-existent index.
public void removeButton_ActionPerformed(String index) { try { getBTree().remove(index); } catch (com.virtualmachinery.btree.exceptions.BTreeInformationException be) { System.out.println(be); } catch (com.virtualmachinery.btree.exceptions.BTreeException be) { handleException(be); } } |