Coverage Report - org.seasar.teeda.core.util.RenderedComponentIterator
 
Classes in this File Line Coverage Branch Coverage Complexity
RenderedComponentIterator
89%
17/19
90%
9/10
3.5
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 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,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.teeda.core.util;
 17  
 
 18  
 import java.util.Collection;
 19  
 import java.util.Iterator;
 20  
 
 21  
 import javax.faces.component.UIComponent;
 22  
 
 23  
 /**
 24  
  * @author manhole
 25  
  */
 26  
 public class RenderedComponentIterator implements Iterator {
 27  
 
 28  
     private Iterator iterator;
 29  
 
 30  
     private UIComponent component;
 31  
 
 32  235
     public RenderedComponentIterator(final Collection collection) {
 33  235
         iterator = collection.iterator();
 34  235
     }
 35  
 
 36  
     public boolean hasNext() {
 37  386
         if (component != null) {
 38  0
             return true;
 39  
         }
 40  393
         while (iterator.hasNext()) {
 41  160
             final UIComponent c = (UIComponent) iterator.next();
 42  160
             if (c.isRendered()) {
 43  153
                 component = c;
 44  153
                 return true;
 45  
             }
 46  
         }
 47  233
         return false;
 48  
     }
 49  
 
 50  
     public Object next() {
 51  157
         if (component != null) {
 52  153
             final UIComponent c = component;
 53  153
             component = null;
 54  153
             return c;
 55  
         }
 56  
         while (true) {
 57  6
             final UIComponent c = (UIComponent) iterator.next();
 58  4
             if (c.isRendered()) {
 59  2
                 return c;
 60  
             }
 61  
         }
 62  
     }
 63  
 
 64  
     public void remove() {
 65  0
         throw new UnsupportedOperationException("remove");
 66  
     }
 67  
 
 68  
 }