Coverage Report - org.apache.tapestry.services.ExpressionEvaluator
 
Classes in this File Line Coverage Branch Coverage Complexity
ExpressionEvaluator
N/A
N/A
1
 
 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.services;
 16  
 
 17  
 import ognl.OgnlContext;
 18  
 import ognl.enhance.ExpressionAccessor;
 19  
 
 20  
 /**
 21  
  * Wrapper around the OGNL library.
 22  
  * 
 23  
  * @author Howard M. Lewis Ship
 24  
  * @since 4.0
 25  
  */
 26  
 public interface ExpressionEvaluator
 27  
 {
 28  
 
 29  
     /**
 30  
      * Reads a property of the target, defined by the expression.
 31  
      * 
 32  
      * @throws org.apache.hivemind.ApplicationRuntimeException
 33  
      *             if the expression can not be parsed, or if some other error
 34  
      *             occurs during evaluation of the expression.
 35  
      */
 36  
     Object read(Object target, String expression);
 37  
 
 38  
     /**
 39  
      * Reads a property of the target, defined by the (previously compiled)
 40  
      * expression.
 41  
      * 
 42  
      * @throws org.apache.hivemind.ApplicationRuntimeException
 43  
      *             if some other error occurs during evaluation of the
 44  
      *             expression.
 45  
      */
 46  
     Object readCompiled(Object target, Object expression);
 47  
     
 48  
     /**
 49  
      * Reads a property of the target, defined by the (previously compiled)
 50  
      * expression.
 51  
      * 
 52  
      * @param target
 53  
      *          The object to resolve the expression against.
 54  
      * @param expression
 55  
      *          The compiled expression.
 56  
      * @return
 57  
      *          The result of reading on the expression.
 58  
      */
 59  
     Object read(Object target, ExpressionAccessor expression);
 60  
     
 61  
     /**
 62  
      * Updates a property of the target, defined by the expression.
 63  
      * 
 64  
      * @throws org.apache.hivemind.ApplicationRuntimeException
 65  
      *             if the expression can not be parsed, or if some other error
 66  
      *             occurs during evaluation of the expression.
 67  
      */
 68  
     void write(Object target, String expression, Object value);
 69  
 
 70  
     /**
 71  
      * Updates a property of the target, defined by the (previously compiled)
 72  
      * expression.
 73  
      * 
 74  
      * @throws org.apache.hivemind.ApplicationRuntimeException
 75  
      *             if some other error occurs during evaluation of the
 76  
      *             expression.
 77  
      */
 78  
     void writeCompiled(Object target, Object expression, Object value);
 79  
     
 80  
     /**
 81  
      * Updates a property of the target, defined by the (previously compiled)
 82  
      * expression.
 83  
      * 
 84  
      * @param target
 85  
      *          The target object to set a value on.
 86  
      * @param expression
 87  
      *          The pre-compiled expression.
 88  
      * @param value
 89  
      *          The value to set.
 90  
      */
 91  
     void write(Object target, ExpressionAccessor expression, Object value);
 92  
     
 93  
     /**
 94  
      * Returns true if the expression evaluates to a constant or other literal
 95  
      * value.
 96  
      * 
 97  
      * @throws org.apache.hivemind.ApplicationRuntimeException
 98  
      *             if the expression is not valid
 99  
      */
 100  
     boolean isConstant(String expression);
 101  
     
 102  
     /**
 103  
      * Returns true if the expression evaluates to a constant or other literal
 104  
      * value.
 105  
      * 
 106  
      * @throws org.apache.hivemind.ApplicationRuntimeException
 107  
      *             if the expression is not valid
 108  
      */
 109  
     boolean isConstant(Object target, String expression);
 110  
     
 111  
     /**
 112  
      * Creates a default OGNL context object that can be used against
 113  
      * the specified object for expression evaluation.
 114  
      * 
 115  
      * @param target 
 116  
      *          The object to get a context for.
 117  
      * @return 
 118  
      *          An ognl context map.
 119  
      */
 120  
     OgnlContext createContext(Object target);
 121  
 }