forked from tushartushar/DesigniteJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputArgs.java
More file actions
64 lines (56 loc) · 1.79 KB
/
InputArgs.java
File metadata and controls
64 lines (56 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package Designite;
import java.io.File;
public class InputArgs {
private String sourceFolder;
private String outputFolder;
public InputArgs() {
//It is invoked only in case of error
}
public InputArgs(String inputFolderPath, String outputFolderPath) {
sourceFolder = inputFolderPath;
outputFolder = outputFolderPath;
checkEssentialInputs();
}
public String getSourceFolder() {
return sourceFolder;
}
public String getOutputFolder() {
return outputFolder;
}
//At least, the source folder must be specified
private void checkEssentialInputs() {
if (sourceFolder==null)
{
//System.out.println("Input source folder is not specified.");
throw new IllegalArgumentException("Input source folder is not specified.");
}
File folder = new File(sourceFolder);
if (!(folder.exists() && folder.isDirectory()))
{
//System.out.println("Input source folder path is not valid.");
throw new IllegalArgumentException("Input source folder path is not valid.");
}
File outFolder = new File(outputFolder);
if (outFolder.exists() && outFolder.isFile())
{
//System.out.println("The specified output folder path is not valid.");
throw new IllegalArgumentException("The specified output folder path is not valid.");
}
}
/***
* Analyzes the provided <b>sourceFolder</b> variable and
* extracts the name of the project.
* @return A String with the name of the project.
* When the given sourceFolder has a value of <i>src</i>
* or <i>source</i> then the method returns
* the name of the direct parent directory
*/
public String getProjectName() {
File temp = new File(sourceFolder);
if (temp.getName().equals("src") || temp.getName().equals("source")) {
return new File(temp.getParent()).getName();
} else {
return new File(sourceFolder).getName();
}
}
}