Class PayloadRecorder

  • All Implemented Interfaces:
    java.lang.AutoCloseable, PayloadProvider

    public class PayloadRecorder
    extends java.lang.Object
    implements java.lang.AutoCloseable, PayloadProvider
    • Constructor Detail

      • PayloadRecorder

        public PayloadRecorder()
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • PayloadRecorder

        public PayloadRecorder​(boolean autoFinish)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • PayloadRecorder

        public PayloadRecorder​(boolean autoFinish,
                               PayloadCoding payloadCoding,
                               java.lang.String payloadFlags,
                               DigestAlgorithm fileDigestAlgorithm)
                        throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • addFile

        public PayloadRecorder.Result addFile​(java.lang.String targetPath,
                                              java.nio.file.Path path)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • addFile

        public PayloadRecorder.Result addFile​(java.lang.String targetPath,
                                              java.nio.file.Path path,
                                              java.util.function.Consumer<org.apache.commons.compress.archivers.cpio.CpioArchiveEntry> customizer)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • addFile

        public PayloadRecorder.Result addFile​(java.lang.String targetPath,
                                              java.nio.ByteBuffer data)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • addFile

        public PayloadRecorder.Result addFile​(java.lang.String targetPath,
                                              java.nio.ByteBuffer data,
                                              java.util.function.Consumer<org.apache.commons.compress.archivers.cpio.CpioArchiveEntry> customizer)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • addFile

        public PayloadRecorder.Result addFile​(java.lang.String targetPath,
                                              java.io.InputStream stream)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • addFile

        public PayloadRecorder.Result addFile​(java.lang.String targetPath,
                                              java.io.InputStream stream,
                                              java.util.function.Consumer<org.apache.commons.compress.archivers.cpio.CpioArchiveEntry> customizer)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • addDirectory

        public PayloadRecorder.Result addDirectory​(java.lang.String targetPath,
                                                   java.util.function.Consumer<org.apache.commons.compress.archivers.cpio.CpioArchiveEntry> customizer)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • addSymbolicLink

        public PayloadRecorder.Result addSymbolicLink​(java.lang.String targetPath,
                                                      java.lang.String linkTo,
                                                      java.util.function.Consumer<org.apache.commons.compress.archivers.cpio.CpioArchiveEntry> customizer)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • finish

        public void finish()
                    throws java.io.IOException
        Stop recording payload data

        If the recorder is already finished then nothing will happen

        Throws:
        java.io.IOException - in case of IO errors
      • getArchiveSize

        public long getArchiveSize()
                            throws java.io.IOException
        Description copied from interface: PayloadProvider
        Get the number of bytes of the uncompressed payload archive
        Specified by:
        getArchiveSize in interface PayloadProvider
        Returns:
        the number of bytes of the uncompressed payload archive
        Throws:
        java.io.IOException - if anything goes wrong
      • getPayloadSize

        public long getPayloadSize()
                            throws java.io.IOException
        Description copied from interface: PayloadProvider
        The number of bytes of the compressed archive file
        Specified by:
        getPayloadSize in interface PayloadProvider
        Returns:
        the number of bytes of the compressed archive file
        Throws:
        java.io.IOException - if anything goes wrong
      • getPayloadCoding

        public PayloadCoding getPayloadCoding()
        Description copied from interface: PayloadProvider
        The compression method for this compressed archive file
        Specified by:
        getPayloadCoding in interface PayloadProvider
        Returns:
        the compression method for this compressed archive file
      • getPayloadFlags

        public java.util.Optional<java.lang.String> getPayloadFlags()
        Description copied from interface: PayloadProvider
        The compression flags for this compressed archive file, if any
        Specified by:
        getPayloadFlags in interface PayloadProvider
        Returns:
        the compression flags for this compressed archive file, if any
      • getFileDigestAlgorithm

        public DigestAlgorithm getFileDigestAlgorithm()
        Description copied from interface: PayloadProvider
        The algorithm used for generating file checksum digests whose ordinal is defined in HashAlgorithmTags
        Specified by:
        getFileDigestAlgorithm in interface PayloadProvider
        Returns:
        the algorithm used for generating file checksum digests whose ordinal is defined in HashAlgorithmTags
      • openChannel

        public java.nio.channels.FileChannel openChannel()
                                                  throws java.io.IOException
        Description copied from interface: PayloadProvider
        Open a new channel to the payload data

        The caller is responsible for closing the resource

        Specified by:
        openChannel in interface PayloadProvider
        Returns:
        the newly created channel
        Throws:
        java.io.IOException - if opening the channels fails
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.io.IOException