1/*2 * $Id: IteratorEnumeration.java 797916 2009-07-26 11:54:13Z apetrelli $3 *4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122package org.apache.tiles.util;
2324import java.util.Enumeration;
25import java.util.Iterator;
2627/***28 * Copied and modified from Apache Commons Collections 3.2.1.<br>29 *30 * Adapter to make an {@link Iterator Iterator} instance appear to be an31 * {@link Enumeration Enumeration} instance.32 *33 * @param <E> The type of the enumerated elements.34 * @since Commons Collections 1.035 * @version $Revision: 797916 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr36 * 2008) $37 *38 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>39 */40publicclass IteratorEnumeration<E> implements Enumeration<E> {
4142/*** The iterator being decorated. */43private Iterator<E> iterator;
4445/***46 * Constructs a new <code>IteratorEnumeration</code> that will use the given47 * iterator.48 *49 * @param iterator the iterator to use50 */51publicIteratorEnumeration(Iterator<E> iterator) {
52this.iterator = iterator;
53 }
5455// Iterator interface56// -------------------------------------------------------------------------5758/***59 * Returns true if the underlying iterator has more elements.60 *61 * @return true if the underlying iterator has more elements62 */63publicboolean hasMoreElements() {
64return iterator.hasNext();
65 }
6667/***68 * Returns the next element from the underlying iterator.69 *70 * @return the next element from the underlying iterator.71 * @throws java.util.NoSuchElementException if the underlying iterator has72 * no more elements73 */74public E nextElement() {
75return iterator.next();
76 }
7778// Properties79// -------------------------------------------------------------------------80 }