Record Class ArchiveEntry
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 (seeArchiveEntry.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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe builder forArchiveEntry.static final recordPermission flags for a single target (e.g., user, group or world).static final recordA set of permissions.static enumThe type ofArchiveEntry. -
Constructor Summary
ConstructorsConstructorDescriptionArchiveEntry(@NonNull String name, @NonNull ArchiveEntry.Type type, @Nullable ArchiveEntry.PermissionSet permissions, @Nullable Long size) Construct an entry found in an archive. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull ArchiveEntry.Builderbuilder()Create a builder for anArchiveEntry.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NonNull Stringname()Returns the value of thenamerecord component.@Nullable ArchiveEntry.PermissionSetReturns the value of thepermissionsrecord component.@NonNull FileresolveFile(@NonNull File parent, boolean includeRoot) Resolve a reference to a file, relative to the givenparent.@Nullable Longsize()Returns the value of thesizerecord component.final StringtoString()Returns a string representation of this record class.@NonNull ArchiveEntry.Typetype()Returns the value of thetyperecord component.
-
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
Create a builder for anArchiveEntry.- Returns:
- The
ArchiveEntry.Builder.
-
resolveFile
Resolve a reference to a file, relative to the givenparent.If
includeRootis 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 givenparent).- 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
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
permissions
Returns the value of thepermissionsrecord component.- Returns:
- the value of the
permissionsrecord component
-
size
Returns the value of thesizerecord component.- Returns:
- the value of the
sizerecord component
-