Class PosixTarHeader.Builder

  • Enclosing class:

    public static class PosixTarHeader.Builder
    extends java.lang.Object
    Builder for 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 Detail

      • Builder

        public Builder()
    • Method Detail

      • setName

        public PosixTarHeader.Builder setName​(java.lang.String name)
        Sets the file name. (Required)
        name - must be <100 characters in length.
      • setMode

        public PosixTarHeader.Builder setMode​(int mode)
        Sets the UNIX file mode aka permissions. By default this is 416.
        mode - This value is octal. Just in case you were wondering, 416 is the decimal representation of 0640. If that number doesn't look familiar to you, search Google for "chmod". The value must be >=0 and <8^7.
      • setSize

        public PosixTarHeader.Builder setSize​(long size)
        Sets the file size. (Required)

        This value must be known in advance. There's no such thing as a streaming tar archive.

        size - must be >=0 and <8^11 which places an eight gigabyte limit.
      • setMtime

        public PosixTarHeader.Builder setMtime​(org.joda.time.DateTime mtime)
        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.

      • build

        public PosixTarHeader build()
        Returns a new immutable PosixTarHeader 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.

        java.lang.IllegalStateException - if you forgot to call required setters.