1 4 package com.terracotta.session.util; 5 6 import java.util.Enumeration ; 7 import java.util.NoSuchElementException ; 8 9 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) throw new NoSuchElementException (); 25 String rv = strings[currIndex]; 26 currIndex++; 27 return rv; 28 } 29 30 } 31 | Popular Tags |