1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.springframework.osgi.mock;
17
18 import java.util.Enumeration;
19 import java.util.NoSuchElementException;
20
21 /**
22 * Simple enumeration mock backed by an array of objects.
23 *
24 */
25 public class ArrayEnumerator implements Enumeration {
26
27 private final Object[] source;
28
29 private int index = 0;
30
31 public ArrayEnumerator(Object[] source) {
32 this.source = source;
33 }
34
35 public boolean hasMoreElements() {
36 return source.length > index;
37 }
38
39 public Object nextElement() {
40 if (hasMoreElements())
41 return (source[index++]);
42 else
43 throw new NoSuchElementException();
44 }
45 }