Class PrintWriterAssembler<D>

  • Type Parameters:
    D - The type of domain objects to assemble the product from
    All Implemented Interfaces:
    Assembler<D>
    Direct Known Subclasses:
    InfoArchivePackagingInformationAssembler, PdiAssembler

    public abstract class PrintWriterAssembler<D>
    extends java.lang.Object
    implements Assembler<D>
    Base class for assembling a product from domain objects by writing to a PrintWriter.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(D domainObject)
      Add a component to the assembly.
      protected abstract void add​(D domainObject, java.io.PrintWriter writer)
      Add a domain object.
      void end()
      Finish the assembly process.
      protected abstract void end​(java.io.PrintWriter writer)
      End the assembly process.
      Metrics getMetrics()
      Return metrics about the assembly process.
      void start​(DataBuffer dataBuffer)
      Start the assembly process.
      protected abstract void start​(java.io.PrintWriter writer)
      Start the assembly process.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PrintWriterAssembler

        public PrintWriterAssembler()
        Create an instance that will not validate the assembled product.
      • PrintWriterAssembler

        public PrintWriterAssembler​(Validator validator)
        Create an instance.
        Parameters:
        validator - Optional validator for checking whether the assembled product meets expectations
    • Method Detail

      • start

        protected abstract void start​(java.io.PrintWriter writer)
                               throws java.io.IOException
        Start the assembly process.
        Parameters:
        writer - Where to write output
        Throws:
        java.io.IOException - When an I/O error occures
      • add

        protected abstract void add​(D domainObject,
                                    java.io.PrintWriter writer)
                             throws java.io.IOException
        Add a domain object.
        Parameters:
        domainObject - The domain object to add
        writer - Where to write output
        Throws:
        java.io.IOException - When an I/O error occures
      • end

        protected abstract void end​(java.io.PrintWriter writer)
                             throws java.io.IOException
        End the assembly process.
        Parameters:
        writer - Where to write output
        Throws:
        java.io.IOException - When an I/O error occures
      • start

        public final void start​(DataBuffer dataBuffer)
                         throws java.io.IOException
        Description copied from interface: Assembler
        Start the assembly process.
        Specified by:
        start in interface Assembler<D>
        Parameters:
        dataBuffer - Storage for the assembled product
        Throws:
        java.io.IOException - When an I/O error occurs
      • add

        public final void add​(D domainObject)
                       throws java.io.IOException
        Description copied from interface: Assembler
        Add a component to the assembly. The assembler must be opened first.
        Specified by:
        add in interface Assembler<D>
        Parameters:
        domainObject - The component to add
        Throws:
        java.io.IOException - When an I/O error occurs
      • end

        public final void end()
                       throws java.io.IOException
        Description copied from interface: Assembler
        Finish the assembly process.
        Specified by:
        end in interface Assembler<D>
        Throws:
        java.io.IOException - When an I/O error occurs
      • getMetrics

        @Nullable
        public Metrics getMetrics()
        Description copied from interface: Assembler
        Return metrics about the assembly process. Implementations will generally provide dedicated classes that you should cast the result to.
        Specified by:
        getMetrics in interface Assembler<D>
        Returns:
        Metrics about the assembly process, or null if no metrics are provided