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 final int
    Execute permissions = 1.
    private final int
     
    static final int
    No permissions = 0;
    private final int
     
    static final int
    Read permissions = 4.
    private final int
     
    static final FilePermission
    Predefined set of permission giving the owner READ+WRITE permission and no permissions to other users.
    static final FilePermission
    Predefined set of permission giving the owner READ+WRITE permission and READ permissions to other users.
    static final FilePermission
    Predefined set of permission giving the owner READ+WRITE permission, the group READ permission and no permissions to other users.
    static final FilePermission
    Predefined set of permission giving the owner READ+WRITE+EXECUTE permission and no permissions to other users.
    static final int
    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
    Get the octal permission representation to set in 'chmod' command.
    boolean
     
    int
    Get the group permission.
    int
    Get the permission for other users.
    int
    Get the combined permissions.
    int
    Get the user (owner) permission.
    int
     
    Get the octal permission representation to set in 'umask' command.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NONE

      public static final int NONE
      No permissions = 0;
      See Also:
    • READ

      public static final int READ
      Read permissions = 4.
      See Also:
    • WRITE

      public static final int WRITE
      Write permissions = 2.
      See Also:
    • EXECUTE

      public static final int EXECUTE
      Execute permissions = 1.
      See Also:
    • USER_RW

      public static final FilePermission USER_RW
      Predefined set of permission giving the owner READ+WRITE permission and no permissions to other users.
    • USER_RWX

      public static final FilePermission USER_RWX
      Predefined set of permission giving the owner READ+WRITE+EXECUTE permission and no permissions to other users.
    • USER_RW_GROUP_R

      public static final 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.
    • USER_RW_ALL_R

      public static final FilePermission 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

      public String chmod()
      Get the octal permission representation to set in 'chmod' command.
      Since:
      1.1
    • umask

      public String umask()
      Get the octal permission representation to set in 'umask' command.
      Since:
      1.1
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object