java.lang.Object
java.lang.Record
xyz.apollosoftware.bibliothiki.compression.ArchiveEntry
Record Components:
name - The name of the entry, relative to the root of the archive.
type - The type of entry (see ArchiveEntry.Type).
permissions - The permissions for the entry (if available).
size - The uncompressed size of the entry (if available).

public record ArchiveEntry(@NonNull String name, @NonNull ArchiveEntry.Type type, @Nullable ArchiveEntry.PermissionSet permissions, @Nullable Long size) extends Record
An entry found in an archive.
  • Constructor Details

    • ArchiveEntry

      public ArchiveEntry(@NonNull String name, @NonNull ArchiveEntry.Type type, @Nullable ArchiveEntry.PermissionSet permissions, @Nullable Long size)
      Construct an entry found in an archive.

      This constructor also normalizes the path and ensures it is not an absolute path.

      Parameters:
      name - The name of the archive entry.
      type - The type of the archive entry.
      permissions - The permissions (if available) of the archive entry.
      size - The size (if available) of the archive entry.
      Throws:
      CompressionSecurityException - If the name denotes an absolute file path.
      See Also:
  • Method Details

    • builder

      public static @NonNull ArchiveEntry.Builder builder()
      Create a builder for an ArchiveEntry.
      Returns:
      The ArchiveEntry.Builder.
    • resolveFile

      public @NonNull File resolveFile(@NonNull File parent, boolean includeRoot) throws IOException
      Resolve a reference to a file, relative to the given parent.

      If includeRoot is false, the first path component of every entry inside the archive will be ignored (this allows an archived directory to be extracted directly into the given parent).

      Parameters:
      parent - The parent directory to resolve paths relative to.
      includeRoot - Whether to include the first path component for each component in the archive.
      Returns:
      The resolved file.
      Throws:
      IOException - If file system queries fail.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public @NonNull String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • type

      public @NonNull ArchiveEntry.Type type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • permissions

      public @Nullable ArchiveEntry.PermissionSet permissions()
      Returns the value of the permissions record component.
      Returns:
      the value of the permissions record component
    • size

      public @Nullable Long size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component