Coverage Report - org.seasar.teeda.core.el.impl.commons.CommonsELParser
 
Classes in this File Line Coverage Branch Coverage Complexity
CommonsELParser
83%
10/12
100%
2/2
1.75
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 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,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.teeda.core.el.impl.commons;
 17  
 
 18  
 import java.io.StringReader;
 19  
 
 20  
 import javax.faces.el.ReferenceSyntaxException;
 21  
 
 22  
 import org.apache.commons.el.parser.ELParser;
 23  
 import org.apache.commons.el.parser.ParseException;
 24  
 import org.seasar.teeda.core.el.ExpressionProcessor;
 25  
 import org.seasar.teeda.core.el.impl.JspELParserUtil;
 26  
 
 27  
 /**
 28  
  * @author shot
 29  
  */
 30  
 public class CommonsELParser implements org.seasar.teeda.core.el.ELParser {
 31  
 
 32  
     private static final long serialVersionUID = 1L;
 33  
 
 34  
     private ExpressionProcessor processor;
 35  
 
 36  75
     public CommonsELParser() {
 37  75
     }
 38  
 
 39  
     public Object parse(final String expression) {
 40  74
         String jspExpression = JspELParserUtil
 41  
                 .convertToJspExpression(expression);
 42  74
         ELParser parser = new ELParser(new StringReader(jspExpression));
 43  
         try {
 44  74
             Object obj = parser.ExpressionString();
 45  75
             getExpressionProcessor().processExpression(obj, Object.class);
 46  74
             return obj;
 47  0
         } catch (ParseException e) {
 48  0
             throw new ReferenceSyntaxException();
 49  
         }
 50  
     }
 51  
 
 52  
     public ExpressionProcessor getExpressionProcessor() {
 53  195
         return processor;
 54  
     }
 55  
 
 56  
     public void setExpressionProcessor(ExpressionProcessor processor) {
 57  75
         this.processor = processor;
 58  75
     }
 59  
 }