All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kefirsf.bb.proc.IfExpression Maven / Gradle / Ivy

Go to download

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 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