Coverage Report - org.apache.tapestry.contrib.table.model.ognl.OgnlTableColumnEvaluator
 
Classes in this File Line Coverage Branch Coverage Complexity
OgnlTableColumnEvaluator
0%
0/10
0%
0/4
3.5
 
 1  
 // Copyright 2004, 2005 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry.contrib.table.model.ognl;
 16  
 
 17  
 import org.apache.commons.logging.Log;
 18  
 import org.apache.commons.logging.LogFactory;
 19  
 import org.apache.tapestry.contrib.table.model.ITableColumn;
 20  
 import org.apache.tapestry.contrib.table.model.simple.ITableColumnEvaluator;
 21  
 import org.apache.tapestry.services.ExpressionEvaluator;
 22  
 
 23  
 /**
 24  
  * @author mindbridge
 25  
  */
 26  
 public class OgnlTableColumnEvaluator implements ITableColumnEvaluator
 27  
 {
 28  
 
 29  
     private static final long serialVersionUID = 1L;
 30  
 
 31  0
     private static final Log LOG = LogFactory.getLog(OgnlTableColumnEvaluator.class);
 32  
     
 33  
     /** @since 4.0 */
 34  
 
 35  
     private ExpressionEvaluator _expressionEvaluator;
 36  
 
 37  
     private String m_strExpression;
 38  
 
 39  
     public OgnlTableColumnEvaluator(String strExpression,
 40  
             ExpressionEvaluator expressionEvaluator)
 41  0
     {
 42  0
         m_strExpression = strExpression;
 43  0
         _expressionEvaluator = expressionEvaluator;
 44  0
     }
 45  
 
 46  
     /**
 47  
      * @see org.apache.tapestry.contrib.table.model.simple.ITableColumnEvaluator#getColumnValue(ITableColumn,
 48  
      *      Object)
 49  
      */
 50  
     public synchronized Object getColumnValue(ITableColumn objColumn,
 51  
             Object objRow)
 52  
     {
 53  
         // If no expression is given, then this is a dummy column. Return
 54  
         // something.
 55  0
         if (m_strExpression == null || m_strExpression.equals("")) return "";
 56  
 
 57  
         try
 58  
         {
 59  0
             return _expressionEvaluator.read(objRow, m_strExpression);
 60  
         }
 61  0
         catch (Exception e)
 62  
         {
 63  0
             LOG.error("Cannot use column expression '" + m_strExpression
 64  
                     + "' in row", e);
 65  0
             return "";
 66  
         }
 67  
     }
 68  
 }