for (int i = 0; i < outerTime; i++) {
for (int j = 0; j < innerTime; j++) {
testXMLTemplate();
}
for (int j = 0; j < innerTime; j++) {
testVelocityTemplate();
}
for (int j = 0; j < innerTime; j++) {
testCommonTemplate();
}
for (int j = 0; j < innerTime; j++) {
testFreeMarker();
}
for (int j = 0; j < innerTime; j++) {
testSmarty4j();
}
for (int j = 0; j < innerTime; j++) {
testJavaCode();
}
}
<div xmlns:c="http://www.xidea.org/ns/template/core">
<h1>${name}</h1>
<table border="${border}">
<tr>
<th> </th>
<c:for var="cell" items="${data}">
<th>${cell}</th>
</c:for>
</tr>
<c:for var="row" items="${data}">
<tr>
<th>${row}</th>
<c:for var="cell" items="${data}">
<td><c:out value="&#x"/>${row}${cell};</td>
</c:for>
</tr>
</c:for>
</table>
</div>
<div>
<h1>${name}</h1>
<table border="${border}">
<tr>
<th> </th>
#foreach($cell in $data)
<th>${cell}</th>
#end
</tr>
#foreach($row in $data)
<tr>
<th>${row}</th>
#foreach($cell in $data )
<td>&#x${row}${cell};</td>
#end
</tr>
#end
</table>
</div>
<div>
<h1>${name}</h1>
<table border="${border}">
<tr>
<th> </th>
$for{cell:data}
<th>${cell}</th>
$end
</tr>
$for{row:data}
<tr>
<th>${row}</th>
$for{cell:data}
<td>&#x${row}${cell};</td>
$end
</tr>
$end
</table>
</div>
<div>
<h1>${name}</h1>
<table border="${border}">
<tr>
<th> </th>
<#list data as cell>
<th>${cell}</th>
</#list>
</tr>
<#list data as row>
<tr>
<th>${row}</th>
<#list data as cell>
<td>&#x${row}${cell};</td>
</#list>
</tr>
</#list>
</table>
</div>
ST:asciitable.html
<div>
<h1>{$name}</h1>
<table border="{$border}">
<tr>
<th> </th>
{section loop=$data name="cell"}
<th>{$cell}</th>
{/section}
</tr>
{section loop=$data name="row"}
<tr>
<th>{$row}</th>
{section loop=$data name="cell"}
<td>&#x{$row}{$cell};</td>
{/section}
</tr>
{/section}
</table>
</div>
package org.jside.tt;
import java.io.Writer;
import java.util.List;
import java.util.Map;
public class asciitable implements ICode {
@Override
public void execute(Map<String, Object> context, Writer writer) throws Exception {
List<String> data = (List<String>) context.get("data");
String name = (String) context.get("name");
String border = (String) context.get("border");
writer.write("<div>\n<h1>");
writer.write(name);
writer.write("</h1>\n<table border=\"");
writer.write(border);
writer.write("\">\n\t<tr>\n\t\t<th> </th>\n");
for (String cell : data) {
writer.write("\t\t<th>");
writer.write(cell);
writer.write("</th>\n");
}
writer.write("\t</tr>\n");
for (String row : data) {
writer.write("\t<tr>\n<th>");
writer.write(row);
writer.write("</th>\n");
for (String cell : data) {
writer.write("\t\t<td>&#x");
writer.write(row);
writer.write(cell);
writer.write("</td>\n");
}
writer.write("\t</tr>\n");
}
writer.write("</table>\n</div>\n");
}
}
XT:
<td>${name}:<c:out value="&#x"/>${row}${cell};</td>
VT:
<td>${name}:&#x${row}${cell};</td>
CT:
<td>${name}:&#x${row}${cell};</td>
FT:
<td>${name}:&#x${row}${cell};</td>
ST:
<td>{$name}:&#x{$row}{$cell};</td>
JAVA:
writer.write("\t\t<td>");
writer.write(name);
writer.write(":&#x");
writer.write(row);
writer.write(cell);
writer.write("</td>\n");
XT:
<td><c:if test="${(row=='4' && cell!='0') || (row=='5' && cell<'B')}"><c:out value="&#x"/>${row}${cell};</c:if><c:else><c:out value="&"/>nbsp;</c:else></td>
VT:
<td>#if(($row=="4" && $cell!="0") || ($row=="5" && $cell!="B" && $cell!="C" && $cell!="D" && $cell!="E" && $cell!="F"))&#x${row}${cell};#else #end</td>
CT:
<td>$if{(row=="4" && cell!="0") || (row=="5" && cell<"B")}&#x${row}${cell};$else{} $end</td>
FT:
<td><#if (row?string=="4" && cell?string!="0") || (row?string=='5' && cell?string!='B' && cell?string!='C' && cell?string!='D' && cell?string!='E' && cell?string!='F')>&#x${row}${cell};<#else> </#if></td>
ST:
<td>{if ($row==='4' && $cell!=='0') || ($row==='5' && $cell<'B')}&#x{$row}{$cell};{else} {/if}</td>
JAVA:
writer.write("\t\t<td>");
if ((row.equals("4") && !cell.equals("0"))
|| (row.equals("5") && cell.compareTo("B") < 0)) {
writer.write("&#x");
writer.write(row);
writer.write(cell);
} else {
writer.write(" ");
}
writer.write("</td>\n");
for (String row : data) {
char cRow = row.charAt(0);
writer.write("\t<tr>\n<th>");
writer.write(row);
writer.write("</th>\n");
for (String cell : data) {
char cCell = cell.charAt(0);
writer.write("\t\t<td>");
if ((cRow == '4' && cCell != '0') || (cRow == '5' && cCell < 'B')) {
writer.write("&#x");
writer.write(row);
writer.write(cell);
} else {
writer.write(" ");
}
writer.write("</td>\n");
}
writer.write("\t</tr>\n");
}