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

htmlflow.visitor.PreprocessingVisitorAsync Maven / Gradle / Ivy

Go to download

HtmlFlow library purpose is to allow Java applications to easily writing HTML documents in a fluent style into a java.io.PrintStream.

The newest version!
package htmlflow.visitor;

import htmlflow.continuations.HtmlContinuation;
import htmlflow.continuations.HtmlContinuationAsync;
import htmlflow.continuations.HtmlContinuationSyncCloseAndIndent;
import org.xmlet.htmlapifaster.Element;
import org.xmlet.htmlapifaster.SuspendConsumer;
import org.xmlet.htmlapifaster.async.AwaitConsumer;


/**
 * @author Pedro Fialho
 **/
public class PreprocessingVisitorAsync extends PreprocessingVisitor {

    public PreprocessingVisitorAsync(boolean isIndented) {
        super(isIndented);
    }

    @Override
    public  void visitAwait(E element, AwaitConsumer asyncHtmlBlock) {
        /**
         * Creates an HtmlContinuation for the async block.
         */
        HtmlContinuation asyncCont = new HtmlContinuationAsync<>(
                depth,
                isClosed,
                element,
                asyncHtmlBlock,
                this,
                new HtmlContinuationSyncCloseAndIndent(this));
        /**
         * We are resolving this view for the first time.
         * Now we just need to create an HtmlContinuation corresponding to the previous static HTML,
         * which will be followed by the asyncCont.
         */
        chainContinuationStatic(asyncCont);
        /**
         * We have to run newlineAndIndent to leave isClosed and indentation correct for
         * the next static HTML block.
         */
        indentAndAdvanceStaticBlockIndex();
    }

    @Override
    public  void visitSuspending(E element, SuspendConsumer suspendAction) {
        throw new UnsupportedOperationException("Illegal use of suspending builder. To use it you should create a HtmlViewSuspend.");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy