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

org.kefirsf.bb.TextProcessorChain 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;

import java.util.Collections;
import java.util.List;

/**
 * Chain of text processors wich process text serially
 *
 * @author Kefir
 */
public class TextProcessorChain extends TextProcessorAdapter {
    /**
     * List of processors
     */
    private final List processors;

    public TextProcessorChain(List processors) {
        this.processors = Collections.unmodifiableList(processors);
    }

    /**
     * Process the text
     *
     * @param source the sourcetext
     * @return the result of text processing
     * @see TextProcessor#process(CharSequence)
     */
    public CharSequence process(CharSequence source) {
        CharSequence target = source;
        for (TextProcessor processor : processors) {
            target = processor.process(target);
        }
        return target;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy