Class AbstractPipeline<T extends CustomContext>

java.lang.Object
com.itextpdf.tool.xml.pipeline.AbstractPipeline<T>
Type Parameters:
T - the type of CustomContext
All Implemented Interfaces:
Pipeline<T>
Direct Known Subclasses:
AutoDocPipeline, CssResolverPipeline, ElementHandlerPipeline, HtmlPipeline, PdfWriterPipeline

public abstract class AbstractPipeline<T extends CustomContext> extends Object implements Pipeline<T>
Abstract class with default implementations. Override this instead of implementing Pipeline and let your pipeline override only the methods relevant to your implementation.
  • Field Details

  • Constructor Details

    • AbstractPipeline

      public AbstractPipeline(Pipeline<?> next)
      Parameters:
      next - the pipeline that's next in the sequence.
  • Method Details

    • getNext

      public Pipeline<?> getNext()
      Description copied from interface: Pipeline
      Returns the next pipeline in line.
      Specified by:
      getNext in interface Pipeline<T extends CustomContext>
      Returns:
      the next pipeline
    • open

      public Pipeline<?> open(WorkerContext context, Tag t, ProcessObject po) throws PipelineException
      Just calls getNext.
      Override this to get notified on encountered opening tags.
      Specified by:
      open in interface Pipeline<T extends CustomContext>
      Parameters:
      context - the WorkerContext
      t - the Tag
      po - a processObject to put Writables in
      Returns:
      the next pipeline in line
      Throws:
      PipelineException - can be thrown to indicate that something went wrong.
    • content

      public Pipeline<?> content(WorkerContext ctx, Tag currentTag, String text, ProcessObject po) throws PipelineException
      Just calls getNext.
      Override this to get notified on encountered content.
      Specified by:
      content in interface Pipeline<T extends CustomContext>
      Parameters:
      ctx - the WorkerContext
      currentTag - the Tag
      text - the content
      po - a processObject to put Writables in
      Returns:
      the next pipeline in line
      Throws:
      PipelineException - can be thrown to indicate that something went wrong.
    • close

      public Pipeline<?> close(WorkerContext context, Tag t, ProcessObject po) throws PipelineException
      Just calls getNext.
      Override this to get notified on encountered closing tags.
      Specified by:
      close in interface Pipeline<T extends CustomContext>
      Parameters:
      context - the WorkerContext
      t - the Tag
      po - a processObject to put Writables in
      Returns:
      the next pipeline in line
      Throws:
      PipelineException - can be thrown to indicate that something went wrong.
    • getLocalContext

      public T getLocalContext(WorkerContext context) throws PipelineException
      Returns the local context for this class using getContextKey, override this together with getContextKey to change the key usage in case you want to add multiple identical pipelines to the worker.
      Parameters:
      context - the WorkerContext
      Returns:
      the local context for this class using getContextKey()
      Throws:
      PipelineException - thrown when there is no CustomContext or the CustomContext is null.
    • setNext

      public void setNext(Pipeline<?> next)
      setNext method. When using this while parsing one can make live changes the pipeline structure. Use with caution.
      Parameters:
      next - set the next pipeline
    • getContextKey

      public String getContextKey()
      Defaults to the fully qualified class name of the object.
      Returns:
      getClass().getName() as name.
    • init

      public Pipeline<?> init(WorkerContext context) throws PipelineException
      Description copied from interface: Pipeline
      The init method allows implementation to initialize the pipeline. e.g. Initialize their CustomContext here and add it to the WorkerContext through WorkerContext.put(String, CustomContext).
      Specified by:
      init in interface Pipeline<T extends CustomContext>
      Parameters:
      context - the WorkerContext
      Returns:
      the next pipeline in line
      Throws:
      PipelineException - can be thrown to indicate that something went wrong.