01: /*
02: *******************************************************************************
03: * Copyright (C) 2002-2004, International Business Machines Corporation and *
04: * others. All Rights Reserved. *
05: *******************************************************************************
06: */
07: package com.ibm.icu.dev.tool.localeconverter;
08:
09: import java.util.*;
10:
11: public final class ArrayEnumeration implements Enumeration {
12:
13: public ArrayEnumeration(Object[] array, int start, int limit) {
14: this .array = array;
15: position = start;
16: this .limit = limit;
17: }
18:
19: public ArrayEnumeration(byte[] array, int start, int limit) {
20: this .array = new Object[array.length];
21: for (int i = 0; i < array.length; ++i) {
22: this .array[i] = new Byte(array[i]);
23: }
24: position = start;
25: this .limit = limit;
26: }
27:
28: public ArrayEnumeration(char[] array, int start, int limit) {
29: this .array = new Object[array.length];
30: for (int i = 0; i < array.length; ++i) {
31: this .array[i] = new Character(array[i]);
32: }
33: position = start;
34: this .limit = limit;
35: }
36:
37: public ArrayEnumeration(short[] array, int start, int limit) {
38: this .array = new Object[array.length];
39: for (int i = 0; i < array.length; ++i) {
40: this .array[i] = new Short(array[i]);
41: }
42: position = start;
43: this .limit = limit;
44: }
45:
46: public ArrayEnumeration(int[] array, int start, int limit) {
47: this .array = new Object[array.length];
48: for (int i = 0; i < array.length; ++i) {
49: this .array[i] = new Integer(array[i]);
50: }
51: position = start;
52: this .limit = limit;
53: }
54:
55: public ArrayEnumeration(float[] array, int start, int limit) {
56: this .array = new Object[array.length];
57: for (int i = 0; i < array.length; ++i) {
58: this .array[i] = new Float(array[i]);
59: }
60: position = start;
61: this .limit = limit;
62: }
63:
64: public ArrayEnumeration(double[] array, int start, int limit) {
65: this .array = new Object[array.length];
66: for (int i = 0; i < array.length; ++i) {
67: this .array[i] = new Double(array[i]);
68: }
69: position = start;
70: this .limit = limit;
71: }
72:
73: public boolean hasMoreElements() {
74: return position < limit;
75: }
76:
77: public Object nextElement() {
78: if (position < limit)
79: return array[position++];
80: else
81: throw new java.util.NoSuchElementException();
82: }
83:
84: // privates
85: private Object[] array;
86: private int position = 0;
87: private int limit = 0;
88: }
|