oracle.forms.jdapi
Interface JdapiIterator

All Superinterfaces:
java.util.Iterator

public interface JdapiIterator
extends java.util.Iterator

JdapiIterator extends java.util.Iterator. All Jdapi methods returning iterator objects return this type, regardless of the implementing subclass.

This interface supports the JDK1.3 Iterator explicitly but also adds JDK1.3 ListIterator-style bi-directionality.

The typical way to use JdapiIterator (as JDK1.3 Iterator) is:

    JdapiIterator items = blk.getItems();
    while(items.hasNext()) {
      Item itm = (Item)items.next();
      // do something with Item itm...
    }
 
Since the methods of java.util.Iterator return java.lang.Object, so do those of JdapiIterator. Thus, you must cast to the appropriate return type or supertype. For example:
     // Get the block list from the form module
     JdapiIterator blocks = myForm.getObjectProperty(JdapiTypes.BLOCK_PTID);
     Block myBlock = (Block)blocks.next();
     System.out.println(myBlock.getStringProperty(JdapiTypes.NAME_PTID));

     // Now get the item list from the first block
     JdapiIterator items = Block.getObjectProperty(JdapiTypes.ITEM_PTID);
     Item myItem = (Item)items.next();
     System.out.println(myBlock.getStringProperty(JdapiTypes.NAME_PTID)); 
 
This interface includes a remove() method because it is part of the standard implementation of an iterator. Note however, it is not always possible to remove an item from a list. For more information, see remove.


Method Summary
 void goLast()
          Moves the iterator to the end of the list.
 void goStart()
          Moves the iterator to the start of the list.
 boolean hasNext()
          Returns true if the iteration has more elements.
 boolean hasPrevious()
          Returns true if the iteration has a previous element.
 java.lang.Object next()
          Returns the next object in the iteration.
 java.lang.Object previous()
          Returns the previous object.
 void remove()
          Removes the current object from the iteration.
 

Method Detail

goLast

public void goLast()
Moves the iterator to the end of the list. Use this method with previous if you want to step backwards through a list.

goStart

public void goStart()
Moves the iterator to the start of the list.

hasNext

public boolean hasNext()
Returns true if the iteration has more elements.
Specified by:
hasNext in interface java.util.Iterator
Returns:
true if the iteration has more elements; false otherwise.

hasPrevious

public boolean hasPrevious()
Returns true if the iteration has a previous element.
Returns:
true if the iteration has a previous element; false otherwise.

next

public java.lang.Object next()
Returns the next object in the iteration.
Specified by:
next in interface java.util.Iterator
Returns:
the next object; null if there are none.

previous

public java.lang.Object previous()
Returns the previous object. Use this method with goLast if you want to step backwards through a list.
Returns:
the previous object in the list, null if there is no previous object.

remove

public void remove()
Removes the current object from the iteration. You cannot call this method twice on the same object in the iteration. This is the method you should use if you want to remove objects from within an iteration and continue to go through the iteration. If you destroy an object in the iteration any other way, the iterator will probably fail.

If the iterator is not positioned at the first element of the list, it will position itself there before doing the remove. This allows you to write code like:

   while(iter.hasNext()) {
     iter.remove();
   }
 

Note that in some cases it is not possible to call remove() because of the underlying implementation of the list. For example, it is possible to remove a Block from a list of blocks. In contrast, it is not possible to remove a Metaproperty from a list of metaproperties. If you call this method on an object that cannot be removed, then a JdapiException will be thrown.

Specified by:
remove in interface java.util.Iterator