public static PropertyUtils instance() { if (instance == null) { instance = new PropertyUtils(); } return instance; }
public DefaultTemplateBindings(Locale locale) { put(LocaleVariable, locale); }
public void setProperty(String name, Object property) { context.put(name, property); }
public final void execute(ExpressionContext context, TagNode tag, Writer out) throws TemplateEvaluationException, IOException { Object t = context.get(getCurrentObjectName()); Super ts = (Super) context.get(getParentObjectName()); Iter iter = (Iter) context.get(getIterObjectName()); Super s = null; if (t != null) { s = new Super(t, ts, iter); context.put(getParentObjectName(), s); } doExecute(context, tag, out); if (t != null) { context.put(getCurrentObjectName(), s.get()); context.put(getParentObjectName(), s.getSuper()); context.put(getIterObjectName(), s.getIter()); } else { context.put(getCurrentObjectName(), t); context.put(getParentObjectName(), ts); context.put(getIterObjectName(), iter); } }
private void iterateInt(ExpressionContext context, TagNode tag, Writer out, int[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }
public int asInt(ExpressionContext context) throws ExpressionEvaluationException { try { Map<String, Object> globals = context.asMap(); return (Integer) Ognl.getValue(parsedExpression, globals, globals, Integer.class); } catch (OgnlException e) { throw new ExpressionEvaluationException("Error evaluating expression: " + expression, e); } }
public static Locale getLocaleFromBindings(ExpressionContext context) { Locale locale = (Locale) context.get(LocaleVariable); if (locale == null) { locale = Locale.getDefault(); } return locale; } }
public void setAllProperties(Map<String, Object> properties) { context.setVariables(properties); }
private void iterateArray(ExpressionContext context, TagNode tag, Writer out, Object[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }
public boolean asBoolean(ExpressionContext context) throws ExpressionEvaluationException { try { Map<String, Object> globals = context.asMap(); return (Boolean) Ognl.getValue(parsedExpression, globals, globals, Boolean.class); } catch (OgnlException e) { throw new ExpressionEvaluationException("Error evaluating expression: " + expression, e); } }
public DefaultTemplateBindings() { put(LocaleVariable, Locale.getDefault()); }
private void iterateDouble(ExpressionContext context, TagNode tag, Writer out, double[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }
public float asFloat(ExpressionContext context) throws ExpressionEvaluationException { try { Map<String, Object> globals = context.asMap(); return (Float) Ognl.getValue(parsedExpression, globals, globals, Float.class); } catch (OgnlException e) { throw new ExpressionEvaluationException("Error evaluating expression: " + expression, e); } }
private void iterateChar(ExpressionContext context, TagNode tag, Writer out, char[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }
public Object eval(ExpressionContext context) throws ExpressionEvaluationException { //VariableResolverFactory factory = new MapVariableResolverFactory(globals); try { return MVEL.executeExpression(compiledExpression, context.asMap()); } catch (Exception e) { throw new ExpressionEvaluationException("Error evaluating exception on line: " + line + ", column: " + col + ", expression: " + expression, e); } }
private void iterateBoolean(ExpressionContext context, TagNode tag, Writer out, boolean[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }
public double asDouble(ExpressionContext context) throws ExpressionEvaluationException { try { Map<String, Object> globals = context.asMap(); return (Double) Ognl.getValue(parsedExpression, globals, globals, Double.class); } catch (OgnlException e) { throw new ExpressionEvaluationException("Error evaluating expression: " + expression, e); } }
private void iterateFloat(ExpressionContext context, TagNode tag, Writer out, float[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }
public long asLong(ExpressionContext context) throws ExpressionEvaluationException { try { Map<String, Object> globals = context.asMap(); return (Long) Ognl.getValue(parsedExpression, globals, globals, Long.class); } catch (OgnlException e) { throw new ExpressionEvaluationException("Error evaluating expression: " + expression, e); } }
private void iterateByte(ExpressionContext context, TagNode tag, Writer out, byte[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }