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

org.kefirsf.bb.proc.ProcTemplate 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.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 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