public class DBObjectIterator extends java.lang.Object implements java.util.Iterator<DBObject>
final SchemaObjectIterator parentIter = new SchemaObjectIterator( pro ); parentIter.setTypes( Table.TYPE ); final DBObjectIterator iter = new DBObjectIterator( parentIter ); iter.setTypes( Column.TYPE ); while( iter.hasNext() ) { // iterate over every column in every table in the provider. }This iterator is not synchronized, only use on one thread.
Constructor and Description |
---|
DBObjectIterator(DBObject parent)
Creates a new DBObjectIterator that will search for children of the given
object.
|
DBObjectIterator(java.util.Iterator<? extends DBObject> parentIter)
Creates a new DBObjectIterator over all the objects in the parent Iterator.
|
Modifier and Type | Method and Description |
---|---|
static java.util.Iterator<? extends DBObject> |
createIterator(DBObjectProvider[] pros,
java.lang.String[] schemaObjectTypes,
java.lang.String[]... childTypeHeirachy)
Creates an Iterator of DBObjects for a specific type heirachy of child
objects.
|
static java.util.Iterator<? extends DBObject> |
createIterator(DBObject parent,
java.lang.String[]... childTypeHeirachy)
Creates an iterator of the children of the given parent object using the
childTypeHeirachy to restrict the objects returned.
|
boolean |
hasNext() |
DBObject |
next() |
void |
remove()
Not supported by this iterator.
|
void |
setTypes(java.lang.String... types)
Restricts the iterator to only the given object types.
|
public DBObjectIterator(DBObject parent)
parent
- the parent object to iterate over the children of.public DBObjectIterator(java.util.Iterator<? extends DBObject> parentIter)
parentIter
- the iterator of objects this iterator will search the
children ofpublic void setTypes(java.lang.String... types)
public boolean hasNext()
hasNext
in interface java.util.Iterator<DBObject>
public void remove()
remove
in interface java.util.Iterator<DBObject>
java.lang.UnsupportedOperationException
public static final java.util.Iterator<? extends DBObject> createIterator(DBObjectProvider[] pros, java.lang.String[] schemaObjectTypes, java.lang.String[]... childTypeHeirachy)
new String[]{ Column.TYPE }
in which case a normal
DBObjectIterator could be created using the appropriate
SchemaObjectIterator
as a parent. For more complicated heirachies
of depth > 1 this method will create the appropriate SchemaObjectIterator
and DBObjectIterator classes and return a wrapping Iterator.
For example, the following call will return an iterator over all of the IndexObjects owned by all the Indexes in all the Tables or Materialized Views available in all the given providers:
DBObjectIterator.createIterator( providers, new String[]{ Table.TYPE, MaterializedView.TYPE }, new String[]{ Index.TYPE, IndexObject.TYPE } );
pros
- all the providers to search inschemaObjectTypes
- all the top level (schema objects) in the
providers to search (null for all)childTypeHeirachy
- the heirachy of child types to iterate through.
The final element in the array is the type of object ultimately returned
by the iterator.