1 16 17 package org.apache.taglibs.standard.lang.jstl; 18 19 import java.util.Map ; 20 21 30 31 public class ExpressionString 32 { 33 38 Object [] mElements; 39 public Object [] getElements () 40 { return mElements; } 41 public void setElements (Object [] pElements) 42 { mElements = pElements; } 43 44 49 public ExpressionString (Object [] pElements) 50 { 51 mElements = pElements; 52 } 53 54 61 public String evaluate (Object pContext, 62 VariableResolver pResolver, 63 Map functions, 64 String defaultPrefix, 65 Logger pLogger) 66 throws ELException 67 { 68 StringBuffer buf = new StringBuffer (); 69 for (int i = 0; i < mElements.length; i++) { 70 Object elem = mElements [i]; 71 if (elem instanceof String ) { 72 buf.append ((String ) elem); 73 } 74 else if (elem instanceof Expression) { 75 Object val = 76 ((Expression) elem).evaluate (pContext, 77 pResolver, 78 functions, 79 defaultPrefix, 80 pLogger); 81 if (val != null) { 82 buf.append (val.toString ()); 83 } 84 } 85 } 86 return buf.toString (); 87 } 88 89 94 public String getExpressionString () 95 { 96 StringBuffer buf = new StringBuffer (); 97 for (int i = 0; i < mElements.length; i++) { 98 Object elem = mElements [i]; 99 if (elem instanceof String ) { 100 buf.append ((String ) elem); 101 } 102 else if (elem instanceof Expression) { 103 buf.append ("${"); 104 buf.append (((Expression) elem).getExpressionString ()); 105 buf.append ("}"); 106 } 107 } 108 return buf.toString (); 109 } 110 111 } 113 | Popular Tags |