Package es.bsc.dataclay.util
Class FileAndAspectsUtils
- java.lang.Object
-
- es.bsc.dataclay.util.FileAndAspectsUtils
-
public final class FileAndAspectsUtils extends Object
Utility class for aspects and files.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
checkIfSomeFileExists(File folder)
This function checks if there is any file in folder providedstatic void
compileClass(String srcPath, String destPath, String[] classPath)
Compile classstatic void
compileClasses(String srcPath, String destPath, String[] classPath, String excludePackages)
Compile classesstatic void
compileClassesExcluding(String srcPath, String destPath, String[] classPath, Set<String> excludePackages)
Compile classesstatic void
copyFolder(File src, File dest)
Copy folderstatic void
createDirectory(String targetDirectoryPath)
Method that creates a directory on the specified path (or does nothing if it already exists)static void
deleteFolderContent(File folder)
This function deletes the files inside the folder providedstatic String
executeCommand(String[] command, boolean isWindows, boolean printOutput, Path redirectedOutput, String redirectedInput, Map<String,String> envVariables)
Execute commandstatic List<Class<?>>
find(String scannedPackage)
Get all classes in packagestatic ArrayList<String>
getClassNamesFromSourcePath(String dir, boolean isRoot)
This function return a list of class names in a source pathstatic String
storeClass(String targetDirectoryPath, String className, byte[] bs)
Method that stores a class represented by the provided array of bytes with a certain name into a specific directorystatic void
weaveAspects(String binPath, String aspectpath, String[] classPath, String destPath)
Apply aspects
-
-
-
Method Detail
-
createDirectory
public static void createDirectory(String targetDirectoryPath)
Method that creates a directory on the specified path (or does nothing if it already exists)- Parameters:
targetDirectoryPath
- the directory path
-
deleteFolderContent
public static void deleteFolderContent(File folder)
This function deletes the files inside the folder provided- Parameters:
folder
- Folder containing files to delete
-
checkIfSomeFileExists
public static boolean checkIfSomeFileExists(File folder)
This function checks if there is any file in folder provided- Parameters:
folder
- Folder containing files to delete- Returns:
- TRUE if folder is empty
-
storeClass
public static String storeClass(String targetDirectoryPath, String className, byte[] bs)
Method that stores a class represented by the provided array of bytes with a certain name into a specific directory- Parameters:
targetDirectoryPath
- the directory pathclassName
- the file name for the classbs
- Bytecode of the class to store- Returns:
- Path if it succeeds, null otherwise
-
copyFolder
public static void copyFolder(File src, File dest) throws IOException
Copy folder- Parameters:
src
- Source folderdest
- Dest folder- Throws:
IOException
- if some exception occurs
-
find
public static List<Class<?>> find(String scannedPackage)
Get all classes in package- Parameters:
scannedPackage
- Package being scanned- Returns:
- List of classes in package
-
weaveAspects
public static void weaveAspects(String binPath, String aspectpath, String[] classPath, String destPath)
Apply aspects- Parameters:
binPath
- Path of classes to be weavedaspectpath
- Aspects pathclassPath
- Class path (aspects are not applied here)destPath
- Destination path of the class with aspects
-
executeCommand
public static String executeCommand(String[] command, boolean isWindows, boolean printOutput, Path redirectedOutput, String redirectedInput, Map<String,String> envVariables)
Execute command- Parameters:
command
- Command to executeisWindows
- Indicates if windows or LinuxprintOutput
- Print outputredirectedOutput
- Path to file in which to store output of the commandredirectedInput
- TODOenvVariables
- Environment variables for the command.
-
compileClasses
public static void compileClasses(String srcPath, String destPath, String[] classPath, String excludePackages) throws Exception
Compile classes- Parameters:
srcPath
- Source pathdestPath
- Destination pathclassPath
- Class pathexcludePackages
- Packages to exclude- Throws:
Exception
- if some exception occurs
-
compileClassesExcluding
public static void compileClassesExcluding(String srcPath, String destPath, String[] classPath, Set<String> excludePackages) throws Exception
Compile classes- Parameters:
srcPath
- Source pathdestPath
- Destination pathclassPath
- Class pathexcludePackages
- Packages to exclude- Throws:
Exception
- if some exception occurs
-
compileClass
public static void compileClass(String srcPath, String destPath, String[] classPath) throws Exception
Compile class- Parameters:
srcPath
- Source pathdestPath
- Destination pathclassPath
- Class path- Throws:
Exception
- if some exception occurs
-
getClassNamesFromSourcePath
public static ArrayList<String> getClassNamesFromSourcePath(String dir, boolean isRoot)
This function return a list of class names in a source path- Parameters:
dir
- Source path to analyzeisRoot
- Must be true, used for recursive analysis- Returns:
- List of classes found in source path
-
-