Coverage report

  %line %branch
org.apache.commons.jelly.tags.xml.XMLTagLibrary
96% 
92% 

 1  
 /*
 2  
  * Copyright 2002,2004 The Apache Software Foundation.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.apache.commons.jelly.tags.xml;
 17  
 
 18  
 import org.apache.commons.jelly.JellyException;
 19  
 import org.apache.commons.jelly.TagLibrary;
 20  
 import org.apache.commons.jelly.expression.Expression;
 21  
 import org.apache.commons.jelly.expression.ExpressionFactory;
 22  
 import org.apache.commons.jelly.expression.CompositeExpression;
 23  
 import org.apache.commons.jelly.expression.jexl.JexlExpressionFactory;
 24  
 import org.apache.commons.jelly.expression.xpath.XPathExpression;
 25  
 import org.apache.commons.jelly.impl.TagScript;
 26  
 
 27  
 import org.apache.commons.logging.Log;
 28  
 import org.apache.commons.logging.LogFactory;
 29  
 
 30  
 
 31  
 /** Describes the Taglib. This class could be generated by XDoclet
 32  
   *
 33  
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
 34  
   * @version $Revision: 1.5 $
 35  
   */
 36  60
 public class XMLTagLibrary extends TagLibrary {
 37  
 
 38  
     /** The Log to which logging calls will be made. */
 39  16
     private Log log = LogFactory.getLog(XMLTagLibrary.class);
 40  
 
 41  
     private JexlExpressionFactory jexlFactory;
 42  
 
 43  16
     public XMLTagLibrary() {
 44  16
         registerTag("out", ExprTag.class);
 45  16
         registerTag("if", IfTag.class);
 46  16
         registerTag("forEach", ForEachTag.class);
 47  16
         registerTag("parse", ParseTag.class);
 48  16
         registerTag("set", SetTag.class);
 49  16
         registerTag("transform", TransformTag.class);
 50  16
         registerTag("param", ParamTag.class);
 51  
 
 52  
         // extensions to JSTL
 53  16
         registerTag("expr", ExprTag.class);
 54  16
         registerTag("element", ElementTag.class);
 55  16
         registerTag("attribute", AttributeTag.class);
 56  16
         registerTag("copy", CopyTag.class);
 57  16
         registerTag("copyOf", CopyOfTag.class);
 58  16
         registerTag("comment", CommentTag.class);
 59  16
         registerTag("doctype", DoctypeTag.class);
 60  16
         registerTag("sort", SortTag.class);
 61  
 
 62  16
         this.jexlFactory = new JexlExpressionFactory();
 63  16
     }
 64  
 
 65  
     public Expression createExpression(
 66  
         ExpressionFactory factory,
 67  
         TagScript tagScript,
 68  
         String attributeName,
 69  
         String attributeValue) throws JellyException {
 70  
 
 71  
         // #### may need to include some namespace URI information in the XPath instance?
 72  
 
 73  145
         if (attributeName.equals("select") || attributeName.equals("sort")) {
 74  47
             if ( log.isDebugEnabled() ) {
 75  0
                 log.debug( "Parsing XPath expression: " + attributeValue );
 76  
             }
 77  
 
 78  47
             Expression xpathExpr = createXPathTextExpression( attributeValue );
 79  
 
 80  47
             return new XPathExpression(attributeValue,
 81  
                                        xpathExpr,
 82  
                                        tagScript);
 83  
         }
 84  
 
 85  
         // will use the default expression instead
 86  98
         return super.createExpression(factory, tagScript, attributeName, attributeValue);
 87  
     }
 88  
 
 89  
     protected Expression createXPathTextExpression(String exprText) throws JellyException {
 90  47
         return CompositeExpression.parse( exprText,
 91  
                                           this.jexlFactory );
 92  
     }
 93  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.