Coverage Report - com.sun.javafx.runtime.util.backport.ResourceBundleEnumeration
 
Classes in this File Line Coverage Branch Coverage Complexity
ResourceBundleEnumeration
0%
0/21
0%
0/16
0
 
 1  
 /*
 2  
  * Copyright 2001-2008 Sun Microsystems, Inc.  All Rights Reserved.
 3  
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  
  *
 5  
  * This code is free software; you can redistribute it and/or modify it
 6  
  * under the terms of the GNU General Public License version 2 only, as
 7  
  * published by the Free Software Foundation.  Sun designates this
 8  
  * particular file as subject to the "Classpath" exception as provided
 9  
  * by Sun in the LICENSE file that accompanied this code.
 10  
  *
 11  
  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  
  * version 2 for more details (a copy is included in the LICENSE file that
 15  
  * accompanied this code).
 16  
  *
 17  
  * You should have received a copy of the GNU General Public License version
 18  
  * 2 along with this work; if not, write to the Free Software Foundation,
 19  
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  
  *
 21  
  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 22  
  * CA 95054 USA or visit www.sun.com if you need additional information or
 23  
  * have any questions.
 24  
  */
 25  
 
 26  
 /*
 27  
  * NOTE:
 28  
  * 
 29  
  * This class was backported from the JDK6 runtime library, because some of
 30  
  * the functionality in this class aren't available on JDK5, which is at
 31  
  * the moment the target JRE environment for running JavaFX applications.
 32  
  * Once JDK5 is not a supported platform anymore, this class should be
 33  
  * removed.
 34  
  */
 35  
 
 36  
 package com.sun.javafx.runtime.util.backport;
 37  
 
 38  
 import java.util.Enumeration;
 39  
 import java.util.Iterator;
 40  
 import java.util.NoSuchElementException;
 41  
 import java.util.Set;
 42  
 
 43  
 /**
 44  
  * Implements an Enumeration that combines elements from a Set and
 45  
  * an Enumeration. Used by ListResourceBundle and PropertyResourceBundle.
 46  
  */
 47  0
 public class ResourceBundleEnumeration implements Enumeration<String> {
 48  
 
 49  
     Set<String> set;
 50  
     Iterator<String> iterator;
 51  
     Enumeration<String> enumeration; // may remain null
 52  
 
 53  
     /**
 54  
      * Constructs a resource bundle enumeration.
 55  
      * @param set an set providing some elements of the enumeration
 56  
      * @param enumeration an enumeration providing more elements of the enumeration.
 57  
      *        enumeration may be null.
 58  
      */
 59  0
     public ResourceBundleEnumeration(Set<String> set, Enumeration<String> enumeration) {
 60  0
         this.set = set;
 61  0
         this.iterator = set.iterator();
 62  0
         this.enumeration = enumeration;
 63  0
     }
 64  
 
 65  0
     String next = null;
 66  
             
 67  
     public boolean hasMoreElements() {
 68  0
         if (next == null) {
 69  0
             if (iterator.hasNext()) {
 70  0
                 next = iterator.next();
 71  0
             } else if (enumeration != null) {
 72  0
                 while (next == null && enumeration.hasMoreElements()) {
 73  0
                     next = enumeration.nextElement();
 74  0
                     if (set.contains(next)) {
 75  0
                         next = null;
 76  
                     }
 77  
                 }
 78  
             }
 79  
         }
 80  0
         return next != null;
 81  
     }
 82  
 
 83  
     public String nextElement() {
 84  0
         if (hasMoreElements()) {
 85  0
             String result = next;
 86  0
             next = null;
 87  0
             return result;
 88  
         } else {
 89  0
             throw new NoSuchElementException();
 90  
         }
 91  
     }
 92  
 }