Coverage Report - org.kuali.rice.kew.util.SimpleEnumeration
 
Classes in this File Line Coverage Branch Coverage Complexity
SimpleEnumeration
0%
0/21
0%
0/8
1.8
 
 1  
 /*
 2  
  * Copyright 2005-2008 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.util;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.Enumeration;
 21  
 import java.util.Iterator;
 22  
 import java.util.List;
 23  
 
 24  
 /*
 25  
  * A simple Enumeration implementation which is backed by a List and it's Iterator.
 26  
  * Provides a few convienance constructors for creating the Enumeration.
 27  
  * 
 28  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 29  
  */
 30  
 public class SimpleEnumeration<T> implements Enumeration<T> {
 31  
 
 32  0
         private List<T> internalList = new ArrayList<T>();
 33  
         private Iterator<T> iterator;
 34  
         
 35  0
         public SimpleEnumeration(T object) {
 36  0
                 if (object != null) {
 37  0
                         internalList.add(object);
 38  
                 }
 39  0
                 iterator = internalList.iterator();
 40  0
         }
 41  
         
 42  0
         public SimpleEnumeration(Enumeration<T> enumeration, T object) {
 43  0
                 while (enumeration.hasMoreElements()) {
 44  0
                         internalList.add(enumeration.nextElement());
 45  
                 }
 46  0
                 internalList.add(object);
 47  0
                 iterator = internalList.iterator();
 48  0
         }
 49  
         
 50  0
         public SimpleEnumeration(Enumeration<T> enumeration1, Enumeration<T> enumeration2) {
 51  0
                 while (enumeration1.hasMoreElements()) {
 52  0
                         internalList.add(enumeration1.nextElement());
 53  
                 }
 54  0
                 while (enumeration2.hasMoreElements()) {
 55  0
                         internalList.add(enumeration2.nextElement());
 56  
                 }
 57  0
                 iterator = internalList.iterator();
 58  0
         }
 59  
         
 60  
         public boolean hasMoreElements() {
 61  0
                 return iterator.hasNext();
 62  
         }
 63  
 
 64  
         public T nextElement() {
 65  0
                 return iterator.next();
 66  
         }
 67  
 
 68  
 }