1 16 17 package org.apache.taglibs.standard.lang.jstl; 18 19 import java.text.MessageFormat ; 20 import java.util.Map ; 21 22 import javax.servlet.jsp.JspException ; 23 import javax.servlet.jsp.PageContext ; 24 import javax.servlet.jsp.tagext.Tag ; 25 26 import org.apache.taglibs.standard.lang.support.ExpressionEvaluator; 27 28 41 42 public class Evaluator 43 implements ExpressionEvaluator 44 { 45 49 53 54 static ELEvaluator sEvaluator = 55 new ELEvaluator 56 (new JSTLVariableResolver ()); 57 58 67 public String validate (String pAttributeName, 68 String pAttributeValue) 69 { 70 try { 71 sEvaluator.parseExpressionString (pAttributeValue); 72 return null; 73 } 74 catch (ELException exc) { 75 return 76 MessageFormat.format 77 (Constants.ATTRIBUTE_PARSE_EXCEPTION, 78 new Object [] { 79 "" + pAttributeName, 80 "" + pAttributeValue, 81 exc.getMessage () 82 }); 83 } 84 } 85 86 91 public Object evaluate (String pAttributeName, 92 String pAttributeValue, 93 Class pExpectedType, 94 Tag pTag, 95 PageContext pPageContext, 96 Map functions, 97 String defaultPrefix) 98 throws JspException 99 { 100 try { 101 return sEvaluator.evaluate 102 (pAttributeValue, 103 pPageContext, 104 pExpectedType, 105 functions, 106 defaultPrefix); 107 } 108 catch (ELException exc) { 109 throw new JspException 110 (MessageFormat.format 111 (Constants.ATTRIBUTE_EVALUATION_EXCEPTION, 112 new Object [] { 113 "" + pAttributeName, 114 "" + pAttributeValue, 115 exc.getMessage(), 116 exc.getRootCause() 117 }), exc.getRootCause()); 118 } 119 } 120 121 122 public Object evaluate (String pAttributeName, 123 String pAttributeValue, 124 Class pExpectedType, 125 Tag pTag, 126 PageContext pPageContext) 127 throws JspException 128 { 129 return evaluate(pAttributeName, 130 pAttributeValue, 131 pExpectedType, 132 pTag, 133 pPageContext, 134 null, 135 null); 136 } 137 138 139 147 public static String parseAndRender (String pAttributeValue) 148 throws JspException 149 { 150 try { 151 return sEvaluator.parseAndRender (pAttributeValue); 152 } 153 catch (ELException exc) { 154 throw new JspException 155 (MessageFormat.format 156 (Constants.ATTRIBUTE_PARSE_EXCEPTION, 157 new Object [] { 158 "test", 159 "" + pAttributeValue, 160 exc.getMessage () 161 })); 162 } 163 } 164 165 167 } 168 | Popular Tags |