org.universAAL.middleware.util
Class GraphIterator

Package class diagram package GraphIterator
java.lang.Object
  extended by org.universAAL.middleware.util.GraphIterator
All Implemented Interfaces:
Iterator
Direct Known Subclasses:
GraphIterator.GraphIteratorResources

public class GraphIterator
extends Object
implements Iterator

Iterate over all Resources of an RDF graph.

Author:
Carsten Stockloew

Nested Class Summary
protected static class GraphIterator.GraphIteratorResources
          A specialized iterator to iterate only over instances of Resource .
protected  class GraphIterator.StackElement
          Element to be stored in the stack.
 
Field Summary
protected  GraphIteratorElement nextElement
          The next element as being returned by next().
protected  GraphIterator.StackElement se
          The current information at a certain depth.
protected  Stack stack
          The stack contains information for previous depth.
protected  Set visitedResources
          The set of resources that have been visited before.
 
Constructor Summary
protected GraphIterator(Resource root)
           
 
Method Summary
protected  void createNext()
           
protected  void createResult()
           
static Iterator getIterator(Resource root)
          Create a new Iterator that iterates over all triples.
protected  Enumeration getPropertyEnumeration(Resource r)
           
static Iterator getResourceIterator(Resource root)
          Create a new Iterator that iterates over all Resources.
 boolean hasNext()
           
 Object next()
           
 void remove()
           
protected  void stepDeeper(Resource root)
           
protected  boolean stepHigher()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

visitedResources

protected Set visitedResources
The set of resources that have been visited before. During iteration, this will be used to avoid endless loop in case of cycles.


se

protected GraphIterator.StackElement se
The current information at a certain depth.


stack

protected Stack stack
The stack contains information for previous depth. When going one level deeper into the graph, the information about the current state, e.g. the enumerator of properties, is stored in the stack to be restored when all child nodes have been processed.


nextElement

protected GraphIteratorElement nextElement
The next element as being returned by next(). It can be calculated by next() and by hasNext().

Constructor Detail

GraphIterator

protected GraphIterator(Resource root)
Method Detail

getIterator

public static Iterator getIterator(Resource root)
Create a new Iterator that iterates over all triples. The return value of next() is of type GraphIteratorElement.

Parameters:
root - the Resource that is the root of the graph.
Returns:
an Iterator to iterate over elements of the graph.

getResourceIterator

public static Iterator getResourceIterator(Resource root)
Create a new Iterator that iterates over all Resources. The return value of next() is of type Resource.

Parameters:
root - the Resource that is the root of the graph.
Returns:
an Iterator to iterate over elements of the graph.

getPropertyEnumeration

protected Enumeration getPropertyEnumeration(Resource r)

stepDeeper

protected void stepDeeper(Resource root)

stepHigher

protected boolean stepHigher()

createResult

protected void createResult()

createNext

protected void createNext()

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator
See Also:
Iterator.hasNext()

next

public Object next()
Specified by:
next in interface Iterator
Returns:
the next element of the iterator. The type of the return value depends on the type of the iterator.
See Also:
Iterator.next()

remove

public void remove()
Specified by:
remove in interface Iterator
See Also:
Iterator.remove()


Copyright © 2014 universAAL Consortium. All Rights Reserved.