Coverage Report - org.apache.myfaces.view.facelets.compiler.NamespaceHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
NamespaceHandler
0%
0/20
0%
0/4
1.6
 
 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.view.facelets.compiler;
 20  
 
 21  
 import java.io.IOException;
 22  
 import java.lang.reflect.Method;
 23  
 import java.util.Map;
 24  
 import javax.el.ELContext;
 25  
 
 26  
 import javax.el.ELException;
 27  
 import javax.el.FunctionMapper;
 28  
 import javax.faces.FacesException;
 29  
 import javax.faces.component.UIComponent;
 30  
 import javax.faces.view.facelets.ComponentHandler;
 31  
 import javax.faces.view.facelets.FaceletContext;
 32  
 import javax.faces.view.facelets.FaceletException;
 33  
 import javax.faces.view.facelets.FaceletHandler;
 34  
 import org.apache.myfaces.el.unified.FacesELContext;
 35  
 
 36  
 import org.apache.myfaces.view.facelets.el.CompositeFunctionMapper;
 37  
 import org.apache.myfaces.view.facelets.tag.TagLibrary;
 38  
 import org.apache.myfaces.view.facelets.tag.composite.CompositeComponentResourceTagHandler;
 39  
 
 40  
 final class NamespaceHandler extends FunctionMapper implements FaceletHandler
 41  
 {
 42  
 
 43  
     private final TagLibrary library;
 44  
     private final Map<String, String> ns;
 45  
     private FaceletHandler next;
 46  
 
 47  
     public NamespaceHandler(FaceletHandler next, TagLibrary library, Map<String, String> ns)
 48  0
     {
 49  0
         this.library = library;
 50  0
         this.ns = ns;
 51  0
         this.next = next;
 52  0
     }
 53  
 
 54  
     public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
 55  
             ELException
 56  
     {
 57  0
         FunctionMapper orig = ctx.getFunctionMapper();
 58  0
         ELContext elContext = ctx.getFacesContext().getELContext();
 59  0
         if (elContext instanceof FacesELContext)
 60  
         {
 61  0
             ((FacesELContext) elContext).setFunctionMapper(this);
 62  
         }
 63  0
         ctx.setFunctionMapper(new CompositeFunctionMapper(this, orig));
 64  
         try
 65  
         {
 66  0
             next.apply(ctx, parent);
 67  
         }
 68  
         finally
 69  
         {
 70  0
             ctx.setFunctionMapper(orig);
 71  0
         }
 72  0
     }
 73  
 
 74  
     public Method resolveFunction(String prefix, String localName)
 75  
     {
 76  0
         String uri = (String) this.ns.get(prefix);
 77  0
         if (uri != null)
 78  
         {
 79  0
             return this.library.createFunction(uri, localName);
 80  
         }
 81  0
         return null;
 82  
     }
 83  
 
 84  
     public boolean isNextHandlerComponent()
 85  
     {
 86  0
         return (next instanceof ComponentHandler);
 87  
     }
 88  
     
 89  
     public boolean isNextHandlerCompositeComponent()
 90  
     {
 91  0
         return (next instanceof CompositeComponentResourceTagHandler);
 92  
     }
 93  
 }