Menu

[7cef54]: / src / commonTools / RepeatTool.java  Maximize  Restore  History

Download this file

54 lines (43 with data), 1.4 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
package commonTools;
import java.util.LinkedList;
import java.util.List;
import utilities.StringUtilities;
import core.languageHandler.Language;
public abstract class RepeatTool {
protected static final String TAB = " ";
protected static final String TWO_TAB = TAB + TAB;
protected static final String THREE_TAB = TWO_TAB + TAB;
protected static final String FOUR_TAB = THREE_TAB + TAB;
protected List<String> imports;
public RepeatTool() {
imports = new LinkedList<>();
imports.add("import core.UserDefinedAction;");
imports.add("import core.controller.Core;");
}
public String getSource(Language language) {
if (isSupported(language)) {
return "package core;\n"
+ StringUtilities.join(imports, "\n") + "\n\n"
+ getHeader(language) + getBodySource(language) + getFooter(language);
} else {
return "";
}
}
protected String getHeader(Language language) {
if (language == Language.JAVA) {
return "public class CustomAction extends UserDefinedAction {\n"
+ " public void action(final Core controller) throws InterruptedException {\n";
} else {
return "";
}
}
protected String getFooter(Language language) {
if (language == Language.JAVA) {
return " }\n}";
} else {
return "";
}
}
protected abstract boolean isSupported(Language language);
protected abstract String getBodySource(Language language);
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.