com.javanut.pronghorn.util.template.CharTemplate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pronghorn-pipes Show documentation
Show all versions of pronghorn-pipes Show documentation
Ring buffer based queuing utility for applications that require high performance and/or a small
footprint. Well suited for embedded and stream based processing.
package com.javanut.pronghorn.util.template;
import java.io.IOException;
public class CharTemplate {
CharTemplateData[] script;
int count;
public CharTemplate() {
script = new CharTemplateData[8];
}
private void append(CharTemplateData fetchData) {
if (count==script.length) {
CharTemplateData[] newScript = new CharTemplateData[script.length*2];
System.arraycopy(script, 0, newScript, 0, script.length);
script = newScript;
}
script[count++] = fetchData;
}
public CharTemplate add(final String text) {
append(
new CharTemplateData() {
@Override
public void fetch(Appendable target, T source) {
try {
target.append(text);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
);
return this;
}
public CharTemplate add(CharTemplateData data) {
append(data);
return this;
}
public void render(Appendable target, T source) {
for(int i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy