org.entityfs.entityattrs.unix
Class UnixEntityMode

java.lang.Object
  extended by org.entityfs.entityattrs.unix.UnixEntityMode

public class UnixEntityMode
extends Object

The Unix entity mode is three sets of UnixEntityAccessModeFlag:s used to determine what permissions an entity's owner, a subject in the same group as the entity's owner and everybody else have to the entity. It also contains a set of UnixEntityModeFlag determining extra attributes for the entity.

Note: In EntityFS 1.1, this class was refactored to be immutable. The current version of this object is not compatible with pre-1.1 versions.

Since:
1.0
Author:
Karl Gustafsson
See Also:
UnixEntityAccessModeFlag, UnixEntityModeFlag

Method Summary
 UnixEntityMode addGroupMode(UnixEntityAccessModeFlag f)
          Add a UnixEntityAccessModeFlag in effect for users that do not own the entity but are members of its owning group.
 UnixEntityMode addGroupModes(Set<UnixEntityAccessModeFlag> s)
          Add a set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity but are members of its owning group.
 UnixEntityMode addModeFlag(UnixEntityModeFlag f)
          Add a UnixEntityModeFlag.
 UnixEntityMode addModeFlags(Set<UnixEntityModeFlag> s)
          Add a set of UnixEntityModeFlag:s.
 UnixEntityMode addOtherMode(UnixEntityAccessModeFlag f)
          Add a UnixEntityAccessModeFlag in effect for users that do not own the entity and that are not members of its owning group.
 UnixEntityMode addOtherModes(Set<UnixEntityAccessModeFlag> s)
          Add a set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity and that are not members of its owning group.
 UnixEntityMode addUserMode(UnixEntityAccessModeFlag f)
          Add one UnixEntityAccessModeFlag in effect for the entity's owner.
 UnixEntityMode addUserModes(Set<UnixEntityAccessModeFlag> s)
          Add a set of UnixEntityAccessModeFlag:s in effect for the entity's owner, and return a new object.
 boolean equals(Object o)
           
static UnixEntityMode forCode(int code)
          Create an UnixEntityMode object from its numerical representation.
static UnixEntityMode forCode(short code)
          Create an UnixEntityMode object from its numerical representation.
 short getCode()
          Get the numerical representation of this entity mode object.
static UnixEntityMode getDefault()
          Get a UnixEntityMode that has the code 0644.
 Set<UnixEntityAccessModeFlag> getGroupModes()
          Get the set of UnixEntityAccessModeFlag:s in effect for users that don't own the entity but are members of its owning group.
 Set<UnixEntityModeFlag> getModeFlags()
          Get the set of UnixEntityModeFlag:s.
 Set<UnixEntityAccessModeFlag> getOtherModes()
          Get the set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity and that are not members of its owning group.
 Set<UnixEntityAccessModeFlag> getUserModes()
          Get the set of UnixEntityAccessModeFlag:s in effect for the entity's owner.
 int hashCode()
           
 UnixEntityMode removeGroupMode(UnixEntityAccessModeFlag f)
          Remove a UnixEntityAccessModeFlag in effect for users that do not own the entity but are members of its owning group.
 UnixEntityMode removeGroupModes(Set<UnixEntityAccessModeFlag> s)
          Remove a set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity but are members of its owning group.
 UnixEntityMode removeModeFlag(UnixEntityModeFlag f)
          Remove the UnixEntityModeFlag:s
 UnixEntityMode removeModeFlags(Set<UnixEntityModeFlag> s)
          Remove the set of UnixEntityModeFlag:s
 UnixEntityMode removeOtherMode(UnixEntityAccessModeFlag f)
          Remove a UnixEntityAccessModeFlag in effect for users that do not own the entity and that are not members of its owning group.
 UnixEntityMode removeOtherModes(Set<UnixEntityAccessModeFlag> s)
          Remove a set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity and that are not members of its owning group.
 UnixEntityMode removeUserMode(UnixEntityAccessModeFlag f)
          Remove a UnixEntityAccessModeFlag in effect for the entity's owner
 UnixEntityMode removeUserModes(Set<UnixEntityAccessModeFlag> s)
          Remove a set of UnixEntityAccessModeFlag:s in effect for the entity's owner.
 UnixEntityMode setGroupModes(Set<UnixEntityAccessModeFlag> s)
          Set the set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity but are members of its owning group.
 UnixEntityMode setModeFlags(Set<UnixEntityModeFlag> s)
          Set the set of UnixEntityModeFlag:s.
 UnixEntityMode setOtherModes(Set<UnixEntityAccessModeFlag> s)
          Set the set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity and that are not members of its owning group.
 UnixEntityMode setUserModes(Set<UnixEntityAccessModeFlag> s)
          Set the set of UnixEntityAccessModeFlag:s in effect for the entity's owner, and return a new object.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getDefault

public static UnixEntityMode getDefault()
Get a UnixEntityMode that has the code 0644.

Returns:
A UnixEntityMode object.

forCode

public static UnixEntityMode forCode(short code)
                              throws IllegalArgumentException
Create an UnixEntityMode object from its numerical representation. The code may for instance have the octal values 0644 or 01777.

Parameters:
code - The numerical representation of the entity mode.
Returns:
A UnixEntityMode object.
Throws:
IllegalArgumentException - If the supplied code is not valid.

forCode

public static UnixEntityMode forCode(int code)
                              throws IllegalArgumentException
Create an UnixEntityMode object from its numerical representation. The code may for instance have the octal values 0644 or 01777.

Parameters:
code - The numerical representation of the entity mode.
Returns:
A UnixEntityMode object.
Throws:
IllegalArgumentException - If the supplied code is not valid.

getCode

public short getCode()
Get the numerical representation of this entity mode object.

Returns:
The integer representation of the mode object, for instance 0644 or 0750.

getUserModes

public Set<UnixEntityAccessModeFlag> getUserModes()
Get the set of UnixEntityAccessModeFlag:s in effect for the entity's owner.

Returns:
The user mode flags.

setUserModes

public UnixEntityMode setUserModes(Set<UnixEntityAccessModeFlag> s)
Set the set of UnixEntityAccessModeFlag:s in effect for the entity's owner, and return a new object.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
s - A set of user mode flags.
Returns:
A new object containing the configured state.
See Also:
addUserMode(UnixEntityAccessModeFlag), addUserModes(Set), removeUserMode(UnixEntityAccessModeFlag), removeUserModes(Set)

addUserModes

public UnixEntityMode addUserModes(Set<UnixEntityAccessModeFlag> s)
Add a set of UnixEntityAccessModeFlag:s in effect for the entity's owner, and return a new object.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
s - A set of flags.
Returns:
A new object containing the configured state.
See Also:
setUserModes(Set), addUserMode(UnixEntityAccessModeFlag), removeUserMode(UnixEntityAccessModeFlag), removeUserModes(Set)

addUserMode

public UnixEntityMode addUserMode(UnixEntityAccessModeFlag f)
Add one UnixEntityAccessModeFlag in effect for the entity's owner.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
f - The flag.
Returns:
A new object containing the configured state.
See Also:
setUserModes(Set), addUserModes(Set), removeUserMode(UnixEntityAccessModeFlag), removeUserModes(Set)

removeUserModes

public UnixEntityMode removeUserModes(Set<UnixEntityAccessModeFlag> s)
Remove a set of UnixEntityAccessModeFlag:s in effect for the entity's owner.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
s - The set of flags to remove.
Returns:
A new object containing the configured state.
See Also:
setUserModes(Set), addUserMode(UnixEntityAccessModeFlag), addUserModes(Set), removeUserMode(UnixEntityAccessModeFlag)

removeUserMode

public UnixEntityMode removeUserMode(UnixEntityAccessModeFlag f)
Remove a UnixEntityAccessModeFlag in effect for the entity's owner

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
f - The flag to remove.
Returns:
A new object containing the configured state.
See Also:
setUserModes(Set), addUserMode(UnixEntityAccessModeFlag), addUserModes(Set), removeUserModes(Set)

getGroupModes

public Set<UnixEntityAccessModeFlag> getGroupModes()
Get the set of UnixEntityAccessModeFlag:s in effect for users that don't own the entity but are members of its owning group.

Returns:
The set of flags.

setGroupModes

public UnixEntityMode setGroupModes(Set<UnixEntityAccessModeFlag> s)
Set the set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity but are members of its owning group.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
s - The set of flags.
Returns:
A new object containing the configured state.
See Also:
addGroupMode(UnixEntityAccessModeFlag), addGroupModes(Set), removeGroupMode(UnixEntityAccessModeFlag), removeGroupModes(Set)

addGroupModes

public UnixEntityMode addGroupModes(Set<UnixEntityAccessModeFlag> s)
Add a set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity but are members of its owning group.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
s - The set of flags to add.
Returns:
A new object containing the configured state.
See Also:
setGroupModes(Set), addGroupModes(Set), removeGroupMode(UnixEntityAccessModeFlag), removeGroupModes(Set)

addGroupMode

public UnixEntityMode addGroupMode(UnixEntityAccessModeFlag f)
Add a UnixEntityAccessModeFlag in effect for users that do not own the entity but are members of its owning group.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
f - The flag.
Returns:
A new object containing the configured state.
See Also:
setGroupModes(Set), addGroupModes(Set), removeGroupMode(UnixEntityAccessModeFlag), removeGroupModes(Set)

removeGroupModes

public UnixEntityMode removeGroupModes(Set<UnixEntityAccessModeFlag> s)
Remove a set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity but are members of its owning group.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
s - The set of flags to remove.
Returns:
A new object containing the configured state.
See Also:
setGroupModes(Set), addGroupMode(UnixEntityAccessModeFlag), addGroupModes(Set), removeGroupMode(UnixEntityAccessModeFlag)

removeGroupMode

public UnixEntityMode removeGroupMode(UnixEntityAccessModeFlag f)
Remove a UnixEntityAccessModeFlag in effect for users that do not own the entity but are members of its owning group.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
f - The flag to remove.
Returns:
A new object containing the configured state.
See Also:
setGroupModes(Set), addGroupMode(UnixEntityAccessModeFlag), addGroupModes(Set), removeGroupModes(Set)

getOtherModes

public Set<UnixEntityAccessModeFlag> getOtherModes()
Get the set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity and that are not members of its owning group.

Returns:
The set of flags.

setOtherModes

public UnixEntityMode setOtherModes(Set<UnixEntityAccessModeFlag> s)
Set the set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity and that are not members of its owning group.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
s - The set of flags to set.
Returns:
A new object containing the configured state.
See Also:
addOtherMode(UnixEntityAccessModeFlag), addOtherModes(Set), removeOtherMode(UnixEntityAccessModeFlag), removeOtherModes(Set)

addOtherModes

public UnixEntityMode addOtherModes(Set<UnixEntityAccessModeFlag> s)
Add a set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity and that are not members of its owning group.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
s - The set of flags to add.
Returns:
A new object containing the configured state.
See Also:
setOtherModes(Set), addOtherMode(UnixEntityAccessModeFlag), removeOtherMode(UnixEntityAccessModeFlag), removeOtherModes(Set)

addOtherMode

public UnixEntityMode addOtherMode(UnixEntityAccessModeFlag f)
Add a UnixEntityAccessModeFlag in effect for users that do not own the entity and that are not members of its owning group.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
f - The flag to add.
Returns:
A new object containing the configured state.
See Also:
setOtherModes(Set), addOtherModes(Set), removeOtherMode(UnixEntityAccessModeFlag), removeOtherModes(Set)

removeOtherModes

public UnixEntityMode removeOtherModes(Set<UnixEntityAccessModeFlag> s)
Remove a set of UnixEntityAccessModeFlag:s in effect for users that do not own the entity and that are not members of its owning group.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
s - The set of flags to remove.
Returns:
A new object containing the configured state.
See Also:
setOtherModes(Set), addOtherMode(UnixEntityAccessModeFlag), addOtherModes(Set), removeOtherMode(UnixEntityAccessModeFlag)

removeOtherMode

public UnixEntityMode removeOtherMode(UnixEntityAccessModeFlag f)
Remove a UnixEntityAccessModeFlag in effect for users that do not own the entity and that are not members of its owning group.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
f - The flag to remove.
Returns:
A new object containing the configured state.
See Also:
setOtherModes(Set), addOtherMode(UnixEntityAccessModeFlag), addOtherModes(Set), removeOtherModes(Set)

getModeFlags

public Set<UnixEntityModeFlag> getModeFlags()
Get the set of UnixEntityModeFlag:s.

Returns:
The set of UnixEntityModeFlag:s.

setModeFlags

public UnixEntityMode setModeFlags(Set<UnixEntityModeFlag> s)
                            throws IllegalArgumentException
Set the set of UnixEntityModeFlag:s.

All combinations of mode flags are not valid. UnixEntityModeFlag.MANDATORY_LOCKING cannot be set on an entity that is group executable, and UnixEntityModeFlag.SET_GROUP_ID cannot be set on an entity that is not group executable.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
s - The flags to set.
Returns:
A new object containing the configured state.
Throws:
IllegalArgumentException - If the set of flags is invalid.
See Also:
addModeFlag(UnixEntityModeFlag), addModeFlags(Set), removeModeFlag(UnixEntityModeFlag), removeModeFlags(Set)

addModeFlags

public UnixEntityMode addModeFlags(Set<UnixEntityModeFlag> s)
                            throws IllegalArgumentException
Add a set of UnixEntityModeFlag:s.

All combinations of mode flags are not valid. UnixEntityModeFlag.MANDATORY_LOCKING cannot be set on an entity that is group executable, and UnixEntityModeFlag.SET_GROUP_ID cannot be set on an entity that is not group executable.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
s - The set of UnixEntityModeFlag:s to add.
Returns:
A new object containing the configured state.
Throws:
IllegalArgumentException - If the set of flags is invalid.
See Also:
setModeFlags(Set), addModeFlag(UnixEntityModeFlag), removeModeFlag(UnixEntityModeFlag), removeModeFlags(Set)

addModeFlag

public UnixEntityMode addModeFlag(UnixEntityModeFlag f)
                           throws IllegalArgumentException
Add a UnixEntityModeFlag.

All combinations of mode flags are not valid. UnixEntityModeFlag.MANDATORY_LOCKING cannot be set on an entity that is group executable, and UnixEntityModeFlag.SET_GROUP_ID cannot be set on an entity that is not group executable.

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
f - The UnixEntityModeFlag to add.
Returns:
A new object containing the configured state.
Throws:
IllegalArgumentException - If the specific mode flag cannot be set for this object.
See Also:
setModeFlags(Set), addModeFlags(Set), removeModeFlag(UnixEntityModeFlag), removeModeFlags(Set)

removeModeFlags

public UnixEntityMode removeModeFlags(Set<UnixEntityModeFlag> s)
Remove the set of UnixEntityModeFlag:s

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
s - The set of UnixEntityModeFlag:s to remove.
Returns:
A new object containing the configured state.
See Also:
setModeFlags(Set), addModeFlag(UnixEntityModeFlag), addModeFlags(Set), removeModeFlag(UnixEntityModeFlag)

removeModeFlag

public UnixEntityMode removeModeFlag(UnixEntityModeFlag f)
Remove the UnixEntityModeFlag:s

Note: The state of the object that this method is called on is not changed. It is immutable.

Parameters:
f - The UnixEntityModeFlag to remove.
Returns:
A new object containing the configured state.
See Also:
setModeFlags(Set), addModeFlag(UnixEntityModeFlag), addModeFlags(Set), removeModeFlags(Set)

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object