Class FilePermission
java.lang.Object
net.sf.basedb.opengrid.filetransfer.FilePermission
public class FilePermission extends Object
Represents the permission code for a file on a UNIX file system.
This class define numeric constanst for READ, WRITE and EXECUTE
permissions which can be OR-ed to make up a final permission.
We also define some common presets for user, group and other users.
- Since:
- 1.0
- Author:
- nicklas
-
Field Summary
Fields Modifier and Type Field Description static int
EXECUTE
Execute permissions = 1.private int
group
static int
NONE
No permissions = 0;private int
other
static int
READ
Read permissions = 4.private int
user
static FilePermission
USER_RW
Predefined set of permission giving the owner READ+WRITE permission and no permissions to other users.static FilePermission
USER_RW_ALL_R
Predefined set of permission giving the owner READ+WRITE permission and READ permissions to other users.static FilePermission
USER_RW_GROUP_R
Predefined set of permission giving the owner READ+WRITE permission, the group READ permission and no permissions to other users.static FilePermission
USER_RWX
Predefined set of permission giving the owner READ+WRITE+EXECUTE permission and no permissions to other users.static int
WRITE
Write permissions = 2. -
Constructor Summary
Constructors Constructor Description FilePermission(int user, int group, int other)
Create a new set of permissions for the owner, group and all other users. -
Method Summary
Modifier and Type Method Description String
chmod()
Get the octal permission representation to set in 'chmod' command.boolean
equals(Object obj)
int
getGroupPermission()
Get the group permission.int
getOtherPermission()
Get the permission for other users.int
getPermissions()
Get the combined permissions.int
getUserPermission()
Get the user (owner) permission.int
hashCode()
String
umask()
Get the octal permission representation to set in 'umask' command.
-
Field Details
-
NONE
public static final int NONENo permissions = 0;- See Also:
- Constant Field Values
-
READ
public static final int READRead permissions = 4.- See Also:
- Constant Field Values
-
WRITE
public static final int WRITEWrite permissions = 2.- See Also:
- Constant Field Values
-
EXECUTE
public static final int EXECUTEExecute permissions = 1.- See Also:
- Constant Field Values
-
USER_RW
Predefined set of permission giving the owner READ+WRITE permission and no permissions to other users. -
USER_RWX
Predefined set of permission giving the owner READ+WRITE+EXECUTE permission and no permissions to other users. -
USER_RW_GROUP_R
Predefined set of permission giving the owner READ+WRITE permission, the group READ permission and no permissions to other users. -
USER_RW_ALL_R
Predefined set of permission giving the owner READ+WRITE permission and READ permissions to other users. -
user
private final int user -
group
private final int group -
other
private final int other
-
-
Constructor Details
-
FilePermission
public FilePermission(int user, int group, int other)Create a new set of permissions for the owner, group and all other users. The permission codes are integer values between 0 and 7. Use the other constants defined in this file.
-
-
Method Details
-
getUserPermission
public int getUserPermission()Get the user (owner) permission. -
getGroupPermission
public int getGroupPermission()Get the group permission. -
getOtherPermission
public int getOtherPermission()Get the permission for other users. -
getPermissions
public int getPermissions()Get the combined permissions. -
chmod
Get the octal permission representation to set in 'chmod' command.- Since:
- 1.1
-
umask
Get the octal permission representation to set in 'umask' command.- Since:
- 1.1
-
equals
-
hashCode
public int hashCode()
-