org.ourgrid.common.util
Class JavaFileUtil

java.lang.Object
  extended by org.ourgrid.common.util.JavaFileUtil

public class JavaFileUtil
extends java.lang.Object

This is a java file utils class, it has method to manipulate java file names.


Constructor Summary
JavaFileUtil()
           
 
Method Summary
static void copyFile(java.io.File sourceFile, java.io.File destFile)
          Algorithm used to copy files.
static void copyFile(java.lang.String sourceFile, java.lang.String destFile)
          Algorithm used to copy files.
static boolean deleteDir(java.io.File dir)
          Deletes a directory and all of its contents recursively.
static boolean deleteDir(java.lang.String dir)
          Deletes a directory and all of its contents recursively.
static java.lang.String extractJavaSuffix(java.lang.String namePlusSufix, java.lang.String suffix)
          This method extract the extension of the Java Source file name
static java.lang.String getDigestRepresentation(java.io.File fileToDigest)
          That utilitary method get a File oject in applying a Message Digest Filter, the result is a digest string representation of the file contents
static java.lang.String getFilePermissions(java.io.File file)
          This method provides the string representation for file permission on Linux systems.
static java.lang.String getFullClassName(java.io.File file, java.lang.String root)
          This method determine the complete name of a class
static java.lang.String getTranslatedFilePath(java.lang.String filepath, java.util.Map<java.lang.String,java.lang.String> gumAttributesMap)
          Makes translations that depend on the operating system being used.
static boolean isAbsolutePath(java.lang.String filepath)
          Tells if a given filepath represents an absolute path or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaFileUtil

public JavaFileUtil()
Method Detail

extractJavaSuffix

public static java.lang.String extractJavaSuffix(java.lang.String namePlusSufix,
                                                 java.lang.String suffix)
This method extract the extension of the Java Source file name

Parameters:
namePlusSufix - The coplete name to the Java Source File
suffix - The substring that should be extracted
Returns:
The file name without suffix parameter.

getFullClassName

public static java.lang.String getFullClassName(java.io.File file,
                                                java.lang.String root)
This method determine the complete name of a class

Parameters:
file - The file abstraction that denotes a java class file
root - The root directory where the class is located
Returns:
The complete name of a class

getDigestRepresentation

public static java.lang.String getDigestRepresentation(java.io.File fileToDigest)
                                                throws UnableToDigestFileException
That utilitary method get a File oject in applying a Message Digest Filter, the result is a digest string representation of the file contents

Parameters:
fileToDigest - The File object abstraction that denotes a file to be digested
Returns:
The digest string representation of the file contents. Or null if some exception occurs,
Throws:
UnableToDigestFileException - If there is any problem on the digest generation, like the file is not found, I/O errors or the digest algorithm is not valid.

getFilePermissions

public static java.lang.String getFilePermissions(java.io.File file)
                                           throws ExecutorException
This method provides the string representation for file permission on Linux systems.

Parameters:
file - The file which permissions will be determined.
Returns:
The string representation for file permissions (e.g. "rwx---r-x")
Throws:
ExecutorException

isAbsolutePath

public static boolean isAbsolutePath(java.lang.String filepath)
Tells if a given filepath represents an absolute path or not.

Parameters:
filepath - The file path.
Returns:
True if the given filepath represents an absolute file path, false otherwise.

getTranslatedFilePath

public static java.lang.String getTranslatedFilePath(java.lang.String filepath,
                                                     java.util.Map<java.lang.String,java.lang.String> gumAttributesMap)
Makes translations that depend on the operating system being used.

Returns:
The translated filepath.

deleteDir

public static boolean deleteDir(java.io.File dir)
Deletes a directory and all of its contents recursively.

Parameters:
dir - Directory to delete.
Returns:
True if directory was deleted.

deleteDir

public static boolean deleteDir(java.lang.String dir)
Deletes a directory and all of its contents recursively.

Parameters:
dir - Directory to delete.
Returns:
True if directory was deleted.

copyFile

public static void copyFile(java.io.File sourceFile,
                            java.io.File destFile)
                     throws java.io.IOException
Algorithm used to copy files.

Parameters:
sourceFile - Sorce file.
destFile - Destination file.
Throws:
java.io.IOException - In case an exception occurs while copying.

copyFile

public static void copyFile(java.lang.String sourceFile,
                            java.lang.String destFile)
                     throws java.io.IOException
Algorithm used to copy files.

Parameters:
sourceFile - Sorce file.
destFile - Destination file.
Throws:
java.io.IOException - In case an exception occurs while copying.