Format and minor docs.

master
Ivan Olexyn 6 years ago
parent 7b018185c8
commit d43e79babd

@ -6,16 +6,20 @@ public class Artifacts {
Tools tools = new Tools();
/**
* @param file
* @return
*/
public MFile getMFile(File file) {
MFile mfile = new MFile();
mfile.file = file;
mfile.md5 = tools.getMd5(file.getPath());
return mfile;
}
/**
*
*/
public class MFile {
public File file;
public String md5;

@ -16,6 +16,9 @@ import java.util.Map;
import app.Artifacts.MFile;
/***
* Controller class for JavaFX. Contains the application logic.
*/
public class Controller {

@ -7,7 +7,6 @@ public class Execute {
/**
*
* @param cmd an array representing a shell command
* @return <i>TwoBr</i> class, containing two BufferedReaders,
* <i>output</i> and <i>error</i>

@ -13,7 +13,6 @@ import javafx.stage.Stage;
public class Main extends Application {
static String foo;
@Override
public void start(Stage primaryStage) throws Exception {

@ -10,6 +10,10 @@ public class QuicksortMd5 {
private int j;
private int p;
/**
* @param md5Pool
* @return a Map sorted by md5.
*/
public Map<Integer, MFile> quicksortMd5(Map<Integer, MFile> md5Pool) {
this.md5Pool = md5Pool;

@ -12,28 +12,24 @@ import app.Artifacts.MFile;
public class Routines {
Execute x = null;
Tools tools = new Tools();
Write write = new Write();
Execute x;
Tools tools;
public Routines() {
this.x = new Execute();
this.tools = new Tools();
}
/**
* [1] Write output of <b>find srcdir</b> to <b>/tmp/find</b> <br>
* [2] Read <b>/tmp/find</b> into <b>List>String></b> <br>
* [3] Add <b>List>String></b> entries to <b>Map>String,File></b> , where
* [1] Write output of <b>find srcdir</b> to <b>/tmp/find</b> .<br>
* [2] Read <b>/tmp/find</b> into <b>List< String /></b> .<br>
* [3] Add <b>List< String /></b> entries to <b>Map>String,File></b> , where
* <b>String</b> is an <b>int</b> key. <br>
*
* @param srcdir
* @param type file OR directory
* @param srcdir <i>String</i>
* @param type <i>String</i> "file" OR "dir" , pick what type will be loaded.
* @return filepool
*/
public Map<Integer, File> loadPool(String srcdir, String type) {
@ -51,7 +47,7 @@ public class Routines {
int j = 0;
for (int i = 0; i < lines.size(); i++) {
File file = new File(lines.get(i));
if (type == "directory" && file.isDirectory() || type == "file" && file.isFile()) {
if (type == "dir" && file.isDirectory() || type == "file" && file.isFile()) {
filepool.put(j, file);
j++;
}
@ -59,7 +55,12 @@ public class Routines {
return filepool;
}
/**
* Calculate md5 for each file in <b>pool</b> .
*
* @param pool Map< Integer, File />
* @return Map< Integer , MFile />
*/
public Map<Integer, MFile> md5Pool(Map<Integer, File> pool) {
Map<Integer, MFile> md5Pool = new HashMap<>();
for (int i = 0; i < pool.size(); i++) {
@ -69,7 +70,10 @@ public class Routines {
return md5Pool;
}
/**
* @param md5Pool Map< Integer, MFile /> , a map containing files and their md5.
* @return Map< Integer , MFile /> of duplicates contained in <b>md5Pool</b>
*/
public Map<Integer, MFile> doubles(Map<Integer, MFile> md5Pool) {
Map<Integer, MFile> doubles = new HashMap<>();
int d = 0;

@ -13,10 +13,11 @@ public class Tools {
/**
* @return Md5 of File at @param path
* @param path <i>String</i>
* @return Md5 of File at <b>path</b>
*/
public String getMd5(String path) {
// output of md5sum: "md5 filepath"
// output of md5sum is "md5 filepath"
BufferedReader md5reader = x.execute(new String[]{"md5sum", path}).output;
String md5 = null;
try {

@ -4,13 +4,16 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.Map;
import app.Artifacts.MFile;
public class Write {
/**
* writes <b>text</b> to file at <b>path</b>
* <p>
* Write <b>text</b> to file at <b>path</b> .
*
* @param path <i>String</i>
* @param text <i>StringBuilder</i>
*/
public void textFile(String path, StringBuilder text) {
try {
@ -24,11 +27,11 @@ public class Write {
/**
* append all elements of <b>pool</b> to StringBuilder and write to
* <b>/tmp/name</b>
* <p>
* Append all elements of <b>pool</b> to <i>StringBuilder</i>
* and write to /tmp/<b>name</b> .
*
* @param pool
* @param name <i>String</i>
* @param pool <i>Map< Integer, File /></i>
*/
public void textPool(String name, Map<Integer, File> pool) {
StringBuilder text = new StringBuilder();
@ -40,11 +43,11 @@ public class Write {
/**
* append all elements of <b>md5Pool</b> to StringBuilder and write to
* <b>/tmp/name</b>
* <p>
* Append all elements of <b>pool</b> to <i>StringBuilder</i>
* and write to /tmp/<b>name</b> .
*
* @param md5Pool
* @param name <i>String</i>
* @param md5Pool <i>Map< Integer, MFile /></i>
*/
public void textMd5Pool(String name, Map<Integer, MFile> md5Pool) {
StringBuilder text = new StringBuilder();

Loading…
Cancel
Save