Record Class TapeArchiveEntryHeader
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe builder forTapeArchiveEntryHeader.static enumThe type of tape archive entry.static final recordThe UStar (UNIX Standard tar) format extends the nominal tar header to include additional fields. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe length, in bytes, of the file path and name field.static final intThe length, in bytes, of the file path and name prefix.static final intThe maximum name that can be stored in aTapeArchiveEntryHeader, including theTapeArchiveEntryHeader.UnixStandardEntryHeader.static final intThe length, in bytes, of the tape archive header. -
Constructor Summary
ConstructorsConstructorDescriptionTapeArchiveEntryHeader(@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. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull TapeArchiveEntryHeader.Builderbuilder()Create a builder for aTapeArchiveEntryHeader.longchecksum()Returns the value of thechecksumrecord component.static @NonNull TapeArchiveEntryHeaderdecode(@NonNull ByteBuffer buffer) Decode a header from its binary representation.final booleanIndicates whether some other object is "equal to" this one.longfileSize()Returns the value of thefileSizerecord component.@NonNull StringGet the full name of the entry.longgroup()Returns the value of thegrouprecord component.final inthashCode()Returns a hash code value for this object.booleanReturns whether theTapeArchiveEntryHeader.UnixStandardEntryHeaderis present (i.e., whether the UStar fields are present).Returns the value of thelastModifiedrecord component.@Nullable StringReturns the value of thelinkedFilerecord component.longmode()Returns the value of themoderecord component.@NonNull Stringname()Returns the value of thenamerecord component.longowner()Returns the value of theownerrecord component.final StringtoString()Returns a string representation of this record class.@NonNull TapeArchiveEntryHeader.Typetype()Returns the value of thetyperecord component.Returns the value of theunixStandardHeaderrecord component.
-
Field Details
-
LENGTH_BYTES
public static final int LENGTH_BYTESThe length, in bytes, of the tape archive header.- See Also:
-
FILENAME_LENGTH_BYTES
public static final int FILENAME_LENGTH_BYTESThe length, in bytes, of the file path and name field.- See Also:
-
FILENAME_PREFIX_LENGTH_BYTES
public static final int FILENAME_PREFIX_LENGTH_BYTESThe length, in bytes, of the file path and name prefix.- See Also:
-
FULL_FILENAME_LENGTH_BYTES
public static final int FULL_FILENAME_LENGTH_BYTESThe maximum name that can be stored in aTapeArchiveEntryHeader, including theTapeArchiveEntryHeader.UnixStandardEntryHeader.(Longer names may be supported but will be implemented with the
TapeArchivePaxAttributes).- See Also:
-
-
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
Create a builder for aTapeArchiveEntryHeader.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 theTapeArchiveEntryHeader.UnixStandardEntryHeaderis present (i.e., whether the UStar fields are present).- Returns:
- Whether the UStar header is present.
-
getFullName
Get the full name of the entry.If the entry
hasUnixStandardHeader()andTapeArchiveEntryHeader.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
Decode a header from its binary representation.- Parameters:
buffer- A buffer pointing to the binary representation of a header.- Returns:
- The decoded header.
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
mode
public long mode()Returns the value of themoderecord component.- Returns:
- the value of the
moderecord component
-
owner
public long owner()Returns the value of theownerrecord component.- Returns:
- the value of the
ownerrecord component
-
group
public long group()Returns the value of thegrouprecord component.- Returns:
- the value of the
grouprecord component
-
fileSize
public long fileSize()Returns the value of thefileSizerecord component.- Returns:
- the value of the
fileSizerecord component
-
lastModified
Returns the value of thelastModifiedrecord component.- Returns:
- the value of the
lastModifiedrecord component
-
checksum
public long checksum()Returns the value of thechecksumrecord component.- Returns:
- the value of the
checksumrecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
linkedFile
Returns the value of thelinkedFilerecord component.- Returns:
- the value of the
linkedFilerecord component
-
unixStandardHeader
Returns the value of theunixStandardHeaderrecord component.- Returns:
- the value of the
unixStandardHeaderrecord component
-