Coverage Report - org.apache.myfaces.el.CompositeELResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
CompositeELResolver
0%
0/9
0%
0/2
0
CompositeELResolver$CompositeIterator
0%
0/22
0%
0/14
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.el;
 20  
 
 21  
 import java.beans.FeatureDescriptor;
 22  
 import java.util.ArrayList;
 23  
 import java.util.Collection;
 24  
 import java.util.Collections;
 25  
 import java.util.Iterator;
 26  
 import java.util.NoSuchElementException;
 27  
 
 28  
 import javax.el.ELContext;
 29  
 import javax.el.ELResolver;
 30  
 
 31  
 /**
 32  
  * @author Mathias Broekelmann (latest modification by $Author: bommel $)
 33  
  * @version $Revision: 693059 $ $Date: 2008-09-08 06:42:28 -0500 (Mon, 08 Sep 2008) $
 34  
  */
 35  0
 public class CompositeELResolver extends javax.el.CompositeELResolver
 36  
 {
 37  0
     private Collection<ELResolver> _elResolvers = Collections.EMPTY_LIST;
 38  
 
 39  
     @Override
 40  
     public Iterator<FeatureDescriptor> getFeatureDescriptors(final ELContext context, final Object base)
 41  
     {
 42  0
         return new CompositeIterator(context, base, _elResolvers.iterator());
 43  
     }
 44  
 
 45  
     /**
 46  
      * @param elResolver
 47  
      */
 48  
     public final void add(final ELResolver elResolver)
 49  
     {
 50  0
         super.add(elResolver);
 51  
 
 52  0
         if (_elResolvers == Collections.EMPTY_LIST)
 53  
         {
 54  0
             _elResolvers = new ArrayList();
 55  
         }
 56  
 
 57  0
         _elResolvers.add(elResolver);
 58  0
     }
 59  
 
 60  0
     private static class CompositeIterator implements Iterator<FeatureDescriptor>
 61  
     {
 62  
         private final ELContext _context;
 63  
         private final Object _base;
 64  
         private final Iterator<ELResolver> _elResolvers;
 65  
 
 66  
         private FeatureDescriptor _nextFD;
 67  
 
 68  
         private Iterator<FeatureDescriptor> _currentFDIter;
 69  
 
 70  
         public CompositeIterator(final ELContext context, final Object base, final Iterator<ELResolver> elResolvers)
 71  0
         {
 72  0
             _context = context;
 73  0
             _base = base;
 74  0
             _elResolvers = elResolvers;
 75  0
         }
 76  
 
 77  
         public boolean hasNext()
 78  
         {
 79  0
             if (_nextFD != null)
 80  0
                 return true;
 81  0
             if (_currentFDIter != null)
 82  
             {
 83  0
                 while (_nextFD == null && _currentFDIter.hasNext())
 84  
                 {
 85  0
                     _nextFD = _currentFDIter.next();
 86  
                 }
 87  
             }
 88  0
             if (_nextFD == null)
 89  
             {
 90  0
                 if (_elResolvers.hasNext())
 91  
                 {
 92  0
                     _currentFDIter = _elResolvers.next().getFeatureDescriptors(_context, _base);
 93  
                 }
 94  
                 else
 95  
                 {
 96  0
                     return false;
 97  
                 }
 98  
             }
 99  0
             return hasNext();
 100  
         }
 101  
 
 102  
         public FeatureDescriptor next()
 103  
         {
 104  0
             if (!hasNext())
 105  0
                 throw new NoSuchElementException();
 106  0
             FeatureDescriptor next = _nextFD;
 107  0
             _nextFD = null;
 108  0
             return next;
 109  
         }
 110  
 
 111  
         public void remove()
 112  
         {
 113  0
             throw new UnsupportedOperationException();
 114  
         }
 115  
 
 116  
     }
 117  
 }