FileSystemRights.java
package com.goldencode.p2j.concurrent;
import com.goldencode.p2j.security.*;
/**
* Implements the <code>FileSystemResource</code> rights objects.
*/
public class FileSystemRights
extends BitFlagsRights
{
/**
* Default constructor which creates an instance that always evaluates to no access.
*/
public FileSystemRights()
{
}
/**
* Protected constructor.
*
* @param perms
* Bitfield of perms (CDRWN).
*/
public FileSystemRights(BitSet perms)
{
super(perms);
}
/**
* Reports this class' rights name.
*
* @return The name of this rights class.
*/
public String getRightsName()
{
return "fileSystemRights";
}
/**
* Converts this object into a string.
*
* @return The string representation of this object.
*/
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("{");
if (perms.isSet(BIT_CREATE_ACCESS))
{
sb.append("C");
}
else
{
sb.append(".");
}
if (perms.isSet(BIT_DELETE_ACCESS))
{
sb.append("D");
}
else
{
sb.append(".");
}
if (perms.isSet(BIT_READ_ACCESS))
{
sb.append("R");
}
else
{
sb.append(".");
}
if (perms.isSet(BIT_WRITE_ACCESS))
{
sb.append("W");
}
else
{
sb.append(".");
}
if (perms.isSet(FileSystemResource.BIT_EXECUTE_ACCESS))
{
sb.append("X");
}
else
{
sb.append(".");
}
// render the reserved bits
sb.append("..");
if (perms.isSet(BIT_DENIED_ACCESS))
{
sb.append("N");
}
else
{
sb.append(".");
}
sb.append("}");
return new String(sb);
}
}