本文整理汇总了Java中com.hp.hpl.jena.graph.NodeFactory类的典型用法代码示例。如果您正苦于以下问题:Java NodeFactory类的具体用法?Java NodeFactory怎么用?Java NodeFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NodeFactory类属于com.hp.hpl.jena.graph包,在下文中一共展示了NodeFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMaterialTriples
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
public void addMaterialTriples(InstanceGeometry ig){
if(ig.getColors()!=null&&ig.getColors().length>0){
String materials=""+ig.getColors()[0];
for(int i=1;i<ig.getColors().length;i++){
materials=materials+" "+ig.getColors()[i];
}
String indices=""+ig.getMaterialIndices()[0];
for(int i=1;i<ig.getMaterialIndices().length;i++){
indices=indices+" "+ig.getMaterialIndices()[i];
}
Node hasMaterials=NodeFactory.createURI(GEOM.getURI()+"hasMaterials");
Node hasMaterialIndices=NodeFactory.createURI(GEOM.getURI()+"hasMaterialIndices");
getRdfWriter().triple(new Triple(NodeFactory.createURI(baseUri+"Geometry"+"_"+ig.getId()),hasMaterials,NodeFactory.createLiteral(materials)));
getRdfWriter().triple(new Triple(NodeFactory.createURI(baseUri+"Geometry"+"_"+ig.getId()),hasMaterialIndices,NodeFactory.createLiteral((indices))));
}
}
示例2: addGeometryTriples
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
public void addGeometryTriples(InstanceGeometry ig,boolean boundingbox) throws WktWriteException{
Geometry g=toGeometry(ig);
String s=toWKT(g);
getRdfWriter().triple(new Triple(NodeFactory.createURI(baseUri+ig.getType()+"_"+ig.getId()),GEOM.hasGeometry.asNode(),NodeFactory.createURI(baseUri+"Geometry"+"_"+ig.getId())));
getRdfWriter().triple(new Triple(NodeFactory.createURI(baseUri+"Geometry"+"_"+ig.getId()),GEOM.asBody.asNode(),NodeFactory.createLiteral((s))));
Box mvbb=null;
/* if((!g.isEmpty())&&boundingbox){
Box aabb=toAABB(g);
mvbb=toMVBB(g);
if(aabb.getVolume()<mvbb.getVolume()){
System.out.println("Error: AABB: "+ aabb.getVolume()+" | MVBB: "+mvbb.getVolume());
}
getRdfWriter().triple(new Triple(NodeFactory.createURI(baseUri+"Geometry"+"_"+ig.getId()),GEOM.asAABB.asNode(),NodeFactory.createLiteral((toWKT(aabb.toPolyhedralSurface())))));
getRdfWriter().triple(new Triple(NodeFactory.createURI(baseUri+"Geometry"+"_"+ig.getId()),GEOM.asMVBB.asNode(),NodeFactory.createLiteral((toWKT(mvbb.toPolyhedralSurface())))));
}*/
}
示例3: getRelatedSubjects
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
@Override
protected HashSet<Node> getRelatedSubjects(Node node, ExecutionContext execCxt) {
HashSet<Node> results = new HashSet<Node>();
Graph graph = execCxt.getActiveGraph();
Node clazz = NodeFactory.createURI(Namespace.IFC2X3_TC1 + "IfcBuildingStorey");
LinkedList<Storey> storeys = new LinkedList<Storey>();
if (graph.contains(node, RDF.type.asNode(), clazz)) {
Storey storey = new Storey(node, elevation(node, graph));
ExtendedIterator<Triple> triples = graph.find(null, RDF.type.asNode(), clazz);
while (triples.hasNext()) {
Node subject = triples.next().getSubject();
Storey s = new Storey(subject, elevation(subject, graph));
if (s.elevation > storey.elevation) {
addStorey(storeys, s, graph);
}
}
if (storeys.size() > 0) {
results.add(storeys.get(0).storey);
}
}
return results;
}
示例4: getRelatedObjects
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
@Override
protected HashSet<Node> getRelatedObjects(Node node, ExecutionContext execCxt) {
HashSet<Node> results = new HashSet<Node>();
Graph graph = execCxt.getActiveGraph();
Node clazz = NodeFactory.createURI(Namespace.IFC2X3_TC1 + "IfcBuildingStorey");
LinkedList<Storey> storeys = new LinkedList<Storey>();
if (graph.contains(node, RDF.type.asNode(), clazz)) {
Storey storey = new Storey(node, elevation(node, graph));
ExtendedIterator<Triple> triples = graph.find(null, RDF.type.asNode(), clazz);
while (triples.hasNext()) {
Node subject = triples.next().getSubject();
Storey s = new Storey(subject, elevation(subject, graph));
if (s.elevation < storey.elevation) {
addStorey(storeys, s, graph);
}
}
if (storeys.size() > 0) {
results.add(storeys.get(storeys.size() - 1).storey);
}
}
return results;
}
示例5: verifyValue
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
@Override
protected QueryIterator verifyValue(Binding binding, Graph graph, Node product, Geometry geometry, Node object,
ExecutionContext execCxt) {
boolean b = false;
try {
if (product.getLocalName().equals("IfcWallStandardCase_5397")){
System.out.println("");
}
HashSet<Geometry> allGeometries=getProcessableElements(graph);
b = new ExternalQuadTreeImpl(geometry, allGeometries).getIsExternal();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Node node = NodeFactory.createLiteral(Boolean.toString(b), null, XSDDatatype.XSDboolean);
if (node.equals(object)) {
return IterLib.result(binding, execCxt);
} else {
return IterLib.noResults(execCxt);
}
}
示例6: testRule
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
@Test
public void testRule() throws Exception {
Node var = NodeFactory.createAnon();
System.out.println("Node: " + var);
KBCollection varCol = new KBCollectionImpl("http://www.w3.org/2007/rif#var");
RDFNode varRdf = KBObjectImpl.getBaseContextModel().asRDFNode(var);
System.out.println("RDF Node: " + varRdf);
Resource varRes = varRdf.asResource();
System.out.println("Resource: " + varRes.getLocalName() + ", " + varRes.getNameSpace() + ", " + varRes.getURI());
// Individual varInd = ((KBCollectionImpl)varCol).getCore().createIndividual();//.createIndividual(varRes.getURI());
// KBObjectImpl.getBaseContextModel().createIndividual(((KBCollectionImpl)varCol).getCore());
Variable v = new VariableImpl("vijayvar");
System.out.println("Var Name: " + v.getName());
FileWriter fw = new FileWriter("/scratch/WORK2/jena/testModels/test4.xml");
RDFDataMgr.write(fw, KBObjectImpl.getDataset(), RDFFormat.NQUADS);
}
示例7: evaluate
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
TestingSelector testingSelector = (TestingSelector) nodeSelector;
FunctionTest functionTest = (FunctionTest) testingSelector.getTest();
if(functionTest.getArgSelectors().get(0) instanceof PropertySelector) {
PropertySelector arg = (PropertySelector) functionTest.getArgSelectors().get(0);
PropertySelector delegate = (PropertySelector) testingSelector.getDelegate();
Var target = Var.alloc(VarIDGenerator.createID());
elementGroup.addTriplePattern(new Triple(var.asNode(), NodeFactory.createURI(delegate.getProperty().toString()), target));
Var selector = Var.alloc(VarIDGenerator.createID());
elementGroup.addTriplePattern(new Triple(target.asNode(), NodeFactory.createURI(arg.getProperty().toString()), selector.asNode()));
elementGroup.addElementFilter(new ElementFilter(new E_IsLiteral(new ExprVar(selector))));
return selector;
} else {
throw new IllegalStateException("Argument of function isLiteral has to be a PropertySelector");
}
}
示例8: queryClauseToTriple
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
private Triple queryClauseToTriple(Term term, QueryVars queryVars) {
if (term.getArity() == 1) {
Node clas = NodeFactory.createURI(term.getName());
Node object = termToNode(term.getArgument(0),queryVars);
return Triple
.create(object,
NodeFactory
.createURI(HTTP_WWW_W3_ORG_1999_02_22_RDF_SYNTAX_NS_TYPE),
clas);
} else if (term.getArity() == 2) {
Node pred = NodeFactory.createURI(term.getName());
Node subj = termToNode( term.getArgument(0),queryVars);
Node obj = termToNode( term.getArgument(1),queryVars);
return Triple.create(subj, pred, obj);
} else {
return null;
}
}
示例9: test01
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
@Test
public synchronized void test01() throws IOException, NotImplementedException, SQLException {
String metricName = "test01";
metric.setName(metricName);
metric.setParentDimension("parent");
metric.setThreshold(threshold);
metric.initMeasureDataSink();
// not sounding
Node subj = NodeFactory.createURI("http://ex.org/1");
// pain threshold (sounding)
Node pred = NodeFactory.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
// should be ignored
Node obj = NodeFactory.createLiteral("foo");
Triple triple = new Triple(subj, pred, obj);
metric.assessNodes(triple);
assertTrue(sink.nodeMeasureWritten(metricName, TriplePosition.SUBJECT));
assertFalse(sink.nodeMeasureWritten(metricName, TriplePosition.PREDICATE));
assertFalse(sink.nodeMeasureWritten(metricName, TriplePosition.OBJECT));
}
示例10: termToNode
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
private Node termToNode( Term term, QueryVars queryVars) {
if (term instanceof FunctionalTerm) {
try {
URI uri = new URI(term.getName());
return NodeFactory.createURI(uri.toString());
} catch (MalformedURIException e) {
return NodeFactory.createLiteral(term.toString());
}
} else if (term instanceof Variable) {
//Check for blank node
QueryVar queryVar =queryVars.get(term.getMinVariableIndex());
if (queryVar!=null){
return NodeFactory.createURI(HTTP_INOVA8_COM_VARIABLE + queryVar.getName());
}else{
return NodeFactory.createURI(HTTP_INOVA8_COM_BLANKNODE + term.getMinVariableIndex());
}
} else {
return null;
}
}
示例11: test01
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
@Test
public synchronized void test01() throws NotImplementedException, SQLException {
String metricName = "test01";
metric.setName(metricName);
metric.setParentDimension("parent");
metric.setPrefixes(prefixes);
metric.initMeasureDataSink();
Node subj = NodeFactory.createURI("http://" + hostName + ":" + port + okPath);
Node pred = NodeFactory.createURI("http://ex.org/properties/fooProp");
Node obj = NodeFactory.createURI("http://ex.org/Foo");
Triple triple = new Triple(subj, pred, obj);
metric.assessNodes(triple);
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.SUBJECT));
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.PREDICATE));
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.OBJECT));
}
示例12: test02
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
@Test
public synchronized void test02() throws NotImplementedException, SQLException {
String metricName = "test02";
metric.setName(metricName);
metric.setParentDimension("parent");
metric.setPrefixes(prefixes);
metric.initMeasureDataSink();
Node subj = NodeFactory.createURI("http://ex.org/foo/bar");
Node pred = NodeFactory.createURI("http://" + hostName + ":" + port + okPath);
Node obj = NodeFactory.createURI("http://ex.org/Foo");
Triple triple = new Triple(subj, pred, obj);
metric.assessNodes(triple);
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.SUBJECT));
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.PREDICATE));
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.OBJECT));
}
示例13: test03
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
@Test
public synchronized void test03() throws NotImplementedException, SQLException {
String metricName = "test03";
metric.setName(metricName);
metric.setParentDimension("parent");
metric.setPrefixes(prefixes);
metric.initMeasureDataSink();
Node subj = NodeFactory.createURI("http://ex.org/foo/bar");
Node pred = NodeFactory.createURI("http://ex.org/properties/fooProp");
Node obj = NodeFactory.createURI("http://" + hostName + ":" + port + okPath);
Triple triple = new Triple(subj, pred, obj);
metric.assessNodes(triple);
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.SUBJECT));
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.PREDICATE));
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.OBJECT));
}
示例14: test05
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
@Test
public synchronized void test05() throws NotImplementedException, SQLException {
String metricName = "test05";
metric.setName(metricName);
metric.setParentDimension("parent");
metric.setPrefixes(prefixes);
metric.initMeasureDataSink();
Node subj = NodeFactory.createURI("http://ex.org/foo/bar");
Node pred = NodeFactory.createURI("http://" + hostName + ":" + port + redirectPath);
Node obj = NodeFactory.createURI("http://ex.org/Foo");
Triple triple = new Triple(subj, pred, obj);
metric.assessNodes(triple);
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.SUBJECT));
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.PREDICATE));
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.OBJECT));
}
示例15: test06
import com.hp.hpl.jena.graph.NodeFactory; //导入依赖的package包/类
@Test
public synchronized void test06() throws NotImplementedException, SQLException {
String metricName = "test06";
metric.setName(metricName);
metric.setParentDimension("parent");
metric.setPrefixes(prefixes);
metric.initMeasureDataSink();
Node subj = NodeFactory.createURI("http://ex.org/foo/bar");
Node pred = NodeFactory.createURI("http://ex.org/properties/fooProp");
Node obj = NodeFactory.createURI("http://" + hostName + ":" + port + redirectPath);
Triple triple = new Triple(subj, pred, obj);
metric.assessNodes(triple);
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.SUBJECT));
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.PREDICATE));
assertFalse(((BooleanTestingSink) sink).nodeMeasureWritten(metricName,
TriplePosition.OBJECT));
}