當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.createLiteral方法代碼示例

本文整理匯總了Java中com.hp.hpl.jena.graph.Node.createLiteral方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.createLiteral方法的具體用法?Java Node.createLiteral怎麽用?Java Node.createLiteral使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hp.hpl.jena.graph.Node的用法示例。


在下文中一共展示了Node.createLiteral方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: creatRDF

import com.hp.hpl.jena.graph.Node; //導入方法依賴的package包/類
private static void creatRDF(String[] line) {
    String s = line[0];
    String p = line[1];
    String o = line[2];

    Node nodeS = Node.createURI(s);
    Node nodeP = Node.createURI("<" + p + ">");
    Node nodeO = null;

    if (o.contains("http")) {
        nodeO = Node.createURI("<" + o + ">");
    } else if (o.contains(".")) {
        //double
        NodeFactoryExtra c = new NodeFactoryExtra();
        nodeO = c.doubleToNode(Double.parseDouble(o));
    } else {
        nodeO = Node.createLiteral(o);
    }
    Triple triple = Triple.create(nodeS, nodeS, nodeS);

    //Statement sta = ResourceFactory.createStatement(s, p, o);
    graph.add(triple);

}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:25,代碼來源:DataRdfizer.java

示例2: main

import com.hp.hpl.jena.graph.Node; //導入方法依賴的package包/類
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();
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:31,代碼來源:JenaGraphExample.java

示例3: convertStr

import com.hp.hpl.jena.graph.Node; //導入方法依賴的package包/類
private void convertStr(E_Str expr)
{
	logger.debug("convertStr " + expr.toString());
	
	expr.getArg().visit(this);
	
	Expression arg = expression.pop();
	
	if (arg instanceof AttributeExprEx) {
		// make a new AttributeExprEx with changed NodeMaker, which returns plain literal
		// TODO this seems to work, but needs more testing.
		AttributeExprEx attribute = (AttributeExprEx) arg;
		TypedNodeMaker nodeMaker = (TypedNodeMaker) attribute.getNodeMaker();
		TypedNodeMaker newNodeMaker = new TypedNodeMaker(TypedNodeMaker.PLAIN_LITERAL, nodeMaker.valueMaker(), nodeMaker.isUnique());
		logger.debug("changing nodemaker " + nodeMaker + " to " + newNodeMaker);
		expression.push(new AttributeExprEx((Attribute) attribute.attributes().iterator().next(), newNodeMaker));
	} else if (arg instanceof ConstantEx) {
		ConstantEx constant = (ConstantEx) arg;
		Node node = constant.getNode();
		String lexicalForm = node.getLiteral().getLexicalForm();
		node = Node.createLiteral(lexicalForm);
		ConstantEx constantEx = new ConstantEx(NodeValue.makeNode(node).asString(), node);
		logger.debug("pushing " + constantEx);
		expression.push(constantEx);
	} else {
		conversionFailed(expr);
	}
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:29,代碼來源:TransformExprToSQLApplyer.java

示例4: main

import com.hp.hpl.jena.graph.Node; //導入方法依賴的package包/類
public static void main(String[] args) {
	// Load mapping file
	Model mapModel = FileManager.get().loadModel("doc/example/mapping-iswc.ttl");
	
	// Parse mapping file
	MapParser parser = new MapParser(mapModel, "http://localhost:2020/");
	Mapping mapping = parser.parse();
	
	// Set up the GraphD2RQ
	GraphD2RQ g = new GraphD2RQ(mapping);

	// 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();
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:28,代碼來源:JenaGraphExample.java

示例5: makeNode

import com.hp.hpl.jena.graph.Node; //導入方法依賴的package包/類
public Node makeNode(String value) {
	return Node.createLiteral(value, this.language, this.datatype);
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:4,代碼來源:TypedNodeMaker.java

示例6: cast

import com.hp.hpl.jena.graph.Node; //導入方法依賴的package包/類
public static Node cast(Node numeric, RDFDatatype datatype)
{
	return  Node.createLiteral(numeric.getLiteralLexicalForm(), null, datatype);
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:5,代碼來源:XSD.java


注:本文中的com.hp.hpl.jena.graph.Node.createLiteral方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。