Coverage report

  %line %branch
org.apache.jetspeed.profiler.impl.ProfileFallbackIterator
0% 
0% 

 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  * 
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 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.apache.jetspeed.profiler.impl;
 18  
 
 19  
 import java.util.Iterator;
 20  
 import java.util.List;
 21  
 
 22  
 import org.apache.jetspeed.profiler.ProfileLocatorProperty;
 23  
 import org.apache.jetspeed.profiler.rules.RuleCriterion;
 24  
 
 25  
 /**
 26  
  * ProfileFallbackIterator
 27  
  *
 28  
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 29  
  * @version $Id: ProfileFallbackIterator.java 516448 2007-03-09 16:25:47Z ate $
 30  
  */
 31  
 public class ProfileFallbackIterator implements Iterator
 32  
 {
 33  
     private ProfileLocatorControl locator;
 34  0
     private int last = 0;
 35  0
     private int state = RuleCriterion.FALLBACK_CONTINUE;     
 36  
     private ProfileFallbackIterator()
 37  0
     {
 38  0
     }
 39  
     
 40  
     public ProfileFallbackIterator(ProfileLocatorControl locator)
 41  0
     {
 42  0
         this.locator = locator;
 43  0
         last = locator.getElements().size() - 1;
 44  0
     }
 45  
     
 46  
     /* (non-Javadoc)
 47  
      * @see java.util.Iterator#remove()
 48  
      */
 49  
     public void remove()
 50  
     {
 51  
         // TODO Auto-generated method stub
 52  0
     }
 53  
     
 54  
     /* (non-Javadoc)
 55  
      * @see java.util.Iterator#hasNext()
 56  
      */
 57  
     public boolean hasNext()
 58  
     {
 59  0
         boolean hasNext = false;
 60  
         
 61  0
         List elements = locator.getElements();
 62  
         
 63  0
         if (last < 0 || last >= elements.size())
 64  
         {
 65  0
             state = RuleCriterion.FALLBACK_STOP;
 66  0
             return false;
 67  
         }
 68  
         
 69  0
         if (state == RuleCriterion.FALLBACK_STOP)
 70  
         {
 71  0
             hasNext = false;
 72  
         }        
 73  0
         else if (state == RuleCriterion.FALLBACK_CONTINUE ||
 74  
                  state == RuleCriterion.FALLBACK_LOOP)
 75  
         {
 76  0
             hasNext = true;
 77  
         }
 78  
         
 79  0
         return hasNext;
 80  
     }
 81  
     
 82  
     /* (non-Javadoc)
 83  
      * @see java.util.Iterator#next()
 84  
      */
 85  
     public Object next()
 86  
     {
 87  0
         ProfileLocatorProperty [] properties = null;
 88  
 
 89  0
         if (last >= 0)
 90  
         {
 91  
             // generate properties list to return
 92  0
             List elements = locator.getElements();
 93  0
             properties = new ProfileLocatorProperty[last+1];
 94  0
             ProfileLocatorProperty lastElement = null;
 95  0
             Iterator it = elements.listIterator();
 96  0
             for (int count = 0; (count <= last) && it.hasNext(); count++)
 97  
             {
 98  0
                 lastElement = (ProfileLocatorProperty)it.next();
 99  0
                 properties[count] = lastElement;
 100  
             }
 101  
 
 102  
             // modify iterator state based on fallback type;
 103  
             // performed here to prevent multiple calls to
 104  
             // hasNext() from changing iterator state
 105  0
             state = lastElement.getFallbackType();
 106  0
             last--;
 107  
         }
 108  
 
 109  0
         return properties;
 110  
     }
 111  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.