Skip to content

Commit

Permalink
Adding more missing documentation. Related to #20.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Alves Vieira committed Apr 27, 2013
1 parent 2863f9e commit 15b0498
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/java/main/br/ufpe/cin/groundhog/parser/JavaParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public JSONObject parseToJSON() throws IOException, JSONException {
}

/**
* Pretty print metrics.
* Pretty print metrics
* @param counters parse method result
*/
public static void printResult(HashMap<String, HashMap<String, MutableInt>> counters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ public class SearchException extends GroundhogException {
public SearchException(Exception e) {
super(e);
}

}
34 changes: 28 additions & 6 deletions src/java/main/br/ufpe/cin/groundhog/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

public class FileUtil {
private static FileUtil instance;
private ArrayList<File> createdTempDirs;

public static FileUtil getInstance() {
if (instance == null) {
Expand All @@ -18,32 +19,53 @@ public static FileUtil getInstance() {
return instance;
}

private ArrayList<File> createdTempDirs;

private FileUtil() {
createdTempDirs = new ArrayList<File>();
this.createdTempDirs = new ArrayList<File>();
}

/**
*
* @return the created temporary directory
*/
public synchronized File createTempDir() {
File tempDir = Files.createTempDir();
createdTempDirs.add(tempDir);
this.createdTempDirs.add(tempDir);
return tempDir;
}

/**
* Deletes the temporary directories used to store the
* downloaded the projects.
*
* @throws IOException
*/
public synchronized void deleteTempDirs() throws IOException {
for (File tempDir : createdTempDirs) {
for (File tempDir : this.createdTempDirs) {
if (tempDir.exists()) {
FileUtils.deleteDirectory(tempDir);
}
}
}

/**
*
* @param file the file to which the string will be written to
* @param data the string to be written to the file
* @throws IOException
*/
public void writeStringToFile(File file, String data) throws IOException {
FileUtils.writeStringToFile(file, data);
}

/**
* Takes a directory and moves it to another directory
*
* @param srcDir the directory to be moved
* @param destDir the destination directory
* @throws IOException
*/
public void copyDirectory(File srcDir, File destDir) throws IOException {
FileUtils.copyDirectory(srcDir, destDir);
// TODO: add tests
}

}

0 comments on commit 15b0498

Please sign in to comment.