java.lang.Object
java.lang.Record
xyz.apollosoftware.bibliothiki.compression.formats.tar.TapeArchiveEntryHeader
Record Components:
name - The path and name of the file (max. 100 chars).
mode - The UNIX permission mode of the file.
owner - The UID of the owner of the file.
group - The UID of the group that owns the file.
fileSize - The file size, in bytes.
lastModified - The timestamp that the file was last modified.
checksum - The checksum for the header record.
type - The file type.
linkedFile - The path that the file links to, if the link indicator indicates that the file is a link, rather than a normal file. If the link indicator is such that the file is not a link, this is null.
unixStandardHeader - The UNIX Standard header data (if present).

public record TapeArchiveEntryHeader(@NonNull String name, long mode, long owner, long group, long fileSize, Instant lastModified, long checksum, @NonNull TapeArchiveEntryHeader.Type type, @Nullable String linkedFile, @Nullable TapeArchiveEntryHeader.UnixStandardEntryHeader unixStandardHeader) extends Record
The header for a Tape Archive file.
  • Field Details

  • Constructor Details

    • TapeArchiveEntryHeader

      public TapeArchiveEntryHeader(@NonNull String name, long mode, long owner, long group, long fileSize, Instant lastModified, long checksum, @NonNull TapeArchiveEntryHeader.Type type, @Nullable String linkedFile, @Nullable TapeArchiveEntryHeader.UnixStandardEntryHeader unixStandardHeader)
      Construct a header for a tar archive.

      This record represents either an entry that is being added to an archive or which has been parsed from an existing archive.

      Parameters:
      name - The name of the entry.
      mode - The UNIX permission mode of the entry.
      owner - The owner UID of the entry.
      group - The group UID of the entry.
      fileSize - The size of the entry, in bytes.
      lastModified - The last modification timestamp of the entry.
      checksum - The checksum of the entry header.
      type - The type of entry.
      linkedFile - The linked file (if applicable).
      unixStandardHeader - The UNIX Standard tar (UStar) header data (if applicable).
  • Method Details

    • builder

      public static @NonNull TapeArchiveEntryHeader.Builder builder()
      Create a builder for a TapeArchiveEntryHeader.

      This can be useful when wrapping code for creating archives, as well as for reading parameters from a tar file.

      Returns:
      The TapeArchiveEntryHeader.Builder.
    • hasUnixStandardHeader

      public boolean hasUnixStandardHeader()
      Returns whether the TapeArchiveEntryHeader.UnixStandardEntryHeader is present (i.e., whether the UStar fields are present).
      Returns:
      Whether the UStar header is present.
    • getFullName

      public @NonNull String getFullName()
      Get the full name of the entry.

      If the entry hasUnixStandardHeader() and TapeArchiveEntryHeader.UnixStandardEntryHeader.filenamePrefix(), they are concatenated to produce the full name.

      Otherwise, the name() field is used directly.

      Returns:
      The full path and name of the entry.
    • decode

      public static @NonNull TapeArchiveEntryHeader decode(@NonNull ByteBuffer buffer)
      Decode a header from its binary representation.
      Parameters:
      buffer - A buffer pointing to the binary representation of a header.
      Returns:
      The decoded header.
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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
    • mode

      public long mode()
      Returns the value of the mode record component.
      Returns:
      the value of the mode record component
    • owner

      public long owner()
      Returns the value of the owner record component.
      Returns:
      the value of the owner record component
    • group

      public long group()
      Returns the value of the group record component.
      Returns:
      the value of the group record component
    • fileSize

      public long fileSize()
      Returns the value of the fileSize record component.
      Returns:
      the value of the fileSize record component
    • lastModified

      public Instant lastModified()
      Returns the value of the lastModified record component.
      Returns:
      the value of the lastModified record component
    • checksum

      public long checksum()
      Returns the value of the checksum record component.
      Returns:
      the value of the checksum record component
    • type

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

      public @Nullable String linkedFile()
      Returns the value of the linkedFile record component.
      Returns:
      the value of the linkedFile record component
    • unixStandardHeader

      public @Nullable TapeArchiveEntryHeader.UnixStandardEntryHeader unixStandardHeader()
      Returns the value of the unixStandardHeader record component.
      Returns:
      the value of the unixStandardHeader record component