net.charlesames.utility.io
Class PrivilegedFilePropertyGetter

java.lang.Object
  extended by net.charlesames.utility.io.PrivilegedFilePropertyGetter
All Implemented Interfaces:
java.security.PrivilegedAction<java.lang.Boolean>

public class PrivilegedFilePropertyGetter
extends java.lang.Object
implements java.security.PrivilegedAction<java.lang.Boolean>

Reads a text string from a file in a privileged context.

Author:
Charles Ames

Method Summary
 boolean canExecute(java.io.File file)
          Test whether the indicated file is an executable.
 boolean canRead(java.io.File file)
          Test whether the indicated file is readable.
 boolean canWrite(java.io.File file)
          Test whether the indicated file is writable.
 boolean exists(java.io.File file)
          Test if the indicated file exists;
 long getFreeSpace(java.io.File file)
          Get the number of free bytes in the partition named by the indicated file.
 long getLastModified(java.io.File file)
          Get the indicated file's last-modified time.
 long getLength(java.io.File file)
          Get the length of the indicated file.
 java.io.File getParentFile(java.io.File file)
          Get the indicated file's parent directory.
static PrivilegedFilePropertyGetter getSingleton()
          Get the singleton instance of PrivilegedFilePropertyGetter.
 long getTotalSpace(java.io.File file)
          Get the total bytes in the partition named by the indicated file.
 long getUsableSpace(java.io.File file)
          Get the number of usable bytes in the partition named by the indicated file.
 boolean isAbsolute(java.io.File file)
          Test whether the indicated file is absolute.
 boolean isDirectory(java.io.File file)
          Test whether the indicated file is a directory.
 boolean isFile(java.io.File file)
          Test whether the indicated file is a file.
 boolean isHidden(java.io.File file)
          Test whether the indicated file is hidden.
 java.lang.Boolean run()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSingleton

public static PrivilegedFilePropertyGetter getSingleton()
Get the singleton instance of PrivilegedFilePropertyGetter.

Returns:
The singleton instance of PrivilegedFilePropertyGetter.

exists

public boolean exists(java.io.File file)
Test if the indicated file exists;

Parameters:
file - The indicated file.
Returns:
True if file exists; false otherwise;

getLastModified

public long getLastModified(java.io.File file)
Get the indicated file's last-modified time.

Parameters:
file - The indicated file.
Returns:
Number of milliseconds since 00:00:00 GMT on 1/1/1970 if file exists; 0L otherwise;

getLength

public long getLength(java.io.File file)
Get the length of the indicated file.

Parameters:
file - The indicated file.
Returns:
File length if file exists; 0 otherwise;

getFreeSpace

public long getFreeSpace(java.io.File file)
Get the number of free bytes in the partition named by the indicated file.

Parameters:
file - The indicated file.
Returns:
Number of free bytes in the partition named by the indicated file; 0L if file does not exist.

getTotalSpace

public long getTotalSpace(java.io.File file)
Get the total bytes in the partition named by the indicated file.

Parameters:
file - The indicated file.
Returns:
Total bytes in the partition named by the indicated file; 0L if file does not exist.

getUsableSpace

public long getUsableSpace(java.io.File file)
Get the number of usable bytes in the partition named by the indicated file.

Parameters:
file - The indicated file.
Returns:
Number of usable bytes in the partition named by the indicated file; 0L if file does not exist.

isDirectory

public boolean isDirectory(java.io.File file)
Test whether the indicated file is a directory.

Parameters:
file - The indicated file.
Returns:
True if the indicated file is a directory; false if file does not exist.

isAbsolute

public boolean isAbsolute(java.io.File file)
Test whether the indicated file is absolute.

Parameters:
file - The indicated file.
Returns:
True if the indicated file is absolute; false if file does not exist.

isFile

public boolean isFile(java.io.File file)
Test whether the indicated file is a file.

Parameters:
file - The indicated file.
Returns:
True if the indicated file is a file; false if file does not exist.

isHidden

public boolean isHidden(java.io.File file)
Test whether the indicated file is hidden.

Parameters:
file - The indicated file.
Returns:
True if the indicated file is hidden; false if file does not exist.

canExecute

public boolean canExecute(java.io.File file)
Test whether the indicated file is an executable.

Parameters:
file - The indicated file.
Returns:
True if the indicated file is an executable; false if file does not exist.

canRead

public boolean canRead(java.io.File file)
Test whether the indicated file is readable.

Parameters:
file - The indicated file.
Returns:
True if the indicated file is readable; false if file does not exist.

canWrite

public boolean canWrite(java.io.File file)
Test whether the indicated file is writable.

Parameters:
file - The indicated file.
Returns:
True if the indicated file is writable; false if file does not exist.

getParentFile

public java.io.File getParentFile(java.io.File file)
Get the indicated file's parent directory.

Parameters:
file - The indicated file.
Returns:
The indicated file's parent directory.

run

public java.lang.Boolean run()
Specified by:
run in interface java.security.PrivilegedAction<java.lang.Boolean>