Class PosixTarHeader.Builder

java.lang.Object
google.registry.util.PosixTarHeader.Builder
Enclosing class:
PosixTarHeader

public static class PosixTarHeader.Builder extends 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 Details

    • Builder

      public Builder()
  • Method Details

    • setName

      public PosixTarHeader.Builder setName(String name)
      Sets the file name. (Required)
      Parameters:
      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.
      Parameters:
      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.
    • setUid

      public PosixTarHeader.Builder setUid(int uid)
      Sets the owner's UNIX user ID. By default this is 0.
      Parameters:
      uid - must be >=0 and <8^7.
      See Also:
    • setGid

      public PosixTarHeader.Builder setGid(int gid)
      Sets the UNIX group ID. By default this is 0.
      Parameters:
      gid - must be >=0 and <8^7.
      See Also:
    • 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.

      Parameters:
      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.

    • setType

      Sets the file PosixTarHeader.Type. By default this is PosixTarHeader.Type.REGULAR.
    • setUname

      public PosixTarHeader.Builder setUname(String uname)
      Sets the UNIX owner of the file. By default this is "root".
      Parameters:
      uname - must be <32 characters in length.
      See Also:
    • setGname

      public PosixTarHeader.Builder setGname(String gname)
      Sets the UNIX group of the file. By default this is "wheel".
      Parameters:
      gname - must be <32 characters in length.
      See Also:
    • 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.

      Throws:
      IllegalStateException - if you forgot to call required setters.