1 /* 2 * Copyright 2006 Ralf Joachim 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 package org.castor.core.util; 15 16 import java.util.Enumeration; 17 import java.util.Iterator; 18 19 /** 20 * Convert an enumeration to an iterator. 21 * 22 * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a> 23 * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $ 24 * @since 1.0.4 25 */ 26 public final class EnumerationIterator implements Iterator { 27 /** Enumeration to iterate over. */ 28 private final Enumeration _enumeration; 29 30 /** 31 * Construct an iterator for given enumeration. 32 * 33 * @param enumeration Enumeration to iterate over. 34 */ 35 public EnumerationIterator(final Enumeration enumeration) { 36 _enumeration = enumeration; 37 } 38 39 /** 40 * {@inheritDoc} 41 */ 42 public boolean hasNext() { 43 return _enumeration.hasMoreElements(); 44 } 45 46 /** 47 * {@inheritDoc} 48 */ 49 public Object next() { 50 return _enumeration.nextElement(); 51 } 52 53 /** 54 * {@inheritDoc} 55 */ 56 public void remove() { 57 throw new UnsupportedOperationException(); 58 } 59 }