Coverage Report - org.apache.myfaces.shared.trace.TracingIterator
 
Classes in this File Line Coverage Branch Coverage Complexity
TracingIterator
0%
0/20
N/A
1
TracingIterator$1
0%
0/2
N/A
1
TracingIterator$2
0%
0/2
N/A
1
TracingIterator$3
0%
0/3
N/A
1
 
 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.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  0
 public class TracingIterator<E> implements Iterator<E>
 29  
 {
 30  
     private final Iterator<E> _iterator;
 31  
 
 32  
     private final TracingSupport _tracer;
 33  
 
 34  
     public TracingIterator(Iterator<E> iterator)
 35  0
     {
 36  0
         _iterator = iterator;
 37  0
         _tracer = new TracingSupport(iterator.getClass());
 38  0
     }
 39  
 
 40  
     public static <E> TracingIterator<E> create(Iterator<E> iterator)
 41  
     {
 42  0
         return new TracingIterator<E>(iterator);
 43  
     }
 44  
 
 45  
     /**
 46  
      * @return the iterator
 47  
      */
 48  
     public Iterator<E> getIterator()
 49  
     {
 50  0
         return _iterator;
 51  
     }
 52  
 
 53  
     public boolean hasNext()
 54  
     {
 55  0
         return _tracer.trace("hasNext", new Closure<Boolean>()
 56  0
         {
 57  
             public Boolean call()
 58  
             {
 59  0
                 return _iterator.hasNext();
 60  
             }
 61  
         });
 62  
     }
 63  
 
 64  
     public E next()
 65  
     {
 66  0
         return _tracer.trace("next", new Closure<E>()
 67  0
         {
 68  
             public E call()
 69  
             {
 70  0
                 return _iterator.next();
 71  
             }
 72  
         });
 73  
     }
 74  
 
 75  
     public void remove()
 76  
     {
 77  0
         _tracer.trace("remove", new Closure<Object>()
 78  0
         {
 79  
             public Object call()
 80  
             {
 81  0
                 _iterator.remove();
 82  0
                 return Void.class;
 83  
             }
 84  
         });
 85  0
     }
 86  
 
 87  
     /**
 88  
      * @return
 89  
      * @see org.apache.myfaces.shared.trace.TracingSupport#getLevel()
 90  
      */
 91  
     public Level getLevel()
 92  
     {
 93  0
         return _tracer.getLevel();
 94  
     }
 95  
 
 96  
     /**
 97  
      * @return
 98  
      * @see org.apache.myfaces.shared.trace.TracingSupport#getLogger()
 99  
      */
 100  
     public Logger getLogger()
 101  
     {
 102  0
         return _tracer.getLogger();
 103  
     }
 104  
 
 105  
     /**
 106  
      * @return
 107  
      * @see org.apache.myfaces.shared.trace.TracingSupport#getSourceClass()
 108  
      */
 109  
     public String getSourceClass()
 110  
     {
 111  0
         return _tracer.getSourceClass();
 112  
     }
 113  
 
 114  
     /**
 115  
      * @param level
 116  
      * @see org.apache.myfaces.shared.trace.TracingSupport#setLevel(java.util.logging.Level)
 117  
      */
 118  
     public void setLevel(Level level)
 119  
     {
 120  0
         _tracer.setLevel(level);
 121  0
     }
 122  
 
 123  
     /**
 124  
      * @param logger
 125  
      * @see org.apache.myfaces.shared.trace.TracingSupport#setLogger(java.util.logging.Logger)
 126  
      */
 127  
     public void setLogger(Logger logger)
 128  
     {
 129  0
         _tracer.setLogger(logger);
 130  0
     }
 131  
 
 132  
     /**
 133  
      * @param className
 134  
      * @see org.apache.myfaces.shared.trace.TracingSupport#setSourceClass(java.lang.String)
 135  
      */
 136  
     public void setSourceClass(String className)
 137  
     {
 138  0
         _tracer.setSourceClass(className);
 139  0
     }
 140  
 }