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