Coverage Report - org.apache.myfaces.shared_impl.trace.TracingIterator
 
Classes in this File Line Coverage Branch Coverage Complexity
TracingIterator
0%
0/20
N/A
0
TracingIterator$1
0%
0/2
N/A
0
TracingIterator$2
0%
0/2
N/A
0
TracingIterator$3
0%
0/3
N/A
0
 
 1  
 /*
 2  
  *  Licensed to the Apache Software Foundation (ASF) under one
 3  
  *  or more contributor license agreements.  See the NOTICE file
 4  
  *  distributed with this work for additional information
 5  
  *  regarding copyright ownership.  The ASF licenses this file
 6  
  *  to you under the Apache License, Version 2.0 (the
 7  
  *  "License"); you may not use this file except in compliance
 8  
  *  with the License.  You may obtain a copy of the License at
 9  
  * 
 10  
  *  http://www.apache.org/licenses/LICENSE-2.0
 11  
  * 
 12  
  *  Unless required by applicable law or agreed to in writing,
 13  
  *  software distributed under the License is distributed on an
 14  
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  *  KIND, either express or implied.  See the License for the
 16  
  *  specific language governing permissions and limitations
 17  
  *  under the License.
 18  
  */
 19  
 package org.apache.myfaces.shared_impl.trace;
 20  
 
 21  
 import java.util.Iterator;
 22  
 import java.util.logging.Level;
 23  
 import java.util.logging.Logger;
 24  
 
 25  
 /**
 26  
  * Trace method calls to an iterator
 27  
  * 
 28  
  * @author Mathias Broekelmann (latest modification by $Author: skitching $)
 29  
  * @version $Revision: 676197 $ $Date: 2008-07-12 11:07:17 -0500 (Sat, 12 Jul 2008) $
 30  
  */
 31  0
 public class TracingIterator<E> implements Iterator<E>
 32  
 {
 33  
     private final Iterator<E> _iterator;
 34  
 
 35  
     private final TracingSupport _tracer;
 36  
 
 37  
     public TracingIterator(Iterator<E> iterator)
 38  0
     {
 39  0
         _iterator = iterator;
 40  0
         _tracer = new TracingSupport(iterator.getClass());
 41  0
     }
 42  
 
 43  
     public static <E> TracingIterator<E> create(Iterator<E> iterator)
 44  
     {
 45  0
         return new TracingIterator<E>(iterator);
 46  
     }
 47  
 
 48  
     /**
 49  
      * @return the iterator
 50  
      */
 51  
     public Iterator<E> getIterator()
 52  
     {
 53  0
         return _iterator;
 54  
     }
 55  
 
 56  
     public boolean hasNext()
 57  
     {
 58  0
         return _tracer.trace("hasNext", new Closure<Boolean>()
 59  0
         {
 60  
             public Boolean call()
 61  
             {
 62  0
                 return _iterator.hasNext();
 63  
             }
 64  
         });
 65  
     }
 66  
 
 67  
     public E next()
 68  
     {
 69  0
         return _tracer.trace("next", new Closure<E>()
 70  0
         {
 71  
             public E call()
 72  
             {
 73  0
                 return _iterator.next();
 74  
             }
 75  
         });
 76  
     }
 77  
 
 78  
     public void remove()
 79  
     {
 80  0
         _tracer.trace("remove", new Closure<Object>()
 81  0
         {
 82  
             public Object call()
 83  
             {
 84  0
                 _iterator.remove();
 85  0
                 return Void.class;
 86  
             }
 87  
         });
 88  0
     }
 89  
 
 90  
     /**
 91  
      * @return
 92  
      * @see org.apache.myfaces.shared_impl.trace.TracingSupport#getLevel()
 93  
      */
 94  
     public Level getLevel()
 95  
     {
 96  0
         return _tracer.getLevel();
 97  
     }
 98  
 
 99  
     /**
 100  
      * @return
 101  
      * @see org.apache.myfaces.shared_impl.trace.TracingSupport#getLogger()
 102  
      */
 103  
     public Logger getLogger()
 104  
     {
 105  0
         return _tracer.getLogger();
 106  
     }
 107  
 
 108  
     /**
 109  
      * @return
 110  
      * @see org.apache.myfaces.shared_impl.trace.TracingSupport#getSourceClass()
 111  
      */
 112  
     public String getSourceClass()
 113  
     {
 114  0
         return _tracer.getSourceClass();
 115  
     }
 116  
 
 117  
     /**
 118  
      * @param level
 119  
      * @see org.apache.myfaces.shared_impl.trace.TracingSupport#setLevel(java.util.logging.Level)
 120  
      */
 121  
     public void setLevel(Level level)
 122  
     {
 123  0
         _tracer.setLevel(level);
 124  0
     }
 125  
 
 126  
     /**
 127  
      * @param logger
 128  
      * @see org.apache.myfaces.shared_impl.trace.TracingSupport#setLogger(java.util.logging.Logger)
 129  
      */
 130  
     public void setLogger(Logger logger)
 131  
     {
 132  0
         _tracer.setLogger(logger);
 133  0
     }
 134  
 
 135  
     /**
 136  
      * @param className
 137  
      * @see org.apache.myfaces.shared_impl.trace.TracingSupport#setSourceClass(java.lang.String)
 138  
      */
 139  
     public void setSourceClass(String className)
 140  
     {
 141  0
         _tracer.setSourceClass(className);
 142  0
     }
 143  
 }