All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jodd.util.collection.ArrayEnumeration Maven / Gradle / Ivy

Go to download

Jodd Core tools and utilities, including type converters, JDateTime, cache etc.

There is a newer version: 5.3.0
Show newest version
// Copyright (c) 2003-2014, Jodd Team (jodd.org). All Rights Reserved.

package jodd.util.collection;

import java.io.Serializable;
import java.util.Enumeration;
import java.util.NoSuchElementException;

/**
 * Enumeration over an array. 
 */
public class ArrayEnumeration implements Enumeration, Serializable {

	private E array[];
	private int ndx;
	private int endNdx;

	public ArrayEnumeration(E arr[]) {
		this(arr, 0, arr.length);
	}

	public ArrayEnumeration(E arr[], int offset, int length) {
		array = arr;
		ndx = offset;
		this.endNdx = offset + length;
	}

	public boolean hasMoreElements() {
		return ndx < endNdx;
	}

	public E nextElement()	throws NoSuchElementException {
		if (ndx < endNdx) {
			return array[ndx++];
		}
		throw new NoSuchElementException();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy