org.kefirsf.bb.proc.ProcTemplate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kefirbb Show documentation
Show all versions of kefirbb Show documentation
KefirBB is a Java-library for text processing. Initially it was developed for BB2HTML translation.
But flexible configuration allows to use it in different cases. For example for parsing Markdown, Textile,
and for HTML filtration.
The newest version!
package org.kefirsf.bb.proc;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
/**
* Code template
*
* @author Vitaliy Samolovskih aka Kefir
*/
public class ProcTemplate extends AbstractTemplate {
/**
* Empty template
*/
public static final ProcTemplate EMPTY = new ProcTemplate(Collections.emptyList());
/**
* Create neq template with elements.
*
* @param elements template elements.
*/
public ProcTemplate(List extends ProcTemplateElement> elements) {
super(elements);
}
/**
* Append to result string processed text.
*
* @param context current context.
*/
public void generate(Context context) {
Appendable target = context.getTarget();
for (ProcTemplateElement element : elements) {
try {
target.append(element.generate(context));
} catch (IOException e) {
// Nothing! Because StringBuilder doesn't catch IOException
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy