Coverage Report - org.apache.myfaces.renderkit.RenderKitFactoryImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
RenderKitFactoryImpl
0%
0/22
0%
0/12
2.8
 
 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.renderkit;
 20  
 
 21  
 import java.util.HashMap;
 22  
 import java.util.Iterator;
 23  
 import java.util.Map;
 24  
 import java.util.logging.Level;
 25  
 import java.util.logging.Logger;
 26  
 
 27  
 import javax.faces.FacesException;
 28  
 import javax.faces.context.FacesContext;
 29  
 import javax.faces.render.RenderKit;
 30  
 import javax.faces.render.RenderKitFactory;
 31  
 
 32  
 /**
 33  
  * RenderKitFactory implementation as defined in Spec. JSF.7.3
 34  
  * 
 35  
  * @author Manfred Geiler (latest modification by $Author$)
 36  
  * @version $Revision$ $Date$
 37  
  */
 38  
 public class RenderKitFactoryImpl extends RenderKitFactory
 39  
 {
 40  
     //private static final Log log = LogFactory.getLog(RenderKitFactoryImpl.class);
 41  0
     private static final Logger log = Logger.getLogger(RenderKitFactoryImpl.class.getName());
 42  
 
 43  0
     private Map<String, RenderKit> _renderkits = new HashMap<String, RenderKit>();
 44  
 
 45  
     public RenderKitFactoryImpl()
 46  0
     {
 47  0
     }
 48  
 
 49  
     public void purgeRenderKit()
 50  
     {
 51  0
         _renderkits.clear();
 52  0
     }
 53  
 
 54  
     @Override
 55  
     public void addRenderKit(String renderKitId, RenderKit renderKit)
 56  
     {
 57  0
         if (renderKitId == null)
 58  
         {
 59  0
             throw new NullPointerException("renderKitId");
 60  
         }
 61  0
         if (renderKit == null)
 62  
         {
 63  0
             throw new NullPointerException("renderKit");
 64  
         }
 65  0
         if (log.isLoggable(Level.INFO))
 66  
         {
 67  0
             if (_renderkits.containsKey(renderKitId))
 68  
             {
 69  0
                 log.info("RenderKit with renderKitId '" + renderKitId + "' was replaced.");
 70  
             }
 71  
         }
 72  0
         _renderkits.put(renderKitId, renderKit);
 73  0
     }
 74  
 
 75  
     @Override
 76  
     public RenderKit getRenderKit(FacesContext context, String renderKitId) throws FacesException
 77  
     {
 78  0
         if (renderKitId == null)
 79  
         {
 80  0
             throw new NullPointerException("renderKitId");
 81  
         }
 82  0
         RenderKit renderkit = _renderkits.get(renderKitId);
 83  0
         if (renderkit == null)
 84  
         {
 85  
             // throw new IllegalArgumentException("Unknown RenderKit '" + renderKitId + "'.");
 86  
             // JSF Spec API Doc says:
 87  
             // "If there is no registered RenderKit for the specified identifier, return null"
 88  
             // vs "IllegalArgumentException - if no RenderKit instance can be returned for the specified identifier"
 89  
             // First sentence is more precise, so we just log a warning
 90  0
             log.warning("Unknown RenderKit '" + renderKitId + "'.");
 91  
         }
 92  0
         return renderkit;
 93  
     }
 94  
 
 95  
     @Override
 96  
     public Iterator<String> getRenderKitIds()
 97  
     {
 98  0
         return _renderkits.keySet().iterator();
 99  
     }
 100  
 }