org.apache.jena.graph.Triple.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中org.apache.jena.graph.Triple.<init>()方法的一些代码示例,展示了Triple.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Triple.<init>()方法的具体详情如下:
包路径:org.apache.jena.graph.Triple
类名称:Triple
方法名:<init>

Triple.<init>介绍

暂无

代码示例

代码示例来源:origin: org.aksw.jena-sparql-api/jena-sparql-api-mapper

@Override
public void writeValue(Object value, Node subject, Node predicate,
    Graph outputGraph) {
  if(value != null) {
    // value must be a string
    String iri = value.toString();
    Node o = NodeFactory.createURI(iri);
    Triple t = new Triple(subject, predicate, o);
    outputGraph.add(t);
  }
}

代码示例来源:origin: apache/jena

/**
 * Internals of makeList.
 */
private static Node doMakeList(Node[] nodes, int next, Graph graph) {
  if (next < nodes.length) {
    Node listNode = NodeFactory.createBlankNode();
    graph.add(new Triple(listNode, RDF.Nodes.first, nodes[next]));
    graph.add(new Triple(listNode, RDF.Nodes.rest, doMakeList(nodes, next+1, graph)));
    return listNode;
  } else {
    return RDF.Nodes.nil;
  }
}

代码示例来源:origin: apache/jena

private void checkCreateNewList(final RDFNode value, final Resource tail)
    throws AddDeniedException, AuthenticationRequiredException {
  checkCreate(new Triple(SecurityEvaluator.FUTURE, listFirst().asNode(),
      value.asNode()));
  checkCreate(new Triple(SecurityEvaluator.FUTURE, listRest().asNode(),
      tail.asNode()));
}

代码示例来源:origin: apache/jena

/**
 * Test basic rule operations - simple AND rule check with tabling.
 */
public void testBaseRules3() {    
  List<Rule> rules = Rule.parseRules("[rule: (?a rdfs:subPropertyOf ?c) <- (?a rdfs:subPropertyOf ?b),(?b rdfs:subPropertyOf ?c)]");        
  Reasoner reasoner =  createReasoner(rules);
  Graph data = Factory.createGraphMem();
  data.add(new Triple(p, sP, q) );
  data.add(new Triple(q, sP, r) );
  data.add(new Triple(p, sP, s) );
  data.add(new Triple(s, sP, t) );
  data.add(new Triple(a,  p, b) );
  InfGraph infgraph = reasoner.bind(data);
  TestUtil.assertIteratorValues(this, 
    infgraph.find(null, RDFS.subPropertyOf.asNode(), null), 
    new Object[] {
      new Triple(p, sP, q),
      new Triple(q, sP, r),
      new Triple(p, sP, s),
      new Triple(s, sP, t),
      new Triple(p, sP, t),
      new Triple(p, sP, r)
    } );
}

代码示例来源:origin: apache/jena

private Triple getTriple2() {
  Node n1 = NodeFactory.createURI("nb1") ;
  Node n2 = NodeFactory.createURI("nb2") ;
  Node l3 = NodeFactory.createLiteral("lb3") ;
  return new Triple(n1, n2, l3) ;
}

代码示例来源:origin: apache/jena

@Override
public SecuredBag getBag(final String uri) throws ReadDeniedException, AuthenticationRequiredException {
  checkRead();
  checkRead(new Triple(NodeFactory.createURI(uri), RDF.type.asNode(), RDF.Bag.asNode()));
  return SecuredBagImpl.getInstance(holder.getSecuredItem(), holder.getBaseItem().getBag(uri));
}

代码示例来源:origin: apache/jena

/**
 * Test example hybrid rule.
 */
public void testHybrid1() {
  Graph data = Factory.createGraphMem();
  data.add(new Triple(a, p, b));
  data.add(new Triple(p, ty, s));
  String rules =
  "[r1: (?p rdf:type s) -> [r1b: (?x ?p ?y) <- (?y ?p ?x)]]";
  InfGraph infgraph = createInfGraph(rules, data);
  TestUtil.assertIteratorValues(this, 
     infgraph.find(null, p, null), new Object[] {
       new Triple(a, p, b),
       new Triple(b, p, a)
     } );
}

代码示例来源:origin: apache/jena

/**
 * The the "remove" builtin
 */
public void testRemoveBuiltin() {
  String rules =  
          "[rule1: (?x p ?y), (?x q ?y) -> remove(0)]" +
          "";
  List<Rule> ruleList = Rule.parseRules(rules);
  InfGraph infgraph = new BasicForwardRuleReasoner(ruleList).bind(Factory.createGraphMem());
  infgraph.add(new Triple(n1, p, Util.makeIntNode(1)));
  infgraph.add(new Triple(n1, p, Util.makeIntNode(2)));
  infgraph.add(new Triple(n1, q, Util.makeIntNode(2)));
  
  TestUtil.assertIteratorValues(this, infgraph.find(n1, null, null),
    new Triple[] {
      new Triple(n1, p, Util.makeIntNode(1)),
      new Triple(n1, q, Util.makeIntNode(2))
    });
  
}

代码示例来源:origin: apache/jena

/**
 * Test basic rule operations - simple AND/OR with tabling.
 */
public void testBaseRules4() {    
  Graph data = Factory.createGraphMem();
  data.add(new Triple(a, r, b));
  data.add(new Triple(b, r, c));
  data.add(new Triple(b, r, b));
  data.add(new Triple(b, r, d));
  List<Rule> rules = Rule.parseRules(
          "[r1: (?x p ?y) <- (?x r ?y)]" +
          "[r2: (?x p ?z) <- (?x p ?y), (?y r ?z)]" 
          );        
  Reasoner reasoner =  createReasoner(rules);
  InfGraph infgraph = reasoner.bind(data);
  TestUtil.assertIteratorValues(this, 
    infgraph.find(a, p, null), 
    new Object[] {
      new Triple(a, p, b),
      new Triple(a, p, d),
      new Triple(a, p, c)
    } );
}

代码示例来源:origin: apache/jena

@Override
protected TripleWritable createInvalidValue(int i) {
  return new TripleWritable(
      new Triple(NodeFactory.createURI("http://subjects/" + i), NodeFactory.createURI("http://predicate"),
          NodeFactory.createLiteral(Integer.toString(i), XSDDatatype.XSDinteger)));
}

代码示例来源:origin: apache/jena

@Override
public SecuredSeq getSeq(final String uri) throws ReadDeniedException, AuthenticationRequiredException {
  checkRead();
  checkRead(new Triple(NodeFactory.createURI(uri), RDF.type.asNode(), RDF.Seq.asNode()));
  return SecuredSeqImpl.getInstance(holder.getSecuredItem(), holder.getBaseItem().getSeq(uri));
}

代码示例来源:origin: apache/jena

protected void checkAdd(final int pos, final Node node)
    throws AddDeniedException, UpdateDeniedException,
    AuthenticationRequiredException {
  checkCreate(new Triple(holder.getBaseItem().asNode(), RDF.li(pos)
      .asNode(), node));
}

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

@Override
public void writeValue(Object value, Node subject, Node predicate,
    Graph outputGraph) {
  if(value != null) {
    // value must be a string
    String iri = value.toString();
    Node o = NodeFactory.createURI(iri);
    Triple t = new Triple(subject, predicate, o);
    outputGraph.add(t);
  }
}

代码示例来源:origin: org.apache.jena/jena-core

private Node getSkolem(Node x, Node y) {
  String rules =  "[r1: (?n p ?x) (?n q ?y) makeSkolem(?s ?x ?y) -> (?n s ?s)]";
  Graph data = Factory.createGraphMem();
  data.add(new Triple(n1, p, x));
  data.add(new Triple(n1, q, y));
  InfGraph infgraph = createInfGraph(rules, data);
  return infgraph.find(n1, s, Node.ANY).next().getObject();
}

代码示例来源:origin: apache/jena

@Override
public void add(Node g, Node s, Node p, Node o) {
  if ( Quad.isDefaultGraph(g) )
    graph.add(new Triple(s, p, o));
  else
    unsupportedMethod(this, "add(named graph)");
}

代码示例来源:origin: org.apache.jena/jena-core

/**
 * The the "remove" builtin
 */
public void testRemoveBuiltin() {
  String rules =  
          "[rule1: (?x p ?y), (?x q ?y) -> remove(0)]" +
          "";
  List<Rule> ruleList = Rule.parseRules(rules);
  InfGraph infgraph = new BasicForwardRuleReasoner(ruleList).bind(Factory.createGraphMem());
  infgraph.add(new Triple(n1, p, Util.makeIntNode(1)));
  infgraph.add(new Triple(n1, p, Util.makeIntNode(2)));
  infgraph.add(new Triple(n1, q, Util.makeIntNode(2)));
  
  TestUtil.assertIteratorValues(this, infgraph.find(n1, null, null),
    new Triple[] {
      new Triple(n1, p, Util.makeIntNode(1)),
      new Triple(n1, q, Util.makeIntNode(2))
    });
  
}

代码示例来源:origin: apache/jena

/**
 * Test basic rule operations - simple AND rule 
 */
public void testBaseRules1() {    
  List<Rule> rules = Rule.parseRules("[r1: (?a r ?c) <- (?a p ?b),(?b p ?c)]");        
  Graph data = Factory.createGraphMem();
  data.add(new Triple(a, p, b));
  data.add(new Triple(b, p, c));
  data.add(new Triple(b, p, d));
  Reasoner reasoner =  createReasoner(rules);
  InfGraph infgraph = reasoner.bind(data);
  TestUtil.assertIteratorValues(this, 
    infgraph.find(null, r, null), 
    new Object[] {
      new Triple(a, r, c),
      new Triple(a, r, d)
    } );
}

代码示例来源:origin: apache/jena

@Override
protected TripleWritable createValue(int i) {
  return new TripleWritable(
      new Triple(NodeFactory.createURI("http://subjects/" + i), NodeFactory.createURI("http://predicate"),
          NodeFactory.createLiteral(Integer.toString(i), XSDDatatype.XSDinteger)));
}

代码示例来源:origin: apache/jena

@Override
public SecuredAlt createAlt(final String uri)
    throws UpdateDeniedException, AddDeniedException, AuthenticationRequiredException {
  checkUpdate();
  checkCreate(new Triple(NodeFactory.createURI(uri), RDF.type.asNode(), RDF.Alt.asNode()));
  return SecuredAltImpl.getInstance(holder.getSecuredItem(), holder.getBaseItem().createAlt(uri));
}

代码示例来源:origin: apache/jena

@Override
public SecuredModel add(final Resource s, final Property p, final String lex, final RDFDatatype datatype)
    throws UpdateDeniedException, AddDeniedException, AuthenticationRequiredException {
  checkUpdate();
  checkCreate(new Triple(s.asNode(), p.asNode(), NodeFactory.createLiteral(lex, datatype)));
  holder.getBaseItem().add(s, p, lex, datatype);
  return holder.getSecuredItem();
}

相关文章