protected Filter getFilter(Context context, String key) { Object value = context.get(key); if (value instanceof Filter) { return (Filter) value; } return filter; }
@Override public void visit(Variable node) throws IOException, ParseException { parameterStack.push(Context.getContext().get(node.getName())); }
@Override public void visit(Variable node) throws IOException, ParseException { parameterStack.push(Context.getContext().get(node.getName())); }
protected Template getMacro(Context context, String key, Template defaultValue) { Object value = context.get(key); if (value instanceof Template) { return (Template) value; } return defaultValue; }
public static Engine getEngine() { if (ENGINE == null) { Object request = Context.getContext().get("request"); if (request instanceof HttpServletRequest && ((HttpServletRequest) request).getSession() != null) { setServletContext(((HttpServletRequest) request).getSession().getServletContext()); } else { setServletContext(ServletLoader.getAndCheckServletContext()); } } return ENGINE; }
protected Template getMacro(Context context, String key, Template defaultValue) { Object value = context.get(key); if (value instanceof Template) { return (Template) value; } return defaultValue; }
@Override public boolean visit(Template node) throws IOException, ParseException { for (Node child : node.getChildren()) { child.accept(this); if (ClassUtils.isTrue(Context.getContext().get(breakVariable))) { Context.getContext().remove(breakVariable); break; } } return false; }
/** * Get the variable value. * * @see #getContext() * @param key - variable key * @param defaultValue - default value * @return variable value */ public Object get(String key, Object defaultValue) { Object value = get(key); return value == null ? defaultValue : value; }
public static Engine getEngine() { if (ENGINE == null) { Object request = Context.getContext().get("request"); if (request instanceof HttpServletRequest && ((HttpServletRequest) request).getSession() != null) { setServletContext(((HttpServletRequest) request).getSession().getServletContext()); } else { setServletContext(ServletLoader.getAndCheckServletContext()); } } return ENGINE; }
/** * Get the variable value. * * @param key - variable key * @param defaultValue - default value * @return variable value * @see #getContext() */ public Object get(String key, Object defaultValue) { Object value = get(key); return value == null ? defaultValue : value; }
@Override public boolean visit(Template node) throws IOException, ParseException { for (Node child : node.getChildren()) { child.accept(this); if (ClassUtils.isTrue(Context.getContext().get(breakVariable))) { Context.getContext().remove(breakVariable); break; } } return false; }
protected Filter getFilter(Context context, String key) { Object value = context.get(key); if (value instanceof Filter) { return (Filter) value; } return filter; }
@Override public boolean visit(ElseDirective node) throws IOException, ParseException { boolean result = true; if (node.getExpression() != null) { result = ClassUtils.isTrue(popExpressionResult(node.getOffset())); } result = result && !ClassUtils.isTrue(Context.getContext().get(ifVariable)); if (result) { Context.getContext().put(ifVariable, true); } return result; }
protected MultiFormatter getFormatter(Context context, String key) { Object value = context.get(key); if (value instanceof Formatter) { return toMultiFormatter((Formatter<?>) value); } return formatter; }
@Override public boolean visit(ElseDirective node) throws IOException, ParseException { boolean result = true; if (node.getExpression() != null) { result = ClassUtils.isTrue(popExpressionResult(node.getOffset())); } result = result && ! ClassUtils.isTrue(Context.getContext().get(ifVariable)); if (result) { Context.getContext().put(ifVariable, true); } return result; }
protected MultiFormatter getFormatter(Context context, String key) { Object value = context.get(key); if (value instanceof Formatter) { return toMultiFormatter((Formatter<?>) value); } return formatter; }
public void render(Context context) throws IOException, ParseException { if (next == null) { Listener listener = (Listener) context.get(LISTENER_KEY); if (listener != null) { current.render(context, listener); } } else { current.render(context, next); } } };
public void render(Context context) throws IOException, ParseException { if (next == null) { Listener listener = (Listener) context.get(LISTENER_KEY); if (listener != null) { current.render(context, listener); } } else { current.render(context, next); } } };
@Override protected void doRender(Context context, Listener listener) throws IOException, ParseException { if (ServletResolver.getRequest() == null) { Object request = context.get("request"); Object response = context.get("response"); if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) { ServletResolver.setRequestAndResponse((HttpServletRequest) request, (HttpServletResponse) response); try { listener.render(context); } finally { ServletResolver.removeRequestAndResponse(); } return; } } listener.render(context); }
@Override protected void doRender(Context context, Listener listener) throws IOException, ParseException { if (ServletResolver.getRequest() == null) { Object request = context.get("request"); Object response = context.get("response"); if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) { ServletResolver.setRequestAndResponse((HttpServletRequest) request, (HttpServletResponse) response); try { listener.render(context); } finally { ServletResolver.removeRequestAndResponse(); } return; } } listener.render(context); }