mulgara - semantic store

skip navigation

SHOW SITE NAV
fixed
fluid
straight

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("http://example.org/staffid#85740"));
BlankNode address = elementFactory.createResource();

//create properties
URIReference hasAddress = elementFactory.createResource(new URI("http://example.org/terms#address"));
URIReference hasStreet = elementFactory.createResource(new URI("http://example.org/terms#street"));
URIReference hasCity = elementFactory.createResource(new URI("http://example.org/terms#city"));
URIReference hasState = elementFactory.createResource(new URI("http://example.org/terms#state"));
URIReference hasPostCode = elementFactory.createResource
(new URI("http://example.org/terms#postalCode"));

//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!