本文整理汇总了Java中org.apache.jena.graph.NodeFactory.createBlankNode方法的典型用法代码示例。如果您正苦于以下问题:Java NodeFactory.createBlankNode方法的具体用法?Java NodeFactory.createBlankNode怎么用?Java NodeFactory.createBlankNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.graph.NodeFactory
的用法示例。
在下文中一共展示了NodeFactory.createBlankNode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()) ;
}
示例2: bodyCall
import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
public boolean bodyCall(Node[] args, int length, RuleContext context) {
BindingEnvironment env = context.getEnv();
InfGraph graph = context.getGraph();
Node s = env.getGroundVersion(args[0]);
Node p = env.getGroundVersion(args[1]);
Node o = env.getGroundVersion(args[2]);
try {
Triple t = Triple.create(s,p,o);
//Reifier r = graph.getReifier();
Node a = NodeFactory.createBlankNode();
// r.reifyAs(a,t);
ReifierStd.reifyAs(graph,a,t);
env.bind(args[3],a);
return true;
} catch (Exception e) {
return false;
}
}
示例3: headAction
import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
public void headAction(Node[] args, int length, RuleContext context) {
BindingEnvironment env = context.getEnv();
InfGraph graph = context.getGraph();
Node s = env.getGroundVersion(args[0]);
Node p = env.getGroundVersion(args[1]);
Node o = env.getGroundVersion(args[2]);
try {
Triple t = Triple.create(s,p,o);
context.add(t);
Node a = NodeFactory.createBlankNode();
//Reifier r = graph.getReifier();
//r.reifyAs(a,t);
ReifierStd.reifyAs(graph,a,t) ;
env.bind(args[3],a);
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
示例4: tokenToNode
import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
private static Node tokenToNode(Token token) {
if ( token.isIRI() )
// URI or <_:...>
return RiotLib.createIRIorBNode(token.getImage()) ;
if ( token.isBNode() ) {
// Blank node as _:...
String label = token.getImage().substring(bNodeLabelStart.length());
return NodeFactory.createBlankNode(label);
}
return token.asNode() ;
}
示例5: exec
import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
@Override
public NodeValue exec(NodeValue node) {
String input = (String) node.asNode().getLiteralValue();
if (!map.containsKey(input)) {
String hash = new BigInteger(120, new Random()).toString(32);
map.put(input, hash);
}
Node n = NodeFactory.createBlankNode(map.get(input));
return NodeValue.makeNode(n);
}
示例6: 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;
}
}
示例7: asJenaNode
import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
/**
* Convert a CommonsRDF RDFTerm to a Jena Node. If the RDFTerm was from Jena
* originally, return that original object, else create a copy using Jena
* objects.
*
* @param term
* Commons RDF {@link RDFTerm} to convert
* @return Converted Jena {@link Node}
*/
public Node asJenaNode(final RDFTerm term) {
if (term == null) {
return null;
}
if (term instanceof JenaRDFTerm) {
// TODO: What if it's a JenaBlankNodeImpl with
// a different salt? Do we need to rewrite the
// jena blanknode identifier?
return ((JenaRDFTerm) term).asJenaNode();
}
if (term instanceof IRI) {
return NodeFactory.createURI(((IRI) term).getIRIString());
}
if (term instanceof Literal) {
final Literal lit = (Literal) term;
final RDFDatatype dt = NodeFactory.getType(lit.getDatatype().getIRIString());
final String lang = lit.getLanguageTag().orElse("");
return NodeFactory.createLiteral(lit.getLexicalForm(), lang, dt);
}
if (term instanceof BlankNode) {
final String id = ((BlankNode) term).uniqueReference();
return NodeFactory.createBlankNode(id);
}
throw new ConversionException("Not a concrete RDF Term: " + term);
}
示例8: asGeneralizedQuad
import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
@Test
public void asGeneralizedQuad() throws Exception {
final Node s = NodeFactory.createLiteral("Hello");
final Node p = NodeFactory.createBlankNode();
final Node o = NodeFactory.createURI("http://example.com/ex");
final Node g = Quad.defaultGraphIRI;
final Quad jq = Quad.create(g, s, p, o);
final JenaQuadLike<RDFTerm> q = jena.asGeneralizedQuad(jq);
assertEquals(jena.createLiteral("Hello"), q.getSubject());
assertEquals(jena.asRDFTerm(p), q.getPredicate());
assertEquals(jena.createIRI("http://example.com/ex"), q.getObject());
assertFalse(q.getGraphName().isPresent());
}
示例9: asGeneralizedTriple
import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
@Test
public void asGeneralizedTriple() throws Exception {
final Node s = NodeFactory.createLiteral("Hello");
final Node p = NodeFactory.createBlankNode();
final Node o = NodeFactory.createURI("http://example.com/ex");
final Triple jt = Triple.create(s, p, o);
final JenaTripleLike t = jena.asGeneralizedTriple(jt);
assertEquals(jena.createLiteral("Hello"), t.getSubject());
assertEquals(jena.asRDFTerm(p), t.getPredicate());
assertEquals(jena.createIRI("http://example.com/ex"), t.getObject());
}
示例10: bnodeFor
import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
public ValueNode bnodeFor(Object key) {
if (bNodes == null) {
bNodes = new HashMap<Object, Node>();
}
Node bnode = bNodes.get(key);
if (bnode == null) {
bnode = NodeFactory.createBlankNode();
bNodes.put(key, bnode);
}
return new ValueNode(bnode);
}
示例11: blankNode
import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
public JSBlankNode blankNode(String value) {
Node node = value == null ?
NodeFactory.createBlankNode() :
NodeFactory.createBlankNode(value);
return new JSBlankNode(node);
}
示例12: createBlankNode
import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
public JenaBlankNode createBlankNode(final String id, final UUID salt) {
return new JenaBlankNodeImpl(NodeFactory.createBlankNode(id), salt);
}
示例13: asNode
import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
@Override
public Node asNode() {
return NodeFactory.createBlankNode();
}
示例14: getBnode
import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
public ValueNode getBnode() {
if (bNode == null) {
bNode = NodeFactory.createBlankNode();
}
return new ValueNode(bNode);
}