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


Java NodeFactory.createBlankNode方法代码示例

本文整理汇总了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()) ;
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:22,代码来源:RDFPatchReaderBinary.java

示例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;
	}
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:19,代码来源:Reify.java

示例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);
	}		
}
 
开发者ID:stevebattle,项目名称:Gloze,代码行数:19,代码来源:Reify.java

示例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() ;
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:12,代码来源:RDFPatchReaderText.java

示例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);
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:11,代码来源:FUN_bnode.java

示例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;
	}
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:37,代码来源:JSFactory.java

示例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);
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:38,代码来源:JenaRDF.java

示例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());
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:14,代码来源:GeneralizedRDFQuadTest.java

示例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());
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:12,代码来源:GeneralizedRDFTripleTest.java

示例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);
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:12,代码来源:Row.java

示例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);
}
 
开发者ID:TopQuadrant,项目名称:shacl,代码行数:7,代码来源:TermFactory.java

示例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);
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:4,代码来源:InternalJenaFactory.java

示例13: asNode

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
@Override
public Node asNode() {
    return NodeFactory.createBlankNode();
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:5,代码来源:ValueFunction.java

示例14: getBnode

import org.apache.jena.graph.NodeFactory; //导入方法依赖的package包/类
public ValueNode getBnode() {
    if (bNode == null) {
        bNode = NodeFactory.createBlankNode();
    }
    return new ValueNode(bNode);
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:7,代码来源:Row.java


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