Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.util
Class SimpleEnumerator

    java.lang.Object
      com.tangosol.util.Base
          com.tangosol.util.SimpleEnumerator

All Implemented Interfaces:
  java.util.Enumeration, java.util.Iterator

Direct Known Subclasses:
  SortedEnumerator

    public class SimpleEnumerator

extends Base
implements java.util.Enumeration, java.util.Iterator

Provide a generic implementation of an array enumerator.

Version:
  0.50, 09/05/97, 1.00, 08/07/98
Author:
  Cameron Purdy

Field Summary
`protected java.lang.Object[]` | `m_aoItem` Array of items to enumerate.
`protected boolean` | `m_fForward` Iterator direction.
`protected int` | `m_iItem` Iterator position: next item to return.
`protected int` | `m_ofLimit` Iterator end position (beyond last).

Constructor Summary
`SimpleEnumerator(java.util.Collection col)` Construct a simple enumerator based on a collection.
`SimpleEnumerator(java.util.Enumeration enmr)` Construct a simple enumerator based on another Enumeration.
`SimpleEnumerator(java.util.Iterator iter)` Construct a simple enumerator based on another Iterator.
`SimpleEnumerator(java.lang.Object[] aoItem)` Construct the simple enumerator based on an array of objects.
`SimpleEnumerator(java.lang.Object[] aoItem, int ofStart, int cItems)` Construct the simple enumerator based on an array of objects.
`SimpleEnumerator(java.lang.Object[] aoItem, int ofStart, int cItems, boolean fForward, boolean fCopy)` Construct the simple enumerator based on an array of objects, making a copy of the array if specified.

Method Summary
`boolean` | `hasMoreElements()` Tests if this enumeration contains more elements.
`boolean` | `hasNext()` Tests if this Iterator contains more elements.
`java.lang.Object` | `next()` Returns the next element of this Iterator.
`java.lang.Object` | `nextElement()` Returns the next element of this enumeration.
`void` | `remove()` Remove the last-returned element that was returned by the Iterator.
`java.lang.Object[]` | `toArray()` Return the remaining contents of this SimpleEnumerator as an array.
`static java.lang.Object[]` | `toArray(java.util.Enumeration enmr)` Turns an enumeration into an array.
`static java.lang.Object[]` | `toArray(java.util.Enumeration enmr, java.lang.Object[] ao)` Turns an enumeration into an array.
`static java.lang.Object[]` | `toArray(java.util.Iterator iter)` Turns an Iterator into an array.
`static java.lang.Object[]` | `toArray(java.util.Iterator iter, java.lang.Object[] ao)` Turns an Iterator into an array.
`java.lang.Object[]` | `toArray(java.lang.Object[] ao)` Return the remaining contents of this SimpleEnumerator as an array of the type specified by the passed array, and use that passed array to store the values if it is big enough, putting a null in the first unused element if the size of the passed array is bigger than the number of remaining elements in this enumerator, as per the contract of the `Collection.toArray(Object[])` method.

Field Detail

### m_aoItem

    protected java.lang.Object[] m_aoItem

  Array of items to enumerate.

### m_iItem

    protected int m_iItem

  Iterator position: next item to return.

### m_ofLimit

    protected int m_ofLimit

  Iterator end position (beyond last).

### m_fForward

    protected boolean m_fForward

  Iterator direction.

Constructor Detail

### SimpleEnumerator

    public SimpleEnumerator(java.lang.Object[] aoItem)

  Construct the simple enumerator based on an array of objects.

  Parameters:
    `aoItem` - array of objects to enumerate

### SimpleEnumerator

    public SimpleEnumerator(java.lang.Object[] aoItem,
                            int ofStart,
                            int cItems)

  Construct the simple enumerator based on an array of objects.

  Parameters:
    `aoItem` - array of objects to enumerate
    `ofStart` - the first object position
    `cItems` - the number of objects to enumerate

### SimpleEnumerator

    public SimpleEnumerator(java.lang.Object[] aoItem,
                            int ofStart,
                            int cItems,
                            boolean fForward,
                            boolean fCopy)

  Construct the simple enumerator based on an array of objects, making a copy of the array if specified.

  Parameters:
    `aoItem` - array of objects to enumerate
    `ofStart` - the first object position
    `cItems` - the number of objects to enumerate
    `fForward` - true to iterate forwards, false to iterate from the end backwards to the beginning
    `fCopy` - pass true to make a copy of the array or false if the array's contents will not change

### SimpleEnumerator

    public SimpleEnumerator(java.util.Enumeration enmr)

  Construct a simple enumerator based on another Enumeration. This forces an initial pass through the elements of the passed enumerator, making a copy of that data, thus capturing a "point in time" view of an Enumeration which may be backed by mutable data. In other words, this constructs a "safe enumerator" based on a "not-safe enumerator".

  Parameters:
    `enmr` - the java.util.Enumeration to enumerate

### SimpleEnumerator

    public SimpleEnumerator(java.util.Iterator iter)

  Construct a simple enumerator based on another Iterator. This forces an initial pass through the elements of the passed enumerator, making a copy of that data, thus capturing a "point in time" view of an Iterator which may be backed by mutable data. In other words, this constructs a "safe enumerator" based on a "not-safe enumerator".

  Parameters:
    `iter` - the java.util.Iterator to enumerate

### SimpleEnumerator

    public SimpleEnumerator(java.util.Collection col)

  Construct a simple enumerator based on a collection.

  Parameters:
    `col` - the java.util.Collection to enumerate

Method Detail

### hasMoreElements

    public boolean hasMoreElements()

  Tests if this enumeration contains more elements.

  Specified by:
    `hasMoreElements` in interface `java.util.Enumeration`
  Returns:
    true if the enumeration contains more elements, false otherwise

### nextElement

    public java.lang.Object nextElement()

  Returns the next element of this enumeration.

  Specified by:
    `nextElement` in interface `java.util.Enumeration`
  Returns:
    the next element in the enumeration

### hasNext

    public boolean hasNext()

  Tests if this Iterator contains more elements.

  Specified by:
    `hasNext` in interface `java.util.Iterator`
  Returns:
    true if the Iterator contains more elements, false otherwise

### next

    public java.lang.Object next()

  Returns the next element of this Iterator.

  Specified by:
    `next` in interface `java.util.Iterator`
  Returns:
    the next element in the Iterator

### remove

    public void remove()

  Remove the last-returned element that was returned by the Iterator. This method always throws UnsupportedOperationException because the Iterator is immutable.

  Specified by:
    `remove` in interface `java.util.Iterator`

### toArray

    public static java.lang.Object[] toArray(java.util.Enumeration enmr)

  Turns an enumeration into an array.

  Parameters:
    `enmr` - the enumerator
  Returns:
    an array of the objects from the enumerator

### toArray

    public static java.lang.Object[] toArray(java.util.Enumeration enmr,
                                             java.lang.Object[] ao)

  Turns an enumeration into an array. The behavior of this method differs from the simple `toArray(Enumeration)` method in the same way that the `Collection.toArray(Object[])` method differs from the `Collection.toArray()` method.

  Parameters:
    `enmr` - the enumerator
    `ao` - the array into which the elements of the Enumeration are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose
  Returns:
    an array of the objects from the enumerator

### toArray

    public static java.lang.Object[] toArray(java.util.Iterator iter)

  Turns an Iterator into an array.

  Parameters:
    `iter` - the Iterator
  Returns:
    an array of the objects

### toArray

    public static java.lang.Object[] toArray(java.util.Iterator iter,
                                             java.lang.Object[] ao)

  Turns an Iterator into an array. The behavior of this method differs from the simple `toArray(Iterator)` method in the same way that the `Collection.toArray(Object[])` method differs from the `Collection.toArray()` method.

  Parameters:
    `iter` - the Iterator
    `ao` - the array into which the elements of the Iterator are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose
  Returns:
    an array of the objects from the Iterator

### toArray

    public java.lang.Object[] toArray()

  Return the remaining contents of this SimpleEnumerator as an array.

  Returns:
    an array containing all of the elements in this enumerator

### toArray

    public java.lang.Object[] toArray(java.lang.Object[] ao)

  Return the remaining contents of this SimpleEnumerator as an array of the type specified by the passed array, and use that passed array to store the values if it is big enough, putting a null in the first unused element if the size of the passed array is bigger than the number of remaining elements in this enumerator, as per the contract of the `Collection.toArray(Object[])` method.

  Parameters:
    `ao` - the array into which the elements of the Enumeration are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose
  Returns:
    an array containing the elements of the collection
  Throws:
    `java.lang.ArrayStoreException` - if the runtime type of the specified array is not a supertype of the runtime type of every element in this collection

Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle. All rights reserved.