Class PosixTarHeader.Builder
- Enclosing class:
PosixTarHeader
PosixTarHeader
.
The following fields are required:
build()
may be called multiple times. With the exception of the required fields
listed above, fields will retain the values. This is useful if you want to construct many
file headers with the same value for certain certain fields (e.g. uid, gid, uname, gname)
but don't want to have to call their setters repeatedly.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns a new immutablePosixTarHeader
instance.setGid
(int gid) Sets the UNIX group ID.Sets the UNIX group of the file.setMode
(int mode) Sets the UNIX file mode aka permissions.setMtime
(org.joda.time.DateTime mtime) Sets the modified time of the file.Sets the file name.setSize
(long size) Sets the file size.setType
(PosixTarHeader.Type type) Sets the filePosixTarHeader.Type
.setUid
(int uid) Sets the owner's UNIX user ID.Sets the UNIX owner of the file.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
setName
Sets the file name. (Required)- Parameters:
name
- must be<100
characters in length.
-
setMode
Sets the UNIX file mode aka permissions. By default this is 416.- Parameters:
mode
- This value is octal. Just in case you were wondering,416
is the decimal representation of0640
. If that number doesn't look familiar to you, search Google for "chmod". The value must be>=0
and<8^7
.
-
setUid
Sets the owner's UNIX user ID. By default this is 0.- Parameters:
uid
- must be>=0
and<8^7
.- See Also:
-
setGid
Sets the UNIX group ID. By default this is 0.- Parameters:
gid
- must be>=0
and<8^7
.- See Also:
-
setSize
Sets the file size. (Required)This value must be known in advance. There's no such thing as a streaming tar archive.
- Parameters:
size
- must be>=0
and<8^11
which places an eight gigabyte limit.
-
setMtime
Sets the modified time of the file. By default, this is the time the builder object was constructed.The modified time is always stored as a UNIX timestamp which is seconds since the UNIX epoch in UTC time. Because
DateTime
has millisecond precision, it gets rounded down (floor) to the second. -
setType
Sets the filePosixTarHeader.Type
. By default this isPosixTarHeader.Type.REGULAR
. -
setUname
Sets the UNIX owner of the file. By default this is "root".- Parameters:
uname
- must be<32
characters in length.- See Also:
-
setGname
Sets the UNIX group of the file. By default this is "wheel".- Parameters:
gname
- must be<32
characters in length.- See Also:
-
build
Returns a new immutablePosixTarHeader
instance.It's safe to save a reference to the builder instance and call this method multiple times because the header data is copied into the resulting object.
- Throws:
IllegalStateException
- if you forgot to call required setters.
-