org.kefirsf.bb.proc.IfExpression 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.util.List;
/**
* @author kefir
*/
public class IfExpression extends AbstractTemplate implements ProcTemplateElement {
/**
* The name of checked variable
*/
private final String name;
public IfExpression(String name, List extends ProcTemplateElement> elements) {
super(elements);
this.name = name;
}
public CharSequence generate(Context context) {
if (context.getLocalAttribute(name) != null) {
StringBuilder b = new StringBuilder();
for (ProcTemplateElement element : elements) {
b.append(element.generate(context));
}
return b;
} else {
return "";
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy