mulgara - semantic store

skip navigation


Creating Nodes and Triples

Nodes and tiples are created using a GraphElementFactory that is obtained from a JRDF graph using the graph's getElementFactory() method. The following code creates example nodes and triples:

//get the Factory
GraphElementFactory elementFactory = graph.getElementFactory();

//create resources
URIReference person = elementFactory.createResource(new URI(""));
BlankNode address = elementFactory.createResource();

//create properties
URIReference hasAddress = elementFactory.createResource(new URI(""));
URIReference hasStreet = elementFactory.createResource(new URI(""));
URIReference hasCity = elementFactory.createResource(new URI(""));
URIReference hasState = elementFactory.createResource(new URI(""));
URIReference hasPostCode = elementFactory.createResource
(new URI(""));

//create values
Literal street = elementFactory.createLiteral("1501 Grant Avenue");
Literal city = elementFactory.createLiteral("Bedford");
Literal state = elementFactory.createLiteral("Massachusetts");
Literal postCode = elementFactory.createLiteral("01730");

//create statements
Triple addressStatement = elementFactory.createTriple(person, hasAddress, address);
Triple streetStatement = elementFactory.createTriple(address, hasStreet, street);
Triple cityStatement = elementFactory.createTriple(address, hasCity, city);
Triple stateStatement = elementFactory.createTriple(address, hasState, state);
Triple postCodeStatement = elementFactory.createTriple(address, hasPostCode, postCode);

Valid XHTML 1.0 TransitionalValid CSS 3.0!