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


Java Node.ANY屬性代碼示例

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


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

示例1: main

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,代碼行數:30,代碼來源:JenaGraphExample.java

示例2: selectWithVariables

/**
 * Creates a {@link NodeRelation} by applying a triple pattern
 * to the TripleRelation. If the triple contains variables, then
 * the variables will be bound to the corresponding values
 * in the resulting NodeRelation. {@link Node#ANY} will be
 * converted to a variable "subject", "predicate", "object"
 * depending on its position in the triple pattern.
 * 
 * For example, selecting (?x :name ?name) would produce a
 * NodeRelation with ?x bound to the subjects and ?name bound to the
 * objects of this TripleRelation.
 * 
 * TODO This is never called at the moment. Why!?
 * 
 * @param t A triple pattern involving variables
 * @return A NodeRelation over the variables occurring in the triple pattern 
 */
public TripleRelation selectWithVariables(Triple t) {
	// Select non-variable parts of the triple
	TripleRelation selected = selectTriple(t);
	
	// Replace Node.ANY with "subject", "predicate", "object"
	Node s = t.getSubject() == Node.ANY ? SUBJECT : t.getSubject();
	Node p = t.getPredicate() == Node.ANY ? PREDICATE : t.getPredicate();
	Node o = t.getObject() == Node.ANY ? OBJECT : t.getObject();
	
	// Collect variable names and their bound node makers 
	VariableConstraints nodeMakers = new VariableConstraints();
	nodeMakers.addIfVariable(s, nodeMaker(SUBJECT), baseRelation().aliases());
	nodeMakers.addIfVariable(p, nodeMaker(PREDICATE), baseRelation().aliases());
	nodeMakers.addIfVariable(o, nodeMaker(OBJECT), baseRelation().aliases());

	// Did the same variable occur more than once in the pattern, rendering it unsatisfiable?
	if (!nodeMakers.satisfiable()) {
		return TripleRelation.EMPTY;
	}
	
	MutableRelation mutator = new MutableRelation(selected.baseRelation());

	Expression constraint = nodeMakers.constraint();
	if (!constraint.isTrue()) {
		// Same variable occured more than once, so we add a constraint to the base relation 
		mutator.select(constraint);
	}
	
	mutator.project(nodeMakers.allProjections());
	return fromNodeRelation(new NodeRelation(
			mutator.immutableSnapshot(), nodeMakers.toMap()));
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:49,代碼來源:TripleRelation.java

示例3: main

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,代碼行數:27,代碼來源:JenaGraphExample.java

示例4: toNode

private Node toNode(RDFNode n) {
	return n == null ? Node.ANY : n.asNode();
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:3,代碼來源:FindTest.java

示例5: toNode

private Node toNode(RDFNode n) {
	if (n == null) {
		return Node.ANY;
	}
	return n.asNode();
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:6,代碼來源:FindTestFramework.java


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