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

x33g5p2x  于2022-01-20 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(138)

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

Graph.isEmpty介绍

[英]Answer true iff this graph is empty. "Empty" means "has as few triples as it can manage", because an inference graph may have irremovable axioms and their consequences.
[中]如果此图为空,则回答true。“空”意味着“有尽可能少的三元组”,因为推理图可能有不可移动的公理及其结果。

代码示例

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

@Override
public boolean isEmpty()
{
  return graph.isEmpty() ;
}

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

@Override
public Iterator<Node> listGraphNodes() {
  // Hide empty graphs. 
  return graphs.entrySet().stream().filter(e->!e.getValue().isEmpty()).map(Entry::getKey).iterator();
}

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

@Override
  protected ExtendedIterator<Triple> _graphBaseFind(Triple s) {
    return L.isEmpty() || R.isEmpty() ? NullIterator.instance() : super._graphBaseFind(s);
  }
}

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

/**
  Answer true iff this graph is empty. [Used to be in QueryHandler, but moved in
  here because it's a more primitive operation.]
*/
@Override
public boolean isEmpty() {
  return fdata.getGraph().isEmpty();
}

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

@Override
public boolean containsGraph(Node graphNode) {
  // Hide empty graphs. 
  if ( Quad.isDefaultGraph(graphNode) )
    return true;
  if ( Quad.isUnionGraph(graphNode) )
    return true;
  Graph g = graphs.get(graphNode);
  return g != null && !g.isEmpty(); 
}

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

@Override
  public ExtendedIterator<Triple> _graphBaseFind(Triple s) {
    return L.isEmpty() ? NullIterator.instance() : super._graphBaseFind(s);
  }
}

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

@Override
public boolean isEmpty() throws ReadDeniedException,
    AuthenticationRequiredException {
  checkRead();
  return holder.getBaseItem().isEmpty();
}

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

private static void assertNullOrEmpty(Graph graph)
{
  if ( graph == null ) return ; 
  if ( ! graph.isEmpty() ) {
    System.out.println("----") ;
    RDFDataMgr.write(System.out, graph, Lang.TTL) ;
  }
  
  assertTrue(graph.isEmpty()) ;
}

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

public void testEmpty()
{
  Graph g = getGraph();
  assertTrue( g.isEmpty() );
  graphAdd( g, "x rdf:type rdf:Statement" ); assertFalse( g.isEmpty() );
  graphAdd( g, "x rdf:subject Deconstruction" ); assertFalse( g.isEmpty() );
  graphAdd( g, "x rdf:predicate rdfs:subTypeOf" ); assertFalse( g.isEmpty() );
  graphAdd( g, "x rdf:object LiteraryCriticism" ); assertFalse( g.isEmpty() );
}

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

private void write(Graph graph) {
    writeBase(baseURI) ;
    writePrefixes(prefixMap) ;
    if ( !prefixMap.isEmpty() && !graph.isEmpty() )
      out.println() ;
    writeGraphTTL(graph) ;
  }
}

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

public void testAddWithReificationPreamble()
{
  Graph g = getGraph();
  xSPO( g );
  assertFalse( g.isEmpty() );    
}

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

public void testRemoveAll( String triples )
{
  Graph g = getGraph();
  graphAdd( g, triples );
  g.clear();
  assertTrue( g.isEmpty() );
}

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

@Test public void copyAdd_01() {
    Graph graph = SSE.parseGraph("(graph (:s :p :o))") ;
    Node g = SSE.parseNode(":g") ;
    DatasetGraph dsg = emptyDataset() ;
    dsg.addGraph(g, graph);
    graph.clear(); 
    assertTrue(graph.isEmpty()) ;
    assertFalse(dsg.getGraph(g).isEmpty()) ;
  }
}

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

@Test public void linkAdd_01() {
  Graph graph = SSE.parseGraph("(graph (:s :p :o))") ;
  Node g = SSE.parseNode(":g") ;
  DatasetGraph dsg = emptyDataset() ;
  dsg.addGraph(g, graph);
  graph.clear(); 
  assertTrue(graph.isEmpty()) ;
  assertTrue(dsg.getGraph(g).isEmpty()) ;
}

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

@Test public void load_17() { 
  DatasetGraph dsg = RDFDataMgr.loadDatasetGraph(filename("D.ttl")) ;
  assertFalse(dsg.getDefaultGraph().isEmpty()) ;
  assertEquals(0, Iter.count(dsg.listGraphNodes())) ;
}

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

@ContractTest
public void testAddWithReificationPreamble()
{
  Graph g = producer.newInstance();
  txnBegin(g);
  xSPO(g);
  txnCommit(g);
  txnBegin(g);
  assertFalse(g.isEmpty());
  txnRollback(g);
}

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

@Test
public void load_dataset_01() {
  DatasetGraphTDB dsg = fresh() ;
  TDBLoader.load(dsg, DIR + "data-1.nq", false) ;
  assertTrue(dsg.getDefaultGraph().isEmpty()) ;
  assertEquals(1, dsg.getGraph(g).size()) ;
}

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

@Test
public void load_dataset_03() {
  DatasetGraph dsg = fresh();
  DataLoader loader = maker.apply(dsg, null);
  loader.startBulk();
  RDFDataMgr.parse(loader.stream(), DIR + "data-1.nq");
  loader.finishBulk();
  Txn.executeRead(dsg, ()->{
    assertTrue(dsg.getDefaultGraph().isEmpty()) ;
    assertEquals(1, dsg.getGraph(g).size()) ;
  });
}

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

@Test
public void load_dataset_01() {
  DatasetGraph dsg = fresh() ;
  load(dsg, maker, DIR + "data-1.nq") ;
  Txn.executeRead(dsg, ()->{
    assertTrue(dsg.getDefaultGraph().isEmpty()) ;
    assertEquals(1, dsg.getGraph(g).size()) ;
  });
}

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

public void testAddLeftOnlyIfNecessary()
  {
  Graph L = graphWith( "" ), R = graphWith( "x R y" );
  Graph du = new DisjointUnion( L, R );
  graphAdd( du, "x R y" );
  assertEquals( true, L.isEmpty() );
  graphAdd( du, " a P b" );
  assertIsomorphic( graphWith( "a P b" ), L );
  assertIsomorphic( graphWith( "x R y" ), R );
  }
}

相关文章