Java Code Examples for com.hp.hpl.jena.graph.Node#createLiteral()

The following examples show how to use com.hp.hpl.jena.graph.Node#createLiteral() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JenaGraphExample.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	// Load mapping file
	Model mapModel = FileManager.get().loadModel("doc/example/mapping-iswc.ttl");
	
	// Read mapping file
	D2RQReader reader = new D2RQReader(mapModel, "http://localhost:2020/");
	Mapping mapping = reader.getMapping();
	
	// Compile mapping for D2RQ engine
	CompiledMapping compiled = mapping.compile();

	// Set up the GraphD2RQ
	GraphD2RQ g = new GraphD2RQ(compiled);

	// Create a find(spo) pattern 
	Node subject = Node.ANY;
	Node predicate = DC.date.asNode();
	Node object = Node.createLiteral("2003", null, XSDDatatype.XSDgYear);
	Triple pattern = new Triple(subject, predicate, object);

	// Query the graph
	Iterator<Triple> it = g.find(pattern);
	
	// Output query results
	while (it.hasNext()) {
		Triple t = it.next();
	    System.out.println("Published in 2003: " + t.getSubject());
	}
	g.close();
}
 
Example 2
Source File: TypedNodeMaker.java    From GeoTriples with Apache License 2.0 4 votes vote down vote up
public Node makeNode(String value) {
	return Node.createLiteral(value, this.language, this.datatype);
}
 
Example 3
Source File: TypedNodeMaker.java    From GeoTriples with Apache License 2.0 4 votes vote down vote up
public Node makeNode(String value) {
	if (!XSDDatatype.XSDdate.isValid(value)) return null;
	return Node.createLiteral(value, null, XSDDatatype.XSDdate);
}
 
Example 4
Source File: TypedNodeMaker.java    From GeoTriples with Apache License 2.0 4 votes vote down vote up
public Node makeNode(String value) {
	if (!XSDDatatype.XSDtime.isValid(value)) return null;
	return Node.createLiteral(value, null, XSDDatatype.XSDtime);
}
 
Example 5
Source File: TypedNodeMaker.java    From GeoTriples with Apache License 2.0 4 votes vote down vote up
public Node makeNode(String value) {
	if (!XSDDatatype.XSDdateTime.isValid(value)) return null;
	return Node.createLiteral(value, null, XSDDatatype.XSDdateTime);
}