Class PosixPermissions

  • Direct Known Subclasses:
    UserIsOwnerPosixPermissions

    public class PosixPermissions
    extends java.lang.Object
    UNIX permissions.
    Since:
    2.1
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  PosixPermissions.Type
      Permission types.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean isInGroup
      If one user group is the group of the file.
      private boolean isOwner
      If the user is the owner of the file.
      private int permissions
      Current permissions.
    • Constructor Summary

      Constructors 
      Constructor Description
      PosixPermissions​(int permissions, boolean isOwner, boolean isInGroup)
      Creates a new PosixPermissions object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private int computeNewPermissions​(java.util.Map<PosixPermissions.Type,​java.lang.Boolean> values)
      Computes new permission from old ones.
      private boolean get​(PosixPermissions.Type type)
      Tests whether the bit corresponding to the permission is set.
      int getPermissions()
      Gets permissions.
      boolean isExecutable()
      Gets whether the permissions are executable.
      boolean isReadable()
      Gets whether the permissions are readable.
      boolean isWritable()
      Gets whether the permissions are writable.
      int makeExecutable​(boolean executable, boolean ownerOnly)
      Creates new permissions based on these permissions.
      java.lang.Integer makeReadable​(boolean readable, boolean ownerOnly)
      Creates new permissions based on these permissions.
      java.lang.Integer makeWritable​(boolean writable, boolean ownerOnly)
      Creates new permissions based on these permissions.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • permissions

        private final int permissions
        Current permissions.
      • isOwner

        private final boolean isOwner
        If the user is the owner of the file.
      • isInGroup

        private final boolean isInGroup
        If one user group is the group of the file.
    • Constructor Detail

      • PosixPermissions

        public PosixPermissions​(int permissions,
                                boolean isOwner,
                                boolean isInGroup)
        Creates a new PosixPermissions object.
        Parameters:
        permissions - The permissions
        isOwner - true if the user is the owner of the file
        isInGroup - true if the user is a group owner of the file
    • Method Detail

      • computeNewPermissions

        private int computeNewPermissions​(java.util.Map<PosixPermissions.Type,​java.lang.Boolean> values)
        Computes new permission from old ones.
        Parameters:
        values - The permissions to set.
        Returns:
        The new permissions.
      • get

        private boolean get​(PosixPermissions.Type type)
        Tests whether the bit corresponding to the permission is set.
        Returns:
        whether the bit corresponding to the permission is set.
      • getPermissions

        public int getPermissions()
        Gets permissions.
        Returns:
        permissions.
      • isExecutable

        public boolean isExecutable()
        Gets whether the permissions are executable.
        Returns:
        whether the permissions are executable.
      • isReadable

        public boolean isReadable()
        Gets whether the permissions are readable.
        Returns:
        whether the permissions are readable.
      • isWritable

        public boolean isWritable()
        Gets whether the permissions are writable.
        Returns:
        whether the permissions are writable.
      • makeExecutable

        public int makeExecutable​(boolean executable,
                                  boolean ownerOnly)
        Creates new permissions based on these permissions.
        Parameters:
        executable - Whether the new permissions should be readable.
        ownerOnly - Whether the new permissions are only for the owner.
        Returns:
        the new permissions.
      • makeReadable

        public java.lang.Integer makeReadable​(boolean readable,
                                              boolean ownerOnly)
        Creates new permissions based on these permissions.
        Parameters:
        readable - Whether the new permissions should be readable.
        ownerOnly - Whether the new permissions are only for the owner.
        Returns:
        the new permissions.
      • makeWritable

        public java.lang.Integer makeWritable​(boolean writable,
                                              boolean ownerOnly)
        Creates new permissions based on these permissions.
        Parameters:
        writable - Whether the new permissions should be readable.
        ownerOnly - Whether the new permissions are only for the owner.
        Returns:
        the new permissions.