|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 |
public void goLast()
previous
if you want to
step backwards through a list.public void goStart()
public boolean hasNext()
hasNext
in interface java.util.Iterator
public boolean hasPrevious()
public java.lang.Object next()
next
in interface java.util.Iterator
public java.lang.Object previous()
goLast
if you want to
step backwards through a list.public void remove()
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.
remove
in interface java.util.Iterator
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |