The e4Graph Java Binding

This page provides an overview of the classes comprising the Java binding for e4Graph.

The Java API consists of classes representing the main entities of e4Graph: Storage, Node, and Vertex. Each of these classes provides methods for invoking the various operations provided by the underlying e4Graph classes. The classes StorageIterator, VertexIterator and ParentIterator allow a client program to iterate over all open storages, over vertices in a node and over parent nodes of a node, respectively.

Here's a small example similar to the C++ example on the introduction page.

Storage s = new Storage("John's grocery store", Storage.METAKIT);
Node root;
Node items;
Node sugar;
double price_per_pound;
int pound_in_store;

try {
    root = s.getRoot();
    items = root.getNode("on hand items");
    sugar = items.getNode("sugar");
    pounds_in_store = sugar.getInt("pounds in store");
    price_per_pound = sugar.getDouble("price per pound");
    System.out.println("John's store has " + pounds_in_store +
		       " pounds of sugar at " + price_per_pound +
		       " per pound");
    sugar.setDouble("price per pound", price_per_pound+0.05);
} catch (...) {
    ...
}
All of this corresponds exactly to the C++ example, except for error handling. In Java, errors are propagated by throwing exceptions.