Class PosixPermissions.PosixPermissionsBuilder
- Enclosing class:
- PosixPermissions
PosixPermissions.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build a newPosixPermissionsset.create()Create a newPosixPermissions.PosixPermissionsBuilderAdd all permissions for everyone.fromBitmask(long mode) Set the mode using a either a rawintor a rawlong.fromBitmask(com.sshtools.common.util.UnsignedInteger32 mode) Set the mode using a a raw unsigned 32 bit value.fromFileModeString(String fileModes) Set the mode using a full (9 character) file mode string.fromLaxFileModeString(String fileModes) Set the mode using a file mode string.fromMaskString(String maskString) Set the mode using a UNIX style mask octal string, for example '0644'.Removes all permission from the set to be built.fromPermissions(PosixFilePermission... permissions) Set the mode using an array ofPosixFilePermission.fromPermissions(Collection<PosixFilePermission> permissions) Set the mode using a collection ofPosixFilePermission.fromPosixPermissions(PosixPermissions permissions) Set the mode using an existingPosixPermissions.fromUmaskString(String umask) Set the mode using a UNIX style umask, for example '0022' will result in 0022 ^ 0777.Adds execute permission to user, group and other.Adds read permission to user, group and other.Adds write permission to user, group and other.withBitmaskFlags(long flags) Adds a set of modes using bitmask flags via a rawintor a rawlong.withChmodArgumentString(String chmodArgument) Set the mode using a format compatible with the UNIX chmod command.withoutBitmaskFlags(long flags) Remove a set of modes using bitmask flags via a rawintor a rawlong.Removes all execute permissions.Removes all group and other permissions.Removes all other permissions.withoutPermissions(PosixFilePermission... permissions) Remove one or morePosixFilePermissionfrom the built set of permissions.withoutPermissions(Collection<PosixFilePermission> permissions) Remove a collection ofPosixFilePermissionfrom the built set of permissions.Removes all write permissions.withPermissions(PosixFilePermission... permissions) Add one or morePosixFilePermissionto the built set of permissions.withPermissions(Collection<PosixFilePermission> permissions) Add a collection ofPosixFilePermissionto the built set of permissions.
-
Method Details
-
create
Create a newPosixPermissions.PosixPermissionsBuilder- Returns:
- builder
-
build
Build a newPosixPermissionsset.- Returns:
- permissions
-
fromAllPermissions
Add all permissions for everyone.- Returns:
- this for chaining
-
fromBitmask
Set the mode using a either a rawintor a rawlong. Only the first 32 bits of the value will be used.Any existing value already built will be entirely replaced with this new value.
- Parameters:
raw- mode value- Returns:
- this for chaining
-
fromBitmask
public PosixPermissions.PosixPermissionsBuilder fromBitmask(com.sshtools.common.util.UnsignedInteger32 mode) Set the mode using a a raw unsigned 32 bit value.Any existing value already built will be entirely replaced with this new value.
- Parameters:
raw- mode value- Returns:
- this for chaining
-
fromFileModeString
Set the mode using a full (9 character) file mode string. The first 3 characters are for the user, the second 3 are for group and the final 3 are for other users. The correlating output isPosixPermissions.asFileModesString().Any existing value already built will be entirely replaced with this new value.
- Parameters:
file- mode string- Returns:
- this for chaining
-
fromLaxFileModeString
Set the mode using a file mode string. The string can be any length up to 9 characters, with any length less than this padding the string with '-' until it is 9 characters in length. The first 3 characters are for the user, the second 3 are for group and the final 3 are for other users. The correlating output isPosixPermissions.asFileModesString().Any existing value already built will be entirely replaced with this new value.
- Parameters:
file- mode string- Returns:
- this for chaining
-
fromMaskString
Set the mode using a UNIX style mask octal string, for example '0644'. This should be in the same format as that output byPosixPermissions.asMaskString().Any existing value already built will be entirely replaced with this new value.
- Parameters:
maskString- octal mask string- Returns:
- this for chaining
-
fromNoPermissions
Removes all permission from the set to be built.- Returns:
- this for chaining
-
fromPermissions
Set the mode using an array ofPosixFilePermission.Any existing value already built will be entirely replaced with this new value.
- Parameters:
permissions- permissions- Returns:
- this for chaining
-
fromPermissions
public PosixPermissions.PosixPermissionsBuilder fromPermissions(Collection<PosixFilePermission> permissions) Set the mode using a collection ofPosixFilePermission.Any existing value already built will be entirely replaced with this new value.
- Parameters:
permissions- permissions- Returns:
- this for chaining
-
fromPosixPermissions
Set the mode using an existingPosixPermissions.Any existing value already built will be entirely replaced with this new value.
- Parameters:
permissions- permissions- Returns:
- this for chaining
-
fromUmaskString
Set the mode using a UNIX style umask, for example '0022' will result in 0022 ^ 0777. This should be in the same format as that output byPosixPermissions#asUmaskString().Any existing value already built will be entirely replaced with this new value.
- Parameters:
umask- octal umask string- Returns:
- this for chaining
-
withAllExecute
Adds execute permission to user, group and other.- Returns:
- this for chaining
-
withAllRead
Adds read permission to user, group and other.- Returns:
- this for chaining
-
withAllWrite
Adds write permission to user, group and other.- Returns:
- this for chaining
-
withBitmaskFlags
Adds a set of modes using bitmask flags via a rawintor a rawlong. Only the first 32 bits of the value will be used.- Parameters:
bitmask- mask of flags to add- Returns:
- this for chaining
-
withChmodArgumentString
Set the mode using a format compatible with the UNIX chmod command. It supports either settings, adding or removing permissions from either the user, group or other parts.For example,
u=rw,g=r,o=rwould set read-write on the user, and only read on group and other. Or,u+x,g=,o=would add execute permission for user, and clear group and other of all permissions.Note this does not replace all permissions in this builder unless the argment string provided specifies to do so, e.g.
u=,g=,o=oru-rwx,g-rwx,o-rwxwould remove all permissions.You can use an octal mask string with
chmodand so that is also possible here.- Parameters:
chmodArgument- permissions expressed in format used by chmod UNIX command- Returns:
- this for chaining
-
withoutBitmaskFlags
Remove a set of modes using bitmask flags via a rawintor a rawlong. Only the first 32 bits of the value will be used.- Parameters:
bitmask- mask of flags to remove- Returns:
- this for chaining
-
withoutExecutePermissions
Removes all execute permissions.- Returns:
- this for chaining
-
withoutGroupOtherPermissions
Removes all group and other permissions.- Returns:
- this for chaining
-
withoutOtherPermissions
Removes all other permissions.- Returns:
- this for chaining
-
withoutPermissions
public PosixPermissions.PosixPermissionsBuilder withoutPermissions(Collection<PosixFilePermission> permissions) Remove a collection ofPosixFilePermissionfrom the built set of permissions.- Parameters:
permissions- permissions to remove- Returns:
- this for chaining
-
withoutPermissions
public PosixPermissions.PosixPermissionsBuilder withoutPermissions(PosixFilePermission... permissions) Remove one or morePosixFilePermissionfrom the built set of permissions.- Parameters:
permissions- permissions to remove- Returns:
- this for chaining
-
withoutWritePermissions
Removes all write permissions.- Returns:
- this for chaining
-
withPermissions
public PosixPermissions.PosixPermissionsBuilder withPermissions(Collection<PosixFilePermission> permissions) Add a collection ofPosixFilePermissionto the built set of permissions.- Parameters:
permissions- permissions- Returns:
- this for chaining
-
withPermissions
Add one or morePosixFilePermissionto the built set of permissions.- Parameters:
permissions- permissions- Returns:
- this for chaining
-