01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.terracotta.session.util;
05:
06: import java.util.Enumeration;
07: import java.util.NoSuchElementException;
08:
09: public class StringArrayEnumeration implements Enumeration {
10:
11: private static final String[] EMPTY_ARRAY = new String[0];
12: private final String[] strings;
13: private int currIndex = 0;
14:
15: public StringArrayEnumeration(String[] strings) {
16: this .strings = (strings == null) ? EMPTY_ARRAY : strings;
17: }
18:
19: public boolean hasMoreElements() {
20: return currIndex < strings.length;
21: }
22:
23: public Object nextElement() {
24: if (currIndex >= strings.length)
25: throw new NoSuchElementException();
26: String rv = strings[currIndex];
27: currIndex++;
28: return rv;
29: }
30:
31: }
|