com.mucommander.file
Class SimpleFilePermissions

java.lang.Object
  extended by com.mucommander.file.GroupedPermissionBits
      extended by com.mucommander.file.SimpleFilePermissions
All Implemented Interfaces:
FilePermissions, PermissionBits

public class SimpleFilePermissions
extends GroupedPermissionBits
implements FilePermissions

SimpleFilePermissions is a FilePermissions implementation that takes int values for the permission values and mask. Additionally, this class defines padPermission static methods that allows to pad unsupported permission bits with default values.

Author:
Maxence Bernard

Field Summary
protected  PermissionBits mask
          The permissions mask
 
Fields inherited from class com.mucommander.file.GroupedPermissionBits
permissions
 
Fields inherited from interface com.mucommander.file.FilePermissions
DEFAULT_DIRECTORY_PERMISSIONS, DEFAULT_FILE_PERMISSIONS, EMPTY_FILE_PERMISSIONS
 
Fields inherited from interface com.mucommander.file.PermissionBits
EMPTY_PERMISSION_BITS, EMPTY_PERMISSION_INT, FULL_PERMISSION_BITS, FULL_PERMISSION_INT
 
Constructor Summary
SimpleFilePermissions(int permissions)
          Creates a new SimpleFilePermissions using the specified UNIX-style permission int for permission values and full permissions mask.
SimpleFilePermissions(int permissions, int mask)
          Creates a new SimpleFilePermissions using the specified UNIX-style permission int values for permission values and mask.
SimpleFilePermissions(int permissions, PermissionBits mask)
          Creates a new SimpleFilePermissions using the specified UNIX-style permission int and permission mask.
 
Method Summary
 PermissionBits getMask()
          Returns the mask that indicates which permission bits are significant and should be taken into account.
static FilePermissions padPermissions(FilePermissions permissions, FilePermissions defaultPermissions)
          Pads the given permissions with the specified ones: the permission bits that are not supported (as reported by the supplied permissions mask} are replaced by those of the default permissions.
static int padPermissions(int permissions, int supportedPermissionsMask, int defaultPermissions)
          Pads the given permissions with the specified ones: the permission bits that are not supported (as reported by the supplied permissions mask} are replaced by those of the default permissions.
 
Methods inherited from class com.mucommander.file.GroupedPermissionBits
getBitValue, getIntValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.mucommander.file.PermissionBits
getBitValue, getIntValue
 

Field Detail

mask

protected PermissionBits mask
The permissions mask

Constructor Detail

SimpleFilePermissions

public SimpleFilePermissions(int permissions)
Creates a new SimpleFilePermissions using the specified UNIX-style permission int for permission values and full permissions mask.

Parameters:
permissions - a UNIX-style permission int that holds permission values.

SimpleFilePermissions

public SimpleFilePermissions(int permissions,
                             int mask)
Creates a new SimpleFilePermissions using the specified UNIX-style permission int values for permission values and mask.

Parameters:
permissions - a UNIX-style permission int that holds permission values.
mask - a UNIX-style permission int which defines which permission bits are supported.

SimpleFilePermissions

public SimpleFilePermissions(int permissions,
                             PermissionBits mask)
Creates a new SimpleFilePermissions using the specified UNIX-style permission int and permission mask.

Parameters:
permissions - a UNIX-style permission int that holds permission values.
mask - a permission mask which defines which permission bits are supported.
Method Detail

padPermissions

public static FilePermissions padPermissions(FilePermissions permissions,
                                             FilePermissions defaultPermissions)
Pads the given permissions with the specified ones: the permission bits that are not supported (as reported by the supplied permissions mask} are replaced by those of the default permissions. That means:
- if the mask indicates that all permission bits are supported (mask = 777 octal), the supplied permissions will simply be returned, without using any of the default permissions
- if the mask indicates that none of the permission bits are supported (mask = 0), the default permissions will be returned, without using any of the supplied permissions

Parameters:
permissions - the permissions to pad with default permissions for the bits that are not supported
defaultPermissions - permissions to use for the bits that are not supported
Returns:
the permissions padded with the default permissions

padPermissions

public static int padPermissions(int permissions,
                                 int supportedPermissionsMask,
                                 int defaultPermissions)
Pads the given permissions with the specified ones: the permission bits that are not supported (as reported by the supplied permissions mask} are replaced by those of the default permissions. That means:
- if the mask indicates that all permission bits are supported (mask = 777 octal), the supplied permissions will simply be returned, without using any of the default permissions
- if the mask indicates that none of the permission bits are supported (mask = 0), the default permissions will be returned, without using any of the supplied permissions

Parameters:
permissions - the permissions to pad with default permissions for the bits that are not supported
supportedPermissionsMask - the bit mask that indicates which bits of the given permissions are supported
defaultPermissions - permissions to use for the bits that are not supported
Returns:
the given permissions padded with the default permissions

getMask

public PermissionBits getMask()
Description copied from interface: FilePermissions
Returns the mask that indicates which permission bits are significant and should be taken into account. Permission bits that are unsupported have no meaning and their value should simply be ignored.

Specified by:
getMask in interface FilePermissions
Returns:
the mask that indicates which permission bits are significant and should be taken into account.


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard