当前位置: 首页>>代码示例>>Java>>正文


Java NodeFactory.createURI方法代码示例

本文整理汇总了Java中org.apache.jena.graph.NodeFactory.createURI方法的典型用法代码示例。如果您正苦于以下问题:Java NodeFactory.createURI方法的具体用法?Java NodeFactory.createURI怎么用?Java NodeFactory.createURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jena.graph.NodeFactory的用法示例。


在下文中一共展示了NodeFactory.createURI方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromThrift

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
public static Node fromThrift(RDF_Term term) {
    if ( term.isSetIri() )
        return NodeFactory.createURI(term.getIri().getIri()) ;

    if ( term.isSetBnode() )
        return NodeFactory.createBlankNode(term.getBnode().getLabel()) ;

    if ( term.isSetLiteral() ) {
        RDF_Literal lit = term.getLiteral() ;
        String lex = lit.getLex() ;
        String dtString = null ;
        if ( lit.isSetDatatype() )
            dtString = lit.getDatatype() ;
        RDFDatatype dt = NodeFactory.getType(dtString) ;

        String lang = lit.getLangtag() ;
        return NodeFactory.createLiteral(lex, lang, dt) ;
    }

    throw new PatchException("No conversion to a Node: "+term.toString()) ;
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:22,代码来源:RDFPatchReaderBinary.java

示例2: next

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
@Override
public Quad next() {
    QuerySolution solution = results.next();
    Node s = solution.get("s").asNode();
    Node p = solution.get("p").asNode();
    Node o = solution.get("o").asNode();
    Node g = null;
    if (solution.get("g") != null) {
        g = solution.get("g").asNode();
    } else {
        if (graphName != null) {
            g = NodeFactory.createURI(graphName);
        }
    }
    Quad quad = new Quad(g, s, p, o);
    return quad;
}
 
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:18,代码来源:QuadsIterator.java

示例3: testStringAskQuery2

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
@Test
public void testStringAskQuery2() {

	String file = datasource + "tigers.ttl";
	// Read triples into dataset
	RDFDataMgr.read(markLogicDatasetGraph, file);
	markLogicDatasetGraph.sync();
	Graph g = markLogicDatasetGraph.getDefaultGraph();
	Node newgraph = NodeFactory.createURI("http://marklogic.com/Graph1");
	markLogicDatasetGraph.addGraph(newgraph, g);
	dataSet = DatasetFactory.create(markLogicDatasetGraph);

	String query1 = "ASK FROM <http://marklogic.com/Graph1>" + " WHERE" + " {" + " ?player ?team <#Tigers>." + " }";
	QueryExecution queryExec = QueryExecutionFactory.create(query1, dataSet);
	Boolean result = queryExec.execAsk();
	assertFalse(result);

	String query2 = "PREFIX  bb: <http://marklogic.com/baseball/players#>" + "PREFIX  r: <http://marklogic.com/baseball/rules#>"
			+ " ASK WHERE" + " {" + " ?id bb:team r:Tigers." + " ?id bb:position \"pitcher\"." + " }";
	queryExec = QueryExecutionFactory.create(query2, dataSet);
	assertTrue(queryExec.execAsk());

}
 
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:24,代码来源:JenaSPARQLUpdateTests.java

示例4: testDelete_admin

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
@Test
public void testDelete_admin() {
	Triple triple = new Triple(NodeFactory.createURI("s5"), NodeFactory.createURI("p5"), NodeFactory.createURI("o5"));
	Quad quad = new Quad(NodeFactory.createURI("new-graph-fordefault2"), triple);
	Node n2 = NodeFactory.createURI("new-graph-fordefault2");
	markLogicDatasetGraphWriter.add(quad);
	markLogicDatasetGraphWriter.sync();
	Graph g3 = markLogicDatasetGraphWriter.getGraph(n2);
	g3.delete(triple);
	markLogicDatasetGraphWriter.sync();
	assertTrue("did not match Triples", g3.size() == 0);

	markLogicDatasetGraphWriter.delete(quad);
	assertTrue("Quad Should be deleted , but looks like its not", !markLogicDatasetGraphWriter.contains(quad));

	markLogicDatasetGraphWriter.setDefaultGraph(g3);
	Graph defaultG = markLogicDatasetGraphWriter.getDefaultGraph();
	assertTrue("did not match Triples", defaultG.size() == 0);
}
 
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:20,代码来源:JenaGraphTests.java

示例5: pureMemNT

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
public static void pureMemNT() {
    TDBBuilder builder = TDBBuilder.create(Location.mem()) ;
    NodeTable nt = builder.buildBaseNodeTable("nodes") ;
    builder.getTxnCoord().start() ;
    builder.getTxnCoord().begin(ReadWrite.WRITE) ;
    
    ProgressMonitor plog = ProgressMonitor.create(LoggerFactory.getLogger("Dev"), "Nodes", 100000, 10) ;
    plog.start(); 
    int N = 2000000 ;
    for ( int i = 0 ; i < N ; i++ ) {
        Node n = NodeFactory.createURI("http://example/node-"+i) ;
        nt.getAllocateNodeId(n) ;
        plog.tick();
    }
    plog.finish() ;
    plog.finishMessage();
}
 
开发者ID:afs,项目名称:lizard,代码行数:18,代码来源:PerfNodeTableBatches.java

示例6: batched

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
private static void batched(TClientNode client, int batchSize, int repeats) {
    // Multiple/batched.
    unique++ ;
    client.begin(999, ReadWrite.WRITE) ;
    List<Node> nodes = new ArrayList<>(batchSize) ;
    for ( int i = 0 ; i < repeats ; i++ ) {
        nodes.clear() ;
        for ( int j = 0 ; j < batchSize ; j++ ) {
            Node n = NodeFactory.createURI("http://example/n-"+unique+"-"+i+"-"+j) ;
            nodes.add(n) ;
        }
        List<NodeId> nodeIds = client.allocateNodeIds(nodes, true) ;
        //List<Node> nodes2 = client.lookupNodeIds(nodeIds) ;
    }
    client.commit();
    client.end();
}
 
开发者ID:afs,项目名称:lizard,代码行数:18,代码来源:PerfNodeTableBatches.java

示例7: createNode

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
private Node createNode(Map<String, Object> map) {
    String type = (String)map.get("type") ;
    String lex = (String)map.get("value") ;
    if ( type.equals(IRI) )
        return NodeFactory.createURI(lex);
    else if ( type.equals(BLANK_NODE) )
        return labels.get(null, lex) ;  //??
    else if ( type.equals(LITERAL) ) {
        String lang = (String)map.get("language") ;
        String datatype = (String)map.get("datatype") ;
        if ( Objects.equals(xsdString, datatype) )
            // In RDF 1.1, simple literals and xsd:string are the same.
            // During migration, we prefer simple literals to xsd:strings. 
            datatype = null ;
        if ( lang == null && datatype == null )
            return NodeFactory.createLiteral(lex);
        if ( lang != null )
            return NodeFactory.createLiteral(lex, lang);
        RDFDatatype dt = NodeFactory.getType(datatype) ;
        return NodeFactory.createLiteral(lex, dt);
    } else
        throw new InternalErrorException("Node is not a IRI, bNode or a literal: " + type) ;
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:24,代码来源:JenaTripleCallBack.java

示例8: bindParameters

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
protected BindingEnv bindParameters(ConverterProcess proc, BindingEnv row, int rowNumber) {
    BindingEnv env = new BindingEnv(row);
    for (Map<String, Pattern> bindingSet : parameters) {
        for (Entry<String, Pattern> ent : bindingSet.entrySet()) {
            try {
                proc.debugCheck(env, rowNumber, ent.getValue());
                Object value = ent.getValue().evaluate(env, proc, rowNumber);
                env.put(ent.getKey(), value);
            } catch (NullResult e) {
                // fall through to allow missing bindings
                
                // TODO was an abort - 
                // throw new NullResult("Failed to bind variable " + ent.getKey());
            }
        }
    }
    
    // Fix up dataset binding in-case the BIND has changed the $base
    Object baseURI = env.get(ConverterProcess.BASE_OBJECT_NAME);
    if (baseURI != null && !baseURI.toString().isEmpty()) {
        Node dataset = NodeFactory.createURI(baseURI.toString());
        env.put(ConverterProcess.DATASET_OBJECT_NAME, dataset);
    }

    return env;
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:27,代码来源:ParameterizedTemplate.java

示例9: fetch

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
public Value fetch(String...strings) {
    ConverterProcess proc = ConverterProcess.get();
    String uri = asURI();
    Model model = proc.fetchModel(uri);
    if (model != null) {
        StreamRDF out = proc.getOutputStream();
        for (String puri : strings) {
            puri = proc.getDataContext().getPrefixes().expandPrefix(puri);
            Node p = NodeFactory.createURI(puri);
            Node s = NodeFactory.createURI(uri );
            ExtendedIterator<Triple> it = model.getGraph().find(s, p, null);
            while (it.hasNext()) {
                out.triple(it.next());
            }
        }
    }
    return this;
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:19,代码来源:ValueBase.java

示例10: asURINode

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
/**
 * Convert a pattern result to a resource Node or
 * raise an exception if this is not possible.
 */
public Node asURINode(Object result) {
    if (result instanceof String || result instanceof ValueString) {
        return NodeFactory.createURI( result.toString() );
    } 
    Node n = null;
    if (result instanceof Value) {
        n = ((Value)result).asNode();
    } else if (result instanceof Node) {
        n = (Node) result;
    } else if (result instanceof RDFNodeWrapper) {
        n = ((RDFNodeWrapper)result).asRDFNode().asNode();
    }
    if (n == null) {
        throw new EpiException("Pattern " + this + " returned null result");
    }
    if (n.isBlank() || n.isURI()) {
        return n;
    }
    throw new EpiException("Found " + result + " when expecting a URI");
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:25,代码来源:Pattern.java

示例11: convertRow

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
@Override
public Node convertRow(ConverterProcess config, BindingEnv row, int rowNumber) {
    Node root = NodeFactory.createURI( BASE + rowNumber );
    for (String key : row.keySet()) {
        Node property = NodeFactory.createURI( BASE + key );
        Object value = row.get(key);
        if (value instanceof ValueNumber) {
            if ( ((ValueNumber)value).toNumber().intValue() > 20) {
                throw new NullResult("Value exceeds test threshold of 20");
            }
        }
        Node vnode = NodeFactory.createLiteral( value.toString() );
        config.getOutputStream().triple( new Triple(root, property, vnode) );
    }
    return root;
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:17,代码来源:TestConverterProcess.java

示例12: start

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
@Override
public void start() {
    depth++ ;
    if ( depth == 1 ) {
        // Header
        // Node n = NodeFactory.createURI(JenaUUID.getFactory().generate().asURI());
        Node n = NodeFactory.createURI("uuid:"+UUID.randomUUID().toString());
        c.header(RDFPatchConst.ID, n);
        c.txnBegin();
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:12,代码来源:StreamPatch.java

示例13: txnGraph

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
private static Graph txnGraph(String graphName) {
        DatasetGraph dsg = DatasetGraphFactory.createTxnMem();
        Node gn = NodeFactory.createURI(graphName);
        Graph g = dsg.getGraph(gn);
        // Jena 3.5.0 and earlier.
//      g = new GraphWrapper(g) {
//          @Override public TransactionHandler getTransactionHandler() { return new TransactionHandlerView(dsg); }
//      };
        return g;
    }
 
开发者ID:afs,项目名称:rdf-delta,代码行数:11,代码来源:TestRDFChangesGraph.java

示例14: resToNode

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
private static Node resToNode(Resource r, boolean toVar) {
    Node n;
    if (toVar) {
        String name = r.getLocalName();

        if (r.getURI().contains(xsd)) {
            name += varId++;
        }

        n = Var.alloc(name);
    } else {
        n = NodeFactory.createURI(r.getURI());
    }
    return n;
}
 
开发者ID:xgfd,项目名称:ASPG,代码行数:16,代码来源:QueryGen.java

示例15: getNode

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public static Node getNode(Object obj) {
	if(obj == null) {
		return null;
	}
	else if(obj instanceof JSTerm) {
		return ((JSTerm)obj).getNode();
	}
	else if(obj instanceof Map) {
		Map som = (Map) obj;
		String value = (String) som.get(VALUE);
		if(value == null) {
			throw new IllegalArgumentException("Missing value");
		}
		String termType = (String) som.get(TERM_TYPE);
		if(NAMED_NODE.equals(termType)) {
			return NodeFactory.createURI(value);
		}
		else if(BLANK_NODE.equals(termType)) {
			return NodeFactory.createBlankNode(value);
		}
		else if(LITERAL.equals(termType)) {
			String lang = (String) som.get(LANGUAGE);
			Map dt = (Map)som.get(DATATYPE);
			String dtURI = (String)dt.get(VALUE);
			RDFDatatype datatype = TypeMapper.getInstance().getSafeTypeByName(dtURI);
			return NodeFactory.createLiteral(value, lang, datatype);
		}
		else {
			throw new IllegalArgumentException("Unsupported term type " + termType);
		}
	}
	else {
		return null;
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:37,代码来源:JSFactory.java


注:本文中的org.apache.jena.graph.NodeFactory.createURI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。