Skip to content

Commit 71b7839

Browse files
hansonrhansonr
authored andcommitted
just making constants list of all the .j2s directives
1 parent 8b8f0aa commit 71b7839

File tree

1 file changed

+52
-13
lines changed

1 file changed

+52
-13
lines changed

sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptCompiler.java

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,45 @@ class Java2ScriptCompiler {
5050
private Map<String, String> htMethodsCalled;
5151
private List<String> lstMethodsDeclared;
5252

53+
private final static String J2S_COMPILER_STATUS = "j2s.compiler.status";
54+
private final static String J2S_COMPILER_STATUS_ENABLE = "enable";
55+
private final static String J2S_COMPILER_STATUS_ENABLED = "enabled";
56+
57+
private static final String J2S_SITE_DIRECTORY = "j2s.site.directory";
58+
59+
/**
60+
* log file name for methods declared
61+
*/
62+
private static final String J2S_LOG_METHODS_DECLARED = "j2s.log.methods.declared";
63+
64+
/**
65+
* log file name for methods called
66+
*/
67+
private static final String J2S_LOG_METHODS_CALLED = "j2s.log.methods.called";
68+
69+
private static final String J2S_LOG_ALL_CALLS = "j2s.log.all.calls";
70+
71+
private static final String J2S_LOG_ALL_CALLS_TRUE = "true";
72+
73+
private static final String J2S_EXCLUDED_PATHS = "j2s.excluded.paths";
74+
75+
private static final String J2S_TESTING = "j2s.testing";
76+
77+
private static final String J2S_TESTING_TRUE = "true";
78+
79+
private static final String J2S_COMPILER_NONQUALIFIED_PACKAGES = "j2s.compiler.nonqualified.packages";
80+
81+
private static final String J2S_COMPILER_NONQUALIFIED_CLASSES = "j2s.compiler.nonqualified.classes";
82+
83+
private static final String J2S_COMPILER_MODE = "j2s.compiler.mode";
84+
85+
private static final String J2S_COMPILER_MODE_DEBUG = "debug";
86+
87+
private static final String J2S_CLASS_REPLACEMENTS = "j2s.class.replacements";
88+
89+
private static final String J2S_TEMPLATE_HTML = "j2s.template.html";
90+
91+
5392
private Properties props;
5493
private String htmlTemplate = null;
5594

@@ -132,8 +171,8 @@ boolean initializeProject(IJavaProject project, boolean isCompilationParticipant
132171
try {
133172
File j2sFile = new File(projectFolder, J2S_OPTIONS_FILE_NAME);
134173
props.load(new FileInputStream(j2sFile));
135-
String status = getProperty("j2s.compiler.status");
136-
if (!"enable".equals(status) && !"enabled".equals(status)) {
174+
String status = getProperty(J2S_COMPILER_STATUS);
175+
if (!J2S_COMPILER_STATUS_ENABLE.equalsIgnoreCase(status) && !J2S_COMPILER_STATUS_ENABLED.equalsIgnoreCase(status)) {
137176
if (getFileContents(j2sFile).trim().length() == 0) {
138177
writeToFile(j2sFile, getDefaultJ2SFile());
139178
} else {
@@ -148,7 +187,7 @@ boolean initializeProject(IJavaProject project, boolean isCompilationParticipant
148187
}
149188

150189
File file;
151-
siteFolder = getProperty("j2s.site.directory");
190+
siteFolder = getProperty(J2S_SITE_DIRECTORY);
152191
if (siteFolder == null)
153192
siteFolder = "site";
154193
siteFolder = projectFolder + "/" + siteFolder;
@@ -159,7 +198,7 @@ boolean initializeProject(IJavaProject project, boolean isCompilationParticipant
159198
// method declarations and invocations are only logged
160199
// when the designated files are deleted prior to building
161200

162-
logDeclared = (isCompilationParticipant && !isCleanBuild ? null : getProperty("j2s.log.methods.declared"));
201+
logDeclared = (isCompilationParticipant && !isCleanBuild ? null : getProperty(J2S_LOG_METHODS_DECLARED));
163202
if (logDeclared != null) {
164203
if (!(file = new File(projectFolder, logDeclared)).exists()) {
165204
lstMethodsDeclared = new ArrayList<String>();
@@ -169,17 +208,17 @@ boolean initializeProject(IJavaProject project, boolean isCompilationParticipant
169208
}
170209
logAllCalls = false;
171210

172-
logCalled = (isCompilationParticipant && !isCleanBuild ? null : getProperty("j2s.log.methods.called"));
211+
logCalled = (isCompilationParticipant && !isCleanBuild ? null : getProperty(J2S_LOG_METHODS_CALLED));
173212
if (logCalled != null) {
174213
if (!(file = new File(projectFolder, logCalled)).exists()) {
175214
htMethodsCalled = new Hashtable<String, String>();
176215
System.err.println("logging methods called to " + file);
177216
}
178217
logCalled = projectFolder + "/" + logCalled;
179-
logAllCalls = "true".equals(getProperty("j2s.log.all.calls"));
218+
logAllCalls = J2S_LOG_ALL_CALLS_TRUE.equalsIgnoreCase(getProperty(J2S_LOG_ALL_CALLS));
180219
}
181220

182-
excludedPaths = getProperty("j2s.excluded.paths");
221+
excludedPaths = getProperty(J2S_EXCLUDED_PATHS);
183222

184223
lstExcludedPaths = null;
185224

@@ -193,21 +232,21 @@ boolean initializeProject(IJavaProject project, boolean isCompilationParticipant
193232
lstExcludedPaths = null;
194233
}
195234

196-
testing = "true".equals(getProperty("j2s.testing"));
235+
testing = J2S_TESTING_TRUE.equalsIgnoreCase(getProperty(J2S_TESTING));
197236

198-
String prop = getProperty("j2s.compiler.nonqualified.packages");
237+
String prop = getProperty(J2S_COMPILER_NONQUALIFIED_PACKAGES);
199238
// older version of the name
200-
String nonqualifiedPackages = getProperty("j2s.compiler.nonqualified.classes");
239+
String nonqualifiedPackages = getProperty(J2S_COMPILER_NONQUALIFIED_CLASSES);
201240
nonqualifiedPackages = (prop == null ? "" : prop)
202241
+ (nonqualifiedPackages == null ? "" : (prop == null ? "" : ";") + nonqualifiedPackages);
203242
if (nonqualifiedPackages.length() == 0)
204243
nonqualifiedPackages = null;
205244
// includes @j2sDebug blocks
206-
isDebugging = "debug".equals(getProperty("j2s.compiler.mode"));
245+
isDebugging = J2S_COMPILER_MODE_DEBUG.equalsIgnoreCase(getProperty(J2S_COMPILER_MODE));
207246

208-
String classReplacements = getProperty("j2s.class.replacements");
247+
String classReplacements = getProperty(J2S_CLASS_REPLACEMENTS);
209248

210-
String htmlTemplateFile = getProperty("j2s.template.html");
249+
String htmlTemplateFile = getProperty(J2S_TEMPLATE_HTML);
211250
if (htmlTemplateFile == null)
212251
htmlTemplateFile = "template.html";
213252

0 commit comments

Comments
 (0)