public Object evaluate() throws ParseException { // Context.getOut() only OutputStream or Writer if (Context.getContext().getOut() instanceof OutputStream) { return streamTemplate.evaluate(); } else { return writerTemplate.evaluate(); } }
/** * Set the current template. * * @param template - current template */ public Context setTemplate(Template template) { checkThread(); if (template != null) { setEngine(template.getEngine()); } this.template = template; return this; }
@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; }
public Reader getReader() { if (reader == null) { Template template = Context.getContext().getTemplate(); if (template != null) { try { return template.openReader(); } catch (IOException e) { return null; } } } return reader; }
/** * Tests whether the resource denoted by this abstract pathname exists. * * @param name - template name * @return exists * @see #getEngine() */ public boolean hasResource(String name) { return hasResource(name, null); }
/** * Get config value. * * @param key - config key * @return config value * @see #getEngine() */ public Object getProperty(String key) { return getProperty(key, Object.class); }
/** * Get template engine singleton. * * @param configProperties - config properties * @return template engine * @throws FileNotFoundException */ public static Engine getEngine(Properties configProperties) { return getEngine("", configProperties); }
/** * Set the current writer. * * @param out - current writer */ public Context setOut(Writer out) { checkThread(); this.out = out; return this; }
/** * 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; }
public Object evaluate(Object context) throws ParseException { // Context.getOut() only OutputStream or Writer if (Context.getContext().getOut() instanceof OutputStream) { return streamTemplate.evaluate(context); } else { return writerTemplate.evaluate(context); } }
@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; }
/** * Set the current template. * * @param template - current template */ public Context setTemplate(Template template) { checkThread(); this.template = template; if (template != null) { setEngine(template.getEngine()); } return this; }
/** * Get the context level. * * @return context level * @see #getContext() */ public int getLevel() { checkThread(); return level; }
protected Filter getFilter(Context context, String key) { Object value = context.get(key); if (value instanceof Filter) { return (Filter) value; } return filter; }
public Object evaluate() throws ParseException { // Context.getOut() only OutputStream or Writer if (Context.getContext().getOut() instanceof OutputStream) { return streamTemplate.evaluate(); } else { return writerTemplate.evaluate(); } }
/** * Get the current out. * * @return current out * @see #getContext() */ public Object getOut() { checkThread(); return out; }
protected Template getMacro(Context context, String key, Template defaultValue) { Object value = context.get(key); if (value instanceof Template) { return (Template) value; } return defaultValue; }
public Object evaluate(Object context) throws ParseException { // Context.getOut() only OutputStream or Writer if (Context.getContext().getOut() instanceof OutputStream) { return streamTemplate.evaluate(context); } else { return writerTemplate.evaluate(context); } }
/** * Get the parent context. * * @return parent context * @see #getContext() */ public Context getParent() { checkThread(); return parent; }
/** * Get the current engine. * * @return current engine * @see #getContext() */ public Engine getEngine() { checkThread(); return engine; }