Removing ${switch logic from Module in favor of using properties
This commit is contained in:
parent
bd86928f1c
commit
31831476f1
|
@ -292,52 +292,12 @@ public class Module
|
|||
{
|
||||
try (BufferedReader buf = new BufferedReader(reader))
|
||||
{
|
||||
String line;
|
||||
String sectionType = "";
|
||||
String switchProperty = null;
|
||||
String caseTag = null;
|
||||
String caseTagColon = null;
|
||||
boolean switched = false;
|
||||
String line;
|
||||
while ((line = buf.readLine()) != null)
|
||||
{
|
||||
line = line.trim();
|
||||
|
||||
if (caseTag != null)
|
||||
{
|
||||
if ("}".equals(line))
|
||||
{
|
||||
if (!switched)
|
||||
{
|
||||
StartLog.warn("WARN: No matching case in %s for ${switch %s=%s ...}",basehome.toShortForm(file),switchProperty,caseTag);
|
||||
}
|
||||
caseTag = null;
|
||||
caseTagColon = null;
|
||||
switchProperty = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (switched)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!line.startsWith(caseTagColon) && !line.startsWith("*:"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switched = true;
|
||||
line = line.substring(line.indexOf(':') + 1).trim();
|
||||
}
|
||||
else if (line.startsWith("${switch "))
|
||||
{
|
||||
switched = false;
|
||||
switchProperty = line.substring(9).trim();
|
||||
caseTag = System.getProperty(switchProperty);
|
||||
caseTagColon = caseTag + ":";
|
||||
continue;
|
||||
}
|
||||
|
||||
Matcher sectionMatcher = section.matcher(line);
|
||||
|
||||
if (sectionMatcher.matches())
|
||||
|
@ -358,6 +318,9 @@ public class Module
|
|||
{
|
||||
switch (sectionType)
|
||||
{
|
||||
case "":
|
||||
// ignore (this would be entries before first section)
|
||||
break;
|
||||
case "DEPEND":
|
||||
parentNames.add(line);
|
||||
break;
|
||||
|
@ -376,6 +339,8 @@ public class Module
|
|||
case "INI-TEMPLATE":
|
||||
initialise.add(line);
|
||||
break;
|
||||
default:
|
||||
throw new IOException("Unrecognized Module section: [" + sectionType + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue