net.sf.zig_project.gpl.common.enumerations
Class ArrayEnum

java.lang.Object
  extended bynet.sf.zig_project.gpl.common.enumerations.ArrayEnum
All Implemented Interfaces:
Enumeration
Direct Known Subclasses:
ArrayQueue.ArraySequencer

public class ArrayEnum
extends Object
implements Enumeration

Wrapper class for an array of Objects, and allows for them to be enumerated over using the Enumeration interface.

Version:
September 16, 2004
Author:
Frank Ziglar

Field Summary
protected  Object[] entries
           
protected  int index
           
protected  int term
           
 
Constructor Summary
ArrayEnum(Object[] o)
          Constructs an ArrayEnum.
ArrayEnum(Object[] o, int start)
          Constructs an ArrayEnum.
ArrayEnum(Object[] o, int start, int end)
          Constructs an ArrayEnum
 
Method Summary
 int available()
          Determines the current number of valid elements which the Enumeration can currently Enumerate over.
 void copyInto(Object[] targ, int off)
          Copies all of the elements in this Enumeration into the specified array.
 void copyInto(Object[] targ, int off, int len)
          Enumerates over len elements of this Enumeration, copying them into the specified array.
protected  void copyIntoRsvd(Object[] targ, int off, int len)
          Reserved internal method to enumerate over elements in this Enumeration, copying them into the target array.
 boolean hasMoreElements()
          Determines if the current Enumeration currently has any more elements to enumerate over.
 Object nextElement()
          Moves the position of this Enumeration to the next element and returns it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entries

protected final Object[] entries

index

protected int index

term

protected final int term
Constructor Detail

ArrayEnum

public ArrayEnum(Object[] o,
                 int start,
                 int end)
Constructs an ArrayEnum

Parameters:
o - the array containing Objects
start - initial index to use
end - the last valid index in the array, exclusive

ArrayEnum

public ArrayEnum(Object[] o,
                 int start)
Constructs an ArrayEnum. By default, this enum extends to the end of the array.

Parameters:
o - the array containing Objects
start - the first index from which to start the enum in the array.

ArrayEnum

public ArrayEnum(Object[] o)
Constructs an ArrayEnum. By default, this enum starts at the beginning (0) and extends to the end of the array.

Parameters:
o - the array containing Objects
Method Detail

nextElement

public Object nextElement()
Moves the position of this Enumeration to the next element and returns it.

Specified by:
nextElement in interface Enumeration

hasMoreElements

public boolean hasMoreElements()
Determines if the current Enumeration currently has any more elements to enumerate over.

Specified by:
hasMoreElements in interface Enumeration

available

public int available()
Determines the current number of valid elements which the Enumeration can currently Enumerate over.

Returns:
the number of available elements

copyInto

public void copyInto(Object[] targ,
                     int off)
Copies all of the elements in this Enumeration into the specified array. All of the elements in this enumeration are considered enumerated over, and the Enumeration will no longer be valid.

Parameters:
targ - the array to copy elements into
off - the offset within the target array to start copying elements

copyInto

public final void copyInto(Object[] targ,
                           int off,
                           int len)
Enumerates over len elements of this Enumeration, copying them into the specified array.

Parameters:
targ - the array to copy elements into
off - the offset within the target array to start copying elements
len - the number of elements to copy

copyIntoRsvd

protected void copyIntoRsvd(Object[] targ,
                            int off,
                            int len)
Reserved internal method to enumerate over elements in this Enumeration, copying them into the target array. Calls to this method are only made after the parameters have been verified as valid.

Parameters:
targ - the array to copy elements into
off - the offset within the target array to start copying elements
len - the number of elements to copy