public final class TemplateEngine
extends java.lang.Object
HTML-Example
<html><head></head><body> #{times}# Good #(daytime)#morning::evening#(/daytime)#, #[name]#!(#[num]#. Greeting)<br> #{/times}# </body></html>
The corresponding HashMap to use this Template:
Java Example
HashMap pattern; pattern.put("times", 10); //10 greetings for(int i=0;i<=9;i++){ pattern.put("times_"+i+"_daytime", 1); //index: 1, second Entry, evening pattern.put("times_"+i+"_name", "John Connor"); pattern.put("times_"+i+"_num", (i+1)); }
Recursion
If you use recursive templates, the templates will be used from
the external to the internal templates.
In our Example, the Template in #{times}##{/times}# will be repeated ten times.
Then the inner Templates will be applied.
The inner templates have a prefix, so they may have the same name as a template on another level,
or templates which are in another recursive template.
The Prefixes:
Modifier and Type | Field and Description |
---|---|
private static byte[] |
aClose |
private static byte[] |
alternative_which |
private static byte[] |
aOpen |
private static byte[] |
brackclose_hash |
private static byte[] |
close_quotetagn |
private static byte[] |
close_tagn |
private static byte[] |
dpdpa |
private static byte[] |
hash_brackopen_slash |
private static byte |
hashChar |
private static byte[] |
iClose |
private static byte |
lbr |
private static byte |
lcbr |
private static byte |
lrbr |
private static byte[] |
mClose |
private static byte[] |
mOpen |
private static byte[] |
multi_num |
private static byte[] |
open_endtag |
private static byte |
pcChar |
private static byte[] |
pClose |
private static byte[] |
PP |
private static byte |
rbr |
private static byte |
rcbr |
private static byte |
rrbr |
private static byte[] |
slashChar |
private static byte[] |
ul |
private static byte[] |
UNRESOLVED_PATTERN |
Constructor and Description |
---|
TemplateEngine() |
Modifier and Type | Method and Description |
---|---|
private static byte[] |
appendBytes(byte[] b1,
byte[] b2,
byte[] b3,
byte[] b4) |
private static java.lang.String |
getPatternKey(byte[] prefix,
byte[] key) |
static void |
main(java.lang.String[] args) |
private static byte[] |
newPrefix(byte[] oldPrefix,
byte[] key) |
private static byte[] |
newPrefix(byte[] oldPrefix,
byte[] multi_key,
int i) |
private static byte[] |
replacePattern(java.lang.String key,
serverObjects pattern) |
private static boolean |
transferUntil(java.io.PushbackInputStream i,
java.io.OutputStream o,
byte p) |
private static boolean |
transferUntil(java.io.PushbackInputStream i,
java.io.OutputStream o,
byte[] pattern)
transfer until a specified pattern is found; everything but the pattern is transfered so far
the function returns true, if the pattern is found
|
static void |
writeTemplate(java.lang.String servletname,
java.io.InputStream in,
java.io.OutputStream out,
serverObjects pattern) |
private static byte[] |
writeTemplate(java.lang.String servletname,
java.io.InputStream in,
java.io.OutputStream out,
serverObjects pattern,
byte[] prefix)
Reads a input stream, and writes the data with replaced templates on a output stream
|
private static final byte hashChar
private static final byte[] slashChar
private static final byte pcChar
private static final byte[] dpdpa
private static final byte lbr
private static final byte rbr
private static final byte[] pClose
private static final byte lcbr
private static final byte rcbr
private static final byte[] mOpen
private static final byte[] mClose
private static final byte lrbr
private static final byte rrbr
private static final byte[] aOpen
private static final byte[] aClose
private static final byte[] iClose
private static final byte[] ul
private static final byte[] alternative_which
private static final byte[] multi_num
private static final byte[] open_endtag
private static final byte[] close_quotetagn
private static final byte[] close_tagn
private static final byte[] PP
private static final byte[] hash_brackopen_slash
private static final byte[] brackclose_hash
private static final byte[] UNRESOLVED_PATTERN
private static final boolean transferUntil(java.io.PushbackInputStream i, java.io.OutputStream o, byte[] pattern) throws java.io.IOException
java.io.IOException
private static final boolean transferUntil(java.io.PushbackInputStream i, java.io.OutputStream o, byte p) throws java.io.IOException
java.io.IOException
public static final void writeTemplate(java.lang.String servletname, java.io.InputStream in, java.io.OutputStream out, serverObjects pattern) throws java.io.IOException
java.io.IOException
private static final byte[] writeTemplate(java.lang.String servletname, java.io.InputStream in, java.io.OutputStream out, serverObjects pattern, byte[] prefix) throws java.io.IOException
java.io.IOException
private static final byte[] replacePattern(java.lang.String key, serverObjects pattern)
private static final byte[] newPrefix(byte[] oldPrefix, byte[] key)
private static final byte[] newPrefix(byte[] oldPrefix, byte[] multi_key, int i)
private static final java.lang.String getPatternKey(byte[] prefix, byte[] key)
private static final byte[] appendBytes(byte[] b1, byte[] b2, byte[] b3, byte[] b4)
public static void main(java.lang.String[] args)