Coverage Report - org.kuali.rice.kns.uif.service.ExpressionEvaluatorService
 
Classes in this File Line Coverage Branch Coverage Complexity
ExpressionEvaluatorService
N/A
N/A
1
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation Licensed under the Educational Community
 3  
  * License, Version 1.0 (the "License"); you may not use this file except in
 4  
  * compliance with the License. You may obtain a copy of the License at
 5  
  * http://www.opensource.org/licenses/ecl1.php Unless required by applicable law
 6  
  * or agreed to in writing, software distributed under the License is
 7  
  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 8  
  * KIND, either express or implied. See the License for the specific language
 9  
  * governing permissions and limitations under the License.
 10  
  */
 11  
 package org.kuali.rice.kns.uif.service;
 12  
 
 13  
 import java.util.Map;
 14  
 
 15  
 /**
 16  
  * Provides evaluation of expression language statements against a given context
 17  
  * 
 18  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 19  
  */
 20  
 public interface ExpressionEvaluatorService {
 21  
 
 22  
     /**
 23  
      * Evaluates any el expressions that are found as a string property value
 24  
      * for the object
 25  
      * 
 26  
      * <p>
 27  
      * Using reflection the properties for the object are retrieved and if of
 28  
      * <code>String</code> type the corresponding value is retrieved. If the
 29  
      * value is not empty and contains the el placeholder see
 30  
      * {@link #containsElPlaceholder(String)} then the expression is evaluated
 31  
      * using the given context object and parameters. The evaluated string is
 32  
      * then set as the new property value, or in the case of a template
 33  
      * (expression contained within a literal string), the expression part is
 34  
      * replaced in the property value.
 35  
      * </p>
 36  
      * 
 37  
      * <p>
 38  
      * In addition to evaluating any property expressions, any configured
 39  
      * <code>PropertyReplacer</code> for the object are also evaluated and if a
 40  
      * match occurs those property replacements are made
 41  
      * </p>
 42  
      * 
 43  
      * @param object
 44  
      *            - object whose properties should be checked for expressions
 45  
      *            and evaluated
 46  
      * @param contextObject
 47  
      *            - context object for the expression evaluations
 48  
      * @param evaluationParameters
 49  
      *            - map of parameters that may appear in expressions, the map
 50  
      *            key gives the parameter name that may appear in the
 51  
      *            expression, and the map value is the object that expression
 52  
      *            should evaluate against when that name is found
 53  
      */
 54  
     public void evaluateObjectProperties(Object object, Object contextObject, Map<String, Object> evaluationParameters);
 55  
 
 56  
     /**
 57  
      * Evaluates the given expression template string against the context object
 58  
      * and map of parameters
 59  
      * 
 60  
      * <p>
 61  
      * If the template string contains one or more el placeholders (see
 62  
      * {@link #containsElPlaceholder(String)}), the expression contained within
 63  
      * the placeholder will be evaluated and the corresponding value will be
 64  
      * substituted back into the property value where the placeholder occurred.
 65  
      * If no placeholders are found, the string will be returned unchanged
 66  
      * </p>
 67  
      * 
 68  
      * @param contextObject
 69  
      *            - context object for the expression evaluations
 70  
      * @param evaluationParameters
 71  
      *            - map of parameters that may appear in expressions, the map
 72  
      *            key gives the parameter name that may appear in the
 73  
      *            expression, and the map value is the object that expression
 74  
      *            should evaluate against when that name is found
 75  
      * @param expressionTemplate
 76  
      *            - string that should be evaluated for el expressions
 77  
      * @return String formed by replacing any el expressions in the original
 78  
      *         expression template with their corresponding evaluation results
 79  
      */
 80  
     public String evaluateExpressionTemplate(Object contextObject, Map<String, Object> evaluationParameters,
 81  
             String expressionTemplate);
 82  
 
 83  
     /**
 84  
      * Evaluates the given el expression against the content object and
 85  
      * parameters, and returns the result of the evaluation
 86  
      * 
 87  
      * <p>
 88  
      * The given expression string is assumed to be one el expression and should
 89  
      * not contain the el placeholders. The returned result depends on the
 90  
      * evaluation and what type is returns, for instance a boolean will be
 91  
      * return for a boolean expression, or a string for string expression
 92  
      * </p>
 93  
      * 
 94  
      * @param contextObject
 95  
      *            - context object for the expression evaluations
 96  
      * @param evaluationParameters
 97  
      *            - map of parameters that may appear in expressions, the map
 98  
      *            key gives the parameter name that may appear in the
 99  
      *            expression, and the map value is the object that expression
 100  
      *            should evaluate against when that name is found
 101  
      * @param expression
 102  
      *            - el expression to evaluate
 103  
      * @return Object result of the expression evaluation
 104  
      */
 105  
     public Object evaluateExpression(Object contextObject, Map<String, Object> evaluationParameters, String expression);
 106  
 
 107  
     /**
 108  
      * Indicates whether or not the given string contains the el placholder
 109  
      * (begin and end delimiters)
 110  
      * 
 111  
      * @param value
 112  
      *            - String to check for contained placeholders
 113  
      * @return boolean true if the string contains one or more placeholders,
 114  
      *         false if it contains none
 115  
      * @see org.kuali.rice.kns.uif.UifConstants.EL_PLACEHOLDER_PREFIX
 116  
      * @see org.kuali.rice.kns.uif.UifConstants.EL_PLACEHOLDER_SUFFIX
 117  
      */
 118  
     public boolean containsElPlaceholder(String value);
 119  
 }