org.apache.clerezza.commons.rdf.Graph.iterator()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(148)

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

Graph.iterator介绍

暂无

代码示例

代码示例来源:origin: org.apache.clerezza/rdf.core

@Override
  public Iterator<Triple> run() {
    return graph.iterator();
  }
});

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

@Override
  public Iterator<Triple> run() {
    return graph.iterator();
  }
});

代码示例来源:origin: org.apache.clerezza/rdf.core.test

@Override
public Iterator<Triple> iterator() {
  return wrapped.iterator();
}

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

@Override
public Iterator<Triple> iterator() {
  return wrapped.iterator();
}

代码示例来源:origin: org.apache.clerezza.commons-rdf/commons-rdf-impl-utils

/**
 * Creates a ImmutableGraph with the triples in Graph
 * 
 * @param Graph the collection of triples this ImmutableGraph shall consist of
 */
public SimpleImmutableGraph(Graph Graph) {
  this.graph = new SimpleGraph(Graph.iterator());
}

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

/**
 * 
 * Converts a Jena {@link Model} to an {@link ArrayList} of Clerezza triples (instances of class {@link Triple}).
 * 
 * @param model {@link Model}
 * @return an {@link ArrayList} that contains the generated Clerezza triples (see {@link Triple}) 
 */
public static List<Triple> jenaModelToClerezzaTriples(Model model){
  
  ArrayList<Triple> clerezzaTriples = new ArrayList<Triple>();
  
  org.apache.clerezza.commons.rdf.Graph mGraph = jenaModelToClerezzaGraph(model);
  
  Iterator<Triple> tripleIterator = mGraph.iterator();
  while(tripleIterator.hasNext()){
    Triple triple = tripleIterator.next();
    clerezzaTriples.add(triple);
  }
  
  return clerezzaTriples;
  
}

代码示例来源:origin: org.apache.clerezza.commons-rdf/commons-rdf-impl-utils

/**
 * Creates a ImmutableGraph with the triples in Graph.
 *
 * This construction allows to specify if the Graph might change
 * in future. If GraphWillNeverChange is set to true it will
 * assume that the collection never changes, in this case the collection
 * isn't copied making things more efficient.
 *
 * @param Graph the collection of triples this ImmutableGraph shall consist of
 * @param GraphWillNeverChange true if the caller promises Graph will never change
 */
public SimpleImmutableGraph(Graph Graph, boolean GraphWillNeverChange) {
  if (!GraphWillNeverChange) {
    this.graph = new SimpleGraph(Graph.iterator());
  } else {
    this.graph = Graph;
  }
}

代码示例来源:origin: org.apache.clerezza/rdf.core.test

@Override
public Iterator<Triple> iterator() {
  LockChecker.checkIfReadLocked(lock);
  readLock.lock();
  try {
    return new LockingIteratorForTesting(wrapped.iterator(), lock);
  } finally {
    readLock.unlock();
  }
}

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

/**
 * 
 * Converts an OWL API {@link OWLOntology} to an {@link ArrayList} of Clerezza triples (instances of class
 * {@link Triple}).
 * 
 * @param ontology
 *            {@link OWLOntology}
 * @return an {@link ArrayList} that contains the generated Clerezza triples (see {@link Triple})
 */
public static List<Triple> owlOntologyToClerezzaTriples(OWLOntology ontology) {
  ArrayList<Triple> clerezzaTriples = new ArrayList<Triple>();
  org.apache.clerezza.commons.rdf.Graph mGraph = owlOntologyToClerezzaGraph(ontology);
  Iterator<Triple> tripleIterator = mGraph.iterator();
  while (tripleIterator.hasNext()) {
    Triple triple = tripleIterator.next();
    clerezzaTriples.add(triple);
  }
  return clerezzaTriples;
}

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

@Override
public Iterator<Triple> iterator() {
  LockChecker.checkIfReadLocked(lock);
  readLock.lock();
  try {
    return new LockingIteratorForTesting(wrapped.iterator(), lock);
  } finally {
    readLock.unlock();
  }
}

代码示例来源:origin: org.apache.clerezza/rdf.jena.tdb.storage

@Override
public Set<IRI> getNames(ImmutableGraph graph) {
  //TODO: this method would require to compare the triples within the graph
  //      because an equals check will not work with BlankNodes. 
  Set<IRI> graphNames = new HashSet<IRI>();
  for( Iterator<Triple> iterator = graphNameIndex.getGraph().iterator(); iterator.hasNext(); ) {
    Triple triple = iterator.next();
    IRI graphName = new IRI(triple.getSubject().toString());
    ImmutableGraph currentGraph = getModelGraph(graphName, false, false).getImmutableGraph();
    if(graph.equals(currentGraph)){
      graphNames.add(graphName);
    }
  }
  return graphNames;
}

代码示例来源:origin: org.apache.clerezza/rdf.stable.serializer

private List<MSG> decomposeGraphToMSGs(Graph tc) {
  Graph tmp = new SimpleGraph();
  tmp.addAll(tc);
  List<MSG> msgSet = new LinkedList<MSG>();
  while (tmp.size() > 0) {
    Triple triple = tmp.iterator().next();
    Graph msgTc = new SimpleGraph();
    boolean containsBlankNode = fillMSG(triple, tmp, msgTc);
    MSG msg = new MSG(msgTc);
    msg.containsBlankNodes = containsBlankNode;
    msgSet.add(msg);
  }
  return msgSet;
}

代码示例来源:origin: org.apache.clerezza/rdf.utils

final Set<IRI> ifps = getIfps(tBox);
final Map<PredicateObject, Set<BlankNodeOrIRI>> ifp2nodesMap = new HashMap<PredicateObject, Set<BlankNodeOrIRI>>();
for (Iterator<Triple> it = mGraph.iterator(); it.hasNext();) {
  final Triple triple = it.next();
  final IRI predicate = triple.getPredicate();

代码示例来源:origin: org.apache.clerezza/rdf.core.test

@Test
public void testRemoveViaIterator() {
  Graph graph = getEmptyGraph();
  Assert.assertEquals(0, graph.size());
  final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, uriRef1);
  graph.add(triple1);
  final TripleImpl triple2 = new TripleImpl(uriRef1, uriRef2, uriRef4);
  graph.add(triple2);
  Assert.assertEquals(2, graph.size());
  Iterator<Triple> iterator = graph.iterator();
  while (iterator.hasNext()) {
    iterator.next();
    iterator.remove();
  }
  Assert.assertEquals(0, graph.size());
}

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

@Test
public void testRemoveViaIterator() {
  Graph graph = getEmptyGraph();
  Assert.assertEquals(0, graph.size());
  final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, uriRef1);
  graph.add(triple1);
  final TripleImpl triple2 = new TripleImpl(uriRef1, uriRef2, uriRef4);
  graph.add(triple2);
  Assert.assertEquals(2, graph.size());
  Iterator<Triple> iterator = graph.iterator();
  while (iterator.hasNext()) {
    iterator.next();
    iterator.remove();
  }
  Assert.assertEquals(0, graph.size());
}

代码示例来源:origin: org.apache.clerezza/rdf.core.test

@Test
public void testCreateImmutableGraph() {
  TcProvider simpleTcmProvider = getInstance();
  Graph mGraph = new SimpleGraph();
  mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));
  ImmutableGraph createdGraph = simpleTcmProvider.createImmutableGraph(uriRefA, mGraph);
  Iterator<Triple> iteratorInput = mGraph.iterator();
  Iterator<Triple> iteratorCreated = createdGraph.iterator();
  assertEquals(iteratorInput.next(), iteratorCreated.next());
  assertFalse(iteratorCreated.hasNext());
  try {
    simpleTcmProvider.createImmutableGraph(uriRefA, mGraph);
    assertTrue(false);
  } catch (EntityAlreadyExistsException e) {
    assertTrue(true);
  }
  simpleTcmProvider.deleteGraph(uriRefA);
}

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

@Test
public void testCreateImmutableGraph() {
  TcProvider simpleTcmProvider = getInstance();
  Graph mGraph = new SimpleGraph();
  mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));
  ImmutableGraph createdGraph = simpleTcmProvider.createImmutableGraph(uriRefA, mGraph);
  Iterator<Triple> iteratorInput = mGraph.iterator();
  Iterator<Triple> iteratorCreated = createdGraph.iterator();
  assertEquals(iteratorInput.next(), iteratorCreated.next());
  assertFalse(iteratorCreated.hasNext());
  try {
    simpleTcmProvider.createImmutableGraph(uriRefA, mGraph);
    assertTrue(false);
  } catch (EntityAlreadyExistsException e) {
    assertTrue(true);
  }
  simpleTcmProvider.deleteGraph(uriRefA);
}

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

@Test
public void testGetTriples() {
  TcProvider simpleTcmProvider = getInstance();
  // add Graphs
  Graph mGraph = new SimpleGraph();
  mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));
  simpleTcmProvider.createImmutableGraph(uriRefA, mGraph);
  mGraph = new SimpleGraph();
  mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefB));
  simpleTcmProvider.createImmutableGraph(uriRefB, mGraph);
  // add Graphs
  mGraph = simpleTcmProvider.createGraph(uriRefA1);
  mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1));
  mGraph = simpleTcmProvider.createGraph(uriRefB1);
  mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1));
  // get a ImmutableGraph
  Graph tripleCollection = simpleTcmProvider.getGraph(uriRefA);
  // get a Graph
  Graph tripleCollection2 = simpleTcmProvider.getGraph(uriRefB1);
  Iterator<Triple> iterator = tripleCollection.iterator();
  assertEquals(new TripleImpl(uriRefA, uriRefA, uriRefA), iterator.next());
  assertFalse(iterator.hasNext());
  iterator = tripleCollection2.iterator();
  assertEquals(new TripleImpl(uriRefB1, uriRefB1, uriRefB1), iterator.next());
  assertFalse(iterator.hasNext());
  simpleTcmProvider.deleteGraph(uriRefA);
  simpleTcmProvider.deleteGraph(uriRefA1);
  simpleTcmProvider.deleteGraph(uriRefB);
  simpleTcmProvider.deleteGraph(uriRefB1);
}

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

@Test
public void testGetGraph() {
  TcProvider simpleTcmProvider = getInstance();
  // add Graphs
  Graph mGraph = simpleTcmProvider.createGraph(uriRefA);
  mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));
  mGraph = simpleTcmProvider.createGraph(uriRefA1);
  mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1));
  mGraph = simpleTcmProvider.createGraph(uriRefB);
  mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefA));
  mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefB));
  mGraph.remove(new TripleImpl(uriRefB, uriRefB, uriRefA));
  assertEquals(1, mGraph.size());
  mGraph = simpleTcmProvider.createGraph(uriRefB1);
  mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1));
  Graph bGraph = simpleTcmProvider.getGraph(uriRefB);
  Iterator<Triple> iterator = bGraph.iterator();
  assertEquals(new TripleImpl(uriRefB, uriRefB, uriRefB), iterator.next());
  assertFalse(iterator.hasNext());
  simpleTcmProvider.deleteGraph(uriRefA);
  simpleTcmProvider.deleteGraph(uriRefA1);
  simpleTcmProvider.deleteGraph(uriRefB);
  simpleTcmProvider.deleteGraph(uriRefB1);
  
}

代码示例来源:origin: org.apache.clerezza/rdf.core.test

@Test
public void testGetGraph() {
  TcProvider simpleTcmProvider = getInstance();
  // add Graphs
  Graph mGraph = simpleTcmProvider.createGraph(uriRefA);
  mGraph.add(new TripleImpl(uriRefA, uriRefA, uriRefA));
  mGraph = simpleTcmProvider.createGraph(uriRefA1);
  mGraph.add(new TripleImpl(uriRefA1, uriRefA1, uriRefA1));
  mGraph = simpleTcmProvider.createGraph(uriRefB);
  mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefA));
  mGraph.add(new TripleImpl(uriRefB, uriRefB, uriRefB));
  mGraph.remove(new TripleImpl(uriRefB, uriRefB, uriRefA));
  assertEquals(1, mGraph.size());
  mGraph = simpleTcmProvider.createGraph(uriRefB1);
  mGraph.add(new TripleImpl(uriRefB1, uriRefB1, uriRefB1));
  Graph bGraph = simpleTcmProvider.getGraph(uriRefB);
  Iterator<Triple> iterator = bGraph.iterator();
  assertEquals(new TripleImpl(uriRefB, uriRefB, uriRefB), iterator.next());
  assertFalse(iterator.hasNext());
  simpleTcmProvider.deleteGraph(uriRefA);
  simpleTcmProvider.deleteGraph(uriRefA1);
  simpleTcmProvider.deleteGraph(uriRefB);
  simpleTcmProvider.deleteGraph(uriRefB1);
  
}

相关文章