Top Description Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.tools.utility.iterator

public Class SingleElementListIterator<E>

extends Object
implements ListIterator<E>
Class Inheritance
All Implemented Interfaces
java.util.ListIterator, java.util.Iterator
Annotations
@SuppressWarnings:nls
Imports
java.util.ListIterator, .NoSuchElementException

A SingleElementListIterator holds a single element and returns it with the first call to next(), at which point it will return false to any subsequent call to hasNext(). Likewise, it will return false to a call to hasPrevious() until a call to next(), at which point a call to previous() will return the single element.
Since
2.4
Version
2.4

Field Summary

Modifier and TypeField and Description
private E
element

The only element of this Iterator.

private static final Object
END

A constant used to determine if we are at the end of the iteration.

private E
next

The element that can be returned by next().

Constructor Summary

AccessConstructor and Description
public
SingleElementListIterator(E
The only element of this Iterator
element
)

Creates a new SingleElementListIterator that returns only the specified element.

Method Summary

Modifier and TypeMethod and Description
public void
add(E
the element to insert
item
)

Implements java.util.ListIterator.add.

Inserts the specified element into the list (optional operation).
public boolean
hasNext()

Implements java.util.ListIterator.hasNext.

Returns true if this list iterator has more elements when traversing the list in the forward direction.
public boolean
hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction.
public ListIterator<E>
public E
next()

Implements java.util.ListIterator.next.

Returns the next element in the list and advances the cursor position.
public int
nextIndex()

Implements java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next.
public E
previous()

Implements java.util.ListIterator.previous.

Returns the previous element in the list and moves the cursor position backwards.
public int
previousIndex()

Implements java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous.
public void
remove()

Implements java.util.ListIterator.remove.

Removes from the list the last element that was returned by next or previous (optional operation).
public void
set(E
the element with which to replace the last element returned by next or previous
item
)

Implements java.util.ListIterator.set.

Replaces the last element returned by next or previous with the specified element (optional operation).
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

elementback to summary
private E element

The only element of this Iterator.

ENDback to summary
private static final Object END

A constant used to determine if we are at the end of the iteration.

nextback to summary
private E next

The element that can be returned by next().

Constructor Detail

SingleElementListIteratorback to summary
public SingleElementListIterator(E element)

Creates a new SingleElementListIterator that returns only the specified element.

Parameters
element:E

The only element of this Iterator

Method Detail

addback to summary
public void add(E item)

Implements java.util.ListIterator.add.

Doc from java.util.ListIterator.add.

Inserts the specified element into the list (optional operation). The element is inserted immediately before the element that would be returned by next, if any, and after the element that would be returned by previous, if any. (If the list contains no elements, the new element becomes the sole element on the list.) The new element is inserted before the implicit cursor: a subsequent call to next would be unaffected, and a subsequent call to previous would return the new element. (This call increases by one the value that would be returned by a call to nextIndex or previousIndex.)

Parameters
item:E

the element to insert

Annotations
@Override
hasNextback to summary
public boolean hasNext()

Implements java.util.ListIterator.hasNext.

Doc from java.util.ListIterator.hasNext.

Returns true if this list iterator has more elements when traversing the list in the forward direction. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the list iterator has more elements when traversing the list in the forward direction

Annotations
@Override
hasPreviousback to summary
public boolean hasPrevious()

Implements java.util.ListIterator.hasPrevious.

Doc from java.util.ListIterator.hasPrevious.

Returns true if this list iterator has more elements when traversing the list in the reverse direction. (In other words, returns true if previous would return an element rather than throwing an exception.)

Returns:boolean

true if the list iterator has more elements when traversing the list in the reverse direction

Annotations
@Override
iteratorback to summary
public ListIterator<E> iterator()
nextback to summary
public E next()

Implements java.util.ListIterator.next.

Doc from java.util.ListIterator.next.

Returns the next element in the list and advances the cursor position. This method may be called repeatedly to iterate through the list, or intermixed with calls to previous to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

Returns:E

the next element in the list

Annotations
@Override
@SuppressWarnings:unchecked
nextIndexback to summary
public int nextIndex()

Implements java.util.ListIterator.nextIndex.

Doc from java.util.ListIterator.nextIndex.

Returns the index of the element that would be returned by a subsequent call to next. (Returns list size if the list iterator is at the end of the list.)

Returns:int

the index of the element that would be returned by a subsequent call to next, or list size if the list iterator is at the end of the list

Annotations
@Override
previousback to summary
public E previous()

Implements java.util.ListIterator.previous.

Doc from java.util.ListIterator.previous.

Returns the previous element in the list and moves the cursor position backwards. This method may be called repeatedly to iterate through the list backwards, or intermixed with calls to next to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

Returns:E

the previous element in the list

Annotations
@Override
previousIndexback to summary
public int previousIndex()

Implements java.util.ListIterator.previousIndex.

Doc from java.util.ListIterator.previousIndex.

Returns the index of the element that would be returned by a subsequent call to previous. (Returns -1 if the list iterator is at the beginning of the list.)

Returns:int

the index of the element that would be returned by a subsequent call to previous, or -1 if the list iterator is at the beginning of the list

Annotations
@Override
removeback to summary
public void remove()

Implements java.util.ListIterator.remove.

Doc from java.util.ListIterator.remove.

Removes from the list the last element that was returned by next or previous (optional operation). This call can only be made once per call to next or previous. It can be made only if add has not been called after the last call to next or previous.

Annotations
@Override
setback to summary
public void set(E item)

Implements java.util.ListIterator.set.

Doc from java.util.ListIterator.set.

Replaces the last element returned by next or previous with the specified element (optional operation). This call can be made only if neither remove nor add have been called after the last call to next or previous.

Parameters
item:E

the element with which to replace the last element returned by next or previous

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
See Also
Object#toString()