public class FileAccessPermissions extends Object implements Cloneable
| Modifier and Type | Field and Description |
|---|---|
private static int |
MASK_ALL |
private static int |
MASK_ALL_EXECUTABLE |
private static int |
MASK_ALL_READABLE |
private static int |
MASK_ALL_WRITABLE |
static int |
MASK_EXECUTABLE |
private static int |
MASK_FULL_DIRECTORY_ACCESS |
private static int |
MASK_FULL_FILE_ACCESS |
private static int |
MASK_GROUP |
private static int |
MASK_GROUP_FLAGS |
private static int |
MASK_MAX |
private static int |
MASK_OTHERS |
private static int |
MASK_OTHERS_FLAGS |
static int |
MASK_READABLE |
static int |
MASK_SETGID |
static int |
MASK_SETUID |
static int |
MASK_STICKY |
private static int |
MASK_USER |
private static int |
MASK_USER_FLAGS |
static int |
MASK_WRITABLE |
private int |
maskBits |
| Constructor and Description |
|---|
FileAccessPermissions()
The constructor.
|
FileAccessPermissions(int mask)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
chmod(String chmod)
This method allows to change the
modifiers by a string expression. |
FileAccessPermissions |
clone() |
static FileAccessPermissions |
createByUmask(int umask,
boolean isDirectory)
This method create a new
FileAccessPermissions instance according to the given
umask (user file creation mode mask). |
boolean |
equals(Object obj) |
int |
getMaskBits()
This method gets the
FileAccessPermissions encoded as a single integer value. |
private boolean |
hasBits(int bitMask)
This method determines if the flags given by
bitMask are set in this mask. |
private boolean |
hasFlag(FileAccessClass fileModeClass,
int bitMask)
This method determines if the flag(s) given by
bitMask is set in this mask for the
given fileModeClass. |
int |
hashCode() |
boolean |
isExecutable(FileAccessClass fileModeClass)
This method determines if this
mask is executable for the given fileModeClass. |
boolean |
isReadable(FileAccessClass fileModeClass)
This method determines if this
mask is readable for the given fileModeClass. |
boolean |
isSetgid()
This method determines the value of the setgid flag ("set group ID").
|
boolean |
isSetuid()
This method determines the value of the setuid flag ("set user ID").
|
boolean |
isSticky()
This method determines the value of the sticky flag.
|
boolean |
isWritable(FileAccessClass fileModeClass)
This method determines if this
mask is writable for the given fileModeClass. |
private static int |
parseOctalMode(CharSequenceScanner parse)
This method parses the current state of the
chmod argument given by parse in octal
mode. |
private static int |
parseSymbolicMode(CharSequenceScanner parse,
int maskBits)
This method parses a symbolic-mode segment from
parse. |
private static int |
parseUGO(CharSequenceScanner parse)
This method parses the
ugoa prefix indicating which flags to modify. |
private void |
setBits(int bitMask,
boolean set)
|
void |
setExecutable(boolean executable)
This method sets the
executable flag of this this mask for ALL access-classes to the given value ( executable). |
void |
setExecutable(FileAccessClass fileModeClass,
boolean executable)
This method sets the
executable flag of this this mask for the given fileModeClass to the given value ( executable). |
private void |
setFlag(FileAccessClass fileModeClass,
int bitMask,
boolean flag)
This method sets the flag(s) given by
bitMask of this this mask for the given
fileModeClass to the given value (flag). |
void |
setMaskBits(int mask)
This method sets the bitwise encoded
mask. |
void |
setReadable(boolean readable)
This method sets the
readable flag of this this mask
for ALL access-classes to the given value ( readable). |
void |
setReadable(FileAccessClass fileModeClass,
boolean readable)
This method sets the
readable flag of this this mask
for the given fileModeClass to the given value ( readable). |
void |
setSetgid(boolean setgid)
This method sets the
setuid flag to the given value setuid. |
void |
setSetuid(boolean setuid)
This method sets the
setuid flag to the given value setuid. |
void |
setSticky(boolean sticky)
This method sets the
sticky flag to the given value sticky. |
void |
setWritable(boolean writable)
This method sets the
writable flag of this this mask
for ALL access-classes to the given value ( writable). |
void |
setWritable(FileAccessClass fileModeClass,
boolean writable)
This method sets the
writable flag of this this mask
for the given fileModeClass to the given value ( writable). |
private int |
shiftMask(FileAccessClass fileModeClass,
int bitMask)
This method shifts the given
bitMask according to the given fileModeClass. |
String |
toString() |
private static final int MASK_MAX
private static final int MASK_USER
private static final int MASK_GROUP
private static final int MASK_OTHERS
private static final int MASK_ALL
public static final int MASK_READABLE
isReadable(FileAccessClass),
Constant Field Valuespublic static final int MASK_WRITABLE
isWritable(FileAccessClass),
Constant Field Valuespublic static final int MASK_EXECUTABLE
public static final int MASK_SETUID
isSetuid(),
Constant Field Valuespublic static final int MASK_SETGID
isSetgid(),
Constant Field Valuespublic static final int MASK_STICKY
isSticky(),
Constant Field Valuesprivate static final int MASK_USER_FLAGS
private static final int MASK_GROUP_FLAGS
private static final int MASK_OTHERS_FLAGS
private static final int MASK_FULL_FILE_ACCESS
createByUmask(int, boolean),
Constant Field Valuesprivate static final int MASK_FULL_DIRECTORY_ACCESS
createByUmask(int, boolean),
Constant Field Valuesprivate static final int MASK_ALL_EXECUTABLE
private static final int MASK_ALL_WRITABLE
private static final int MASK_ALL_READABLE
private int maskBits
public FileAccessPermissions()
public FileAccessPermissions(int mask)
mask - is the mask.public static FileAccessPermissions createByUmask(int umask, boolean isDirectory)
FileAccessPermissions instance according to the given
umask (user file creation mode mask).umask - is the umask.isDirectory - true if the the FileAccessPermissions is to be created for a directory,
false for a regular file.FileAccessPermissions.public int getMaskBits()
FileAccessPermissions encoded as a single integer value. The value is in the same
format as the octal notation for the command chmod. Only the last 12 bits of the mask can be set.public void setMaskBits(int mask)
throws IllegalArgumentException
mask.mask - the mask to set.IllegalArgumentException - if the given mask is negative or greater than 07777 (==
0xFFF == 4095).public boolean isReadable(FileAccessClass fileModeClass)
mask is readable for the given fileModeClass.fileModeClass - is the class of access ( FileAccessClass.USER, FileAccessClass.GROUP, or
FileAccessClass.OTHERS).true if the mask is readable for the given fileModeClass, false otherwise.public void setReadable(boolean readable)
readable flag of this this mask
for ALL access-classes to the given value ( readable).readable - if true the mask will be readable, if false it will NOT be readable.public void setReadable(FileAccessClass fileModeClass, boolean readable)
readable flag of this this mask
for the given fileModeClass to the given value ( readable).fileModeClass - is the class of access ( FileAccessClass.USER, FileAccessClass.GROUP, or
FileAccessClass.OTHERS).readable - if true the mask will be readable for the given fileModeClass, if false it
will NOT be readable.public boolean isWritable(FileAccessClass fileModeClass)
mask is writable for the given fileModeClass.fileModeClass - is the class of access ( FileAccessClass.USER, FileAccessClass.GROUP, or
FileAccessClass.OTHERS).true if the mask is writable for the given fileModeClass, false otherwise.public void setWritable(boolean writable)
writable flag of this this mask
for ALL access-classes to the given value ( writable).writable - if true the mask will be writable, if false it will NOT be writable.public void setWritable(FileAccessClass fileModeClass, boolean writable)
writable flag of this this mask
for the given fileModeClass to the given value ( writable).fileModeClass - is the class of access ( FileAccessClass.USER, FileAccessClass.GROUP, or
FileAccessClass.OTHERS).writable - if true the mask will be writable for the given fileModeClass, if false it
will NOT be writable.public boolean isExecutable(FileAccessClass fileModeClass)
mask is executable for the given fileModeClass.fileModeClass - is the class of access ( FileAccessClass.USER, FileAccessClass.GROUP, or
FileAccessClass.OTHERS).true if the mask is executable for the given fileModeClass, false otherwise.public void setExecutable(boolean executable)
executable flag of this this mask for ALL access-classes to the given value ( executable).executable - if true the mask will be executable, if false it will NOT be executable.public void setExecutable(FileAccessClass fileModeClass, boolean executable)
executable flag of this this mask for the given fileModeClass to the given value ( executable).fileModeClass - is the class of access ( FileAccessClass.USER, FileAccessClass.GROUP, or
FileAccessClass.OTHERS).executable - if true the mask will be executable for the given fileModeClass, if false
it will NOT be executable.public boolean isSetuid()
owner
instead of the user that performed the execution.true if the flag is set, false otherwise.public void setSetuid(boolean setuid)
setuid flag to the given value setuid.setuid - - if true the flag will be set, if false it will be unset.public boolean isSetgid()
group owning the file
instead of the group of the user that performed the execution.true if the flag is set, false otherwise.public void setSetgid(boolean setgid)
setuid flag to the given value setuid.setgid - - if true the flag will be set, if false it will be unset.public boolean isSticky()
true if the flag is set, false otherwise.public void setSticky(boolean sticky)
sticky flag to the given value sticky.sticky - - if true the flag will be set, if false it will be unset.private int shiftMask(FileAccessClass fileModeClass, int bitMask)
bitMask according to the given fileModeClass.fileModeClass - is the class of access ( FileAccessClass.USER, FileAccessClass.GROUP, or
FileAccessClass.OTHERS).bitMask - is the bit-mask to shift.bitMask.private void setFlag(FileAccessClass fileModeClass, int bitMask, boolean flag)
bitMask of this this mask for the given
fileModeClass to the given value (flag).fileModeClass - is the class of access ( FileAccessClass.USER, FileAccessClass.GROUP, or
FileAccessClass.OTHERS).bitMask - is the bit-mask of the flag(s) to set.flag - - if true the flag will be set, if false it will be unset.private boolean hasFlag(FileAccessClass fileModeClass, int bitMask)
bitMask is set in this mask for the
given fileModeClass.fileModeClass - is the class of access ( FileAccessClass.USER, FileAccessClass.GROUP, or
FileAccessClass.OTHERS).bitMask - is the bit-mask of the flag(s) to get.true if the flag is set, false otherwise.private boolean hasBits(int bitMask)
bitMask are set in this mask.bitMask - is the bit-mask of the flag(s) to check.true if the flags are set, false otherwise.private void setBits(int bitMask,
boolean set)
bitMask - is the bit-mask of the flag(s) to set or unset.set - - if true the flag(s) will be set, if false they will be unset.private static int parseUGO(CharSequenceScanner parse)
ugoa prefix indicating which flags to modify.
parse - is the current state of the parser.private static int parseSymbolicMode(CharSequenceScanner parse, int maskBits)
parse. It applies the chmod of that
segment to the given mask and returns the result. The state of this object remains unchanged.parse - is the current state of the parser.maskBits - is the current modifier mask.mask.private static int parseOctalMode(CharSequenceScanner parse) throws IllegalArgumentException
chmod argument given by parse in octal
mode. If no digits are detected, parse remains unchanged and -1 is returned, else all digits are
consumed and the parsed octal-mode is returned.parse - is the current parser state of the the chmod argument.-1 if parse does NOT point to a digit.IllegalArgumentException - if there are more the 4 digits or non-octal digits (8 or 9).public void chmod(String chmod)
modifiers by a string expression. It behaves like the GNU
command chmod (change modifiers). chmod - is the mode-list argument as supplied to the chmod command. It can either be a single
octal-mode (up to 4 digits of octal number) or a comma-separated list of symbolic-modes (
[ugoa]*([-+=]([rwxXst]*|[ugo]))+).public FileAccessPermissions clone()
Copyright © 2001–2016 mmm-Team. All rights reserved.