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

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

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

Triple.create介绍

暂无

代码示例

代码示例来源:origin: com.github.galigator.openllet/openllet-jena

protected void addClasses(final Collection<ATermAppl> classes)
{
  for (final ATermAppl c : classes)
  {
    final Node n = _names.get(c);
    _facts.add(Triple.create(n, PRED_SUB, n));
    _facts.add(Triple.create(n, PRED_SUB, TOP));
  }
}

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

@Override
  public void derive(Node s, Node p, Node o)
  {
    if ( isTriple )
      output.triple(Triple.create(s,p,o)) ;
    else
      output.quad(Quad.create(g,s,p,o)) ;
  }
} ;

代码示例来源:origin: com.github.galigator.openllet/openllet-jena

protected ExtendedIterator<Triple> propertyFiller(final Node s, final Iterator<ATermAppl> properties, final Node o)
{
  return WrappedIterator.create(properties)//
      .filterKeep(JenaUtils._isGrapheNode)//
      .mapWith(JenaUtils::makeGraphNode)//
      .filterKeep(Optional::isPresent)//
      .mapWith(node -> Triple.create(s, node.get(), o));
}

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

private Triple convert(AResource s, AResource p, ALiteral o) {
  Node object = convert(o) ;
  checker.check(object, -1, -1) ;
  return Triple.create(convert(s), convert(p), object) ;
}

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

@Override
public Model remove( Resource s, Property p, RDFNode o ) {
  graph.delete( Triple.create( s.asNode(), p.asNode(), o.asNode() ) );
  return this;
}

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

/**
 * Utility factory as for create(String), but allowing the PrefixMapping to
 * be specified explicitly.
 */
public static Triple createTriple(PrefixMapping pm, String fact) {
  StringTokenizer st = new StringTokenizer(fact);
  Node sub = create(pm, st.nextToken());
  Node pred = create(pm, st.nextToken());
  Node obj = create(pm, st.nextToken());
  return Triple.create(sub, pred, obj);
}

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

/**
  Utility factory as for create(String), but allowing the PrefixMapping to
  be specified explicitly.
*/
public static Triple createTriple( PrefixMapping pm, String fact )
  {
  StringTokenizer st = new StringTokenizer( fact );
  Node sub = create( pm, st.nextToken() );
  Node pred = create( pm, st.nextToken() );
  Node obj = create( pm, st.nextToken() );
  return Triple.create( sub, pred, obj );
  }

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

private void readObject(java.io.ObjectInputStream in) throws IOException {
  TProtocol protocol = TRDF.protocol(in);
  RDF_Term tterm  = new RDF_Term();
  Node s = SerializerRDF.read(protocol, tterm); 
  Node p = SerializerRDF.read(protocol, tterm);
  Node o = SerializerRDF.read(protocol, tterm);
  triple = Triple.create(s, p, o);
}

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

public static Triple convert(RDF_Triple rt, PrefixMap pmap) {
  Node s = convert(rt.getS(), pmap) ;
  Node p = convert(rt.getP(), pmap) ;
  Node o = convert(rt.getO(), pmap) ;
  return Triple.create(s, p, o) ;
}

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

private Triple transform(Triple triple) {
  Node s = triple.getSubject() ;
  Node s1 = transform(s) ;
  Node p = triple.getPredicate() ;
  Node p1 = transform(p) ;
  Node o = triple.getObject() ;
  Node o1 = transform(o) ;
  if ( s == s1 && p == p1 && o == o1 )
    return triple ;
  return Triple.create(s1, p1, o1) ;
}

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

public void testKevinCaseA()
{
  Graph G = getGraph();
  Node X = node( "x" ), a = node( "a" ), b = node( "b" ), c = node( "c" );
  G.add( Triple.create( X, RDF.Nodes.type, RDF.Nodes.Statement ) );
  ReifierStd.reifyAs( G, X, Triple.create( a, b, c ) ); 
}

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

/**
  Weak test for "same graph": adding this to one is visible in t'other.
  Stopgap for use in testCanFindCreatedGraph.
  TODO: clean that test up (left over from RDB days)
*/
private boolean sameGraph( Graph g1, Graph g2 )
  {
  Node S = node( "S" ), P = node( "P" ), O = node( "O" );
  g1.add( Triple.create( S, P, O ) );
  g2.add( Triple.create( O, P, S ) );
  return g2.contains( S, P, O ) && g1.contains( O, P, S );
  }

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

/**
  Weak test for "same graph": adding this to one is visible in t'other.
  Stopgap for use in testCanFindCreatedGraph.
  TODO: clean that test up (left over from RDB days)
*/
private boolean sameGraph( Graph g1, Graph g2 )
  {
  Node S = node( "S" ), P = node( "P" ), O = node( "O" );
  g1.add( Triple.create( S, P, O ) );
  g2.add( Triple.create( O, P, S ) );
  return g2.contains( S, P, O ) && g1.contains( O, P, S );
  }

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

/**
 * Weak test for "same graph": adding this to one is visible in t'other.
 * Stopgap for use in testCanFindCreatedGraph. TODO: clean that test up
 * (left over from RDB days)
 */
private boolean sameGraph(Graph g1, Graph g2) {
  Node S = GraphHelper.node("S"), P = GraphHelper.node("P"), O = GraphHelper
      .node("O");
  g1.add(Triple.create(S, P, O));
  g2.add(Triple.create(O, P, S));
  return g2.contains(S, P, O) && g1.contains(O, P, S);
}

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

/**
 * Weak test for "same graph": adding this to one is visible in t'other.
 * Stopgap for use in testCanFindCreatedGraph. TODO: clean that test up
 * (left over from RDB days)
 */
private boolean sameGraph(Graph g1, Graph g2) {
  Node S = GraphHelper.node("S"), P = GraphHelper.node("P"), O = GraphHelper
      .node("O");
  g1.add(Triple.create(S, P, O));
  g2.add(Triple.create(O, P, S));
  return g2.contains(S, P, O) && g1.contains(O, P, S);
}

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

@Override
  public void run() {
    out.start();
    out.triple(Triple.create(org.apache.jena.graph.NodeFactory.createURI("urn:s"),
        org.apache.jena.graph.NodeFactory.createURI("urn:p"),
        org.apache.jena.graph.NodeFactory.createURI("urn:o")));
    throw new RuntimeException("die!");
  }
};

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

@Override
  public void run() {
    out.start();
    out.triple(Triple.create(org.apache.jena.graph.NodeFactory.createURI("urn:s"),
        org.apache.jena.graph.NodeFactory.createURI("urn:p"),
        org.apache.jena.graph.NodeFactory.createURI("urn:o")));
    out.finish() ;
    throw new RuntimeException("die!");
  }
});

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

public void testTripleCreate()
  {
  Node S = NodeCreateUtils.create( "s" ), P = NodeCreateUtils.create( "p" ), O = NodeCreateUtils.create( "o" );
  assertEquals( new Triple( S, P, O ), Triple.create( S, P, O ) );
  }

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

/**
  This test case was generated by Ian and was caused by GraphMem
  not keeping up with changes to the find interface. 
 */
public void testFindAndContains()
{
  Graph g = getGraph();
  Node r = NodeCreateUtils.create( "r" ), s = NodeCreateUtils.create( "s" ), p = NodeCreateUtils.create( "P" );
  g.add( Triple.create( r, p, s ) );
  assertTrue( g.contains( r, p, Node.ANY ) );
  assertEquals( 1, g.find( r, p, Node.ANY ).toList().size() );
}

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

/**
  This test case was generated by Ian and was caused by GraphMem
  not keeping up with changes to the find interface. 
 */
public void testFindAndContains()
{
  Graph g = getGraph();
  Node r = NodeCreateUtils.create( "r" ), s = NodeCreateUtils.create( "s" ), p = NodeCreateUtils.create( "P" );
  g.add( Triple.create( r, p, s ) );
  assertTrue( g.contains( r, p, Node.ANY ) );
  assertEquals( 1, g.find( r, p, Node.ANY ).toList().size() );
}

相关文章