Coverage Report - org.apache.myfaces.view.facelets.tag.jstl.fn.JstlFnLibrary
 
Classes in this File Line Coverage Branch Coverage Complexity
JstlFnLibrary
0%
0/19
0%
0/16
2.833
 
 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.tag.jstl.fn;
 20  
 
 21  
 import java.lang.reflect.Method;
 22  
 import java.lang.reflect.Modifier;
 23  
 import java.util.HashMap;
 24  
 import java.util.Map;
 25  
 
 26  
 import javax.faces.FacesException;
 27  
 import javax.faces.view.facelets.TagConfig;
 28  
 import javax.faces.view.facelets.TagHandler;
 29  
 
 30  
 import org.apache.myfaces.view.facelets.tag.TagLibrary;
 31  
 
 32  
 /**
 33  
  * Library for JSTL Functions
 34  
  * 
 35  
  * @author Jacob Hookom
 36  
  * @version $Id$
 37  
  */
 38  
 public class JstlFnLibrary implements TagLibrary
 39  
 {
 40  
     public final static String NAMESPACE = "http://xmlns.jcp.org/jsp/jstl/functions";
 41  
     public final static String ALIAS_NAMESPACE = "http://java.sun.com/jsp/jstl/functions";
 42  
 
 43  0
     private final Map<String, Method> fns = new HashMap<String, Method>();
 44  
 
 45  
     public JstlFnLibrary()
 46  
     {
 47  0
         super();
 48  
         try
 49  
         {
 50  0
             Method[] methods = JstlFunction.class.getMethods();
 51  0
             for (int i = 0; i < methods.length; i++)
 52  
             {
 53  0
                 if (Modifier.isStatic(methods[i].getModifiers()))
 54  
                 {
 55  0
                     fns.put(methods[i].getName(), methods[i]);
 56  
                 }
 57  
             }
 58  
         }
 59  0
         catch (Exception e)
 60  
         {
 61  0
             throw new RuntimeException(e);
 62  0
         }
 63  0
     }
 64  
 
 65  
     public boolean containsNamespace(String ns)
 66  
     {
 67  0
         return NAMESPACE.equals(ns) || ALIAS_NAMESPACE.equals(ns);
 68  
     }
 69  
 
 70  
     public boolean containsTagHandler(String ns, String localName)
 71  
     {
 72  0
         return false;
 73  
     }
 74  
 
 75  
     public TagHandler createTagHandler(String ns, String localName, TagConfig tag) throws FacesException
 76  
     {
 77  0
         return null;
 78  
     }
 79  
 
 80  
     public boolean containsFunction(String ns, String name)
 81  
     {
 82  0
         if (NAMESPACE.equals(ns) || ALIAS_NAMESPACE.equals(ns))
 83  
         {
 84  0
             return this.fns.containsKey(name);
 85  
         }
 86  
         
 87  0
         return false;
 88  
     }
 89  
 
 90  
     public Method createFunction(String ns, String name)
 91  
     {
 92  0
         if (NAMESPACE.equals(ns) || ALIAS_NAMESPACE.equals(ns))
 93  
         {
 94  0
             return (Method) this.fns.get(name);
 95  
         }
 96  
         
 97  0
         return null;
 98  
     }
 99  
 }