org.appng.core.domain

## Class PackageArchiveImpl

- java.lang.Object
- - org.appng.core.domain.PackageArchiveImpl

- All Implemented Interfaces:
    PackageArchive

      public class PackageArchiveImpl
      extends Object
      implements PackageArchive

  A `PackageArchive`.
  Author:
    Matthias Herlitzius

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PackageArchiveImpl(File archive, boolean strict)`
    `PackageArchiveImpl(File archive, String originalFilename)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `getBytes()` Returns the binary data of the archive's ZIP-file.
    `String` | `getChecksum()` Returns the checksum for this archive (SHA256).
    `File` | `getFile()` Returns the archive's ZIP-file.
    `static String` | `getFileName(String applicationName, String applicationVersion, String applicationTimestamp)`
    `String` | `getFilePrefix()`
    `static String` | `getFilePrefix(String applicationName, String applicationVersion)`
    `PackageInfo` | `getPackageInfo()` Returns a `PackageInfo` unmarshalled from the archive's "application.xml".
    `PackageType` | `getType()` Returns the `PackageType` for this `PackageArchive`.
    `boolean` | `isValid()` Checks whether this is a valid `PackageArchive`, meaning it's ZIP-file has a valid structure and contains a valid "application.xml".
    `<T> T` | `processZipFile(ZipFileProcessor<T> processor)` Processes the `PackageArchive`'s ZIP-file with the given `ZipFileProcessor`.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### PackageArchiveImpl

          public PackageArchiveImpl(File archive,
                                    boolean strict)

    - #### PackageArchiveImpl

          public PackageArchiveImpl(File archive,
                                    String originalFilename)

  - ### Method Detail

    - #### processZipFile

          public <T> T processZipFile(ZipFileProcessor<T> processor)
                               throws IOException

      Description copied from interface: `PackageArchive`
      Processes the `PackageArchive`'s ZIP-file with the given `ZipFileProcessor`.
      Specified by:
        `processZipFile` in interface `PackageArchive`
      Type Parameters:
        `T` - the return type of the `ZipFileProcessor`
      Parameters:
        `processor` - a `ZipFileProcessor`
      Returns:
        an object of type `<T>`
      Throws:
        `IOException` -
        - if `ZipFileProcessor.process(org.apache.commons.compress.archivers.zip.ZipFile)` throws an `IOException`
        - if the ZIP-file could not be read

    - #### isValid

          public boolean isValid()

      Description copied from interface: `PackageArchive`
      Checks whether this is a valid `PackageArchive`, meaning it's ZIP-file has a valid structure and contains a valid "application.xml".
      Specified by:
        `isValid` in interface `PackageArchive`
      Returns:
        `true` if this a valid `PackageArchive`, `false` otherwise

    - #### getPackageInfo

          public PackageInfo getPackageInfo()

      Description copied from interface: `PackageArchive`
      Returns a `PackageInfo` unmarshalled from the archive's "application.xml". This methods returns `null`, if `PackageArchive.isValid()` returns `false`.
      Specified by:
        `getPackageInfo` in interface `PackageArchive`
      Returns:
        a `PackageInfo`

    - #### getFilePrefix

          public String getFilePrefix()

    - #### getBytes

          public byte[] getBytes()
                          throws IOException

      Description copied from interface: `PackageArchive`
      Returns the binary data of the archive's ZIP-file. Should only be called if `PackageArchive.isValid()` returns `true`.
      Specified by:
        `getBytes` in interface `PackageArchive`
      Returns:
        the binary data
      Throws:
        `IOException` - if the ZIP-file could not be read

    - #### getFile

          public File getFile()

      Description copied from interface: `PackageArchive`
      Returns the archive's ZIP-file.
      Specified by:
        `getFile` in interface `PackageArchive`
      Returns:
        the file

    - #### getFilePrefix

          public static String getFilePrefix(String applicationName,
                                             String applicationVersion)

    - #### getFileName

          public static String getFileName(String applicationName,
                                           String applicationVersion,
                                           String applicationTimestamp)

    - #### getType

          public PackageType getType()

      Description copied from interface: `PackageArchive`
      Returns the `PackageType` for this `PackageArchive`.
      Specified by:
        `getType` in interface `PackageArchive`
      Returns:
        the `PackageType`

    - #### getChecksum

          public String getChecksum()

      Description copied from interface: `PackageArchive`
      Returns the checksum for this archive (SHA256).
      Specified by:
        `getChecksum` in interface `PackageArchive`
      Returns:
        the checksum

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2011–2023 aiticon GmbH. All rights reserved.