if(xml != null){
out("Using configuration from " + (xmlConfiguration == null ? "input parameters" : xmlConfiguration) + ".", false);
xml = xml.trim();
OORexxParser ooRexxParser = null;
DocGenerator docGenerator = null;
try{
OORexxDocXMLParser docXMLParser = new OORexxDocXMLParser(xml);
ooRexxParser = docXMLParser.getParser();
docGenerator = docXMLParser.getGenerator();
}catch(NullPointerException ex){
out((xmlConfiguration != null ? "Some values are missing or invalid! Please check out the configuration file: " +
xmlConfiguration : "Some paramaters are missing or invalid! Please pass all required parameters!"), true);
}
List<File> srcfiles = ooRexxParser.getContentHolder().getFiles();
if(srcfiles == null || srcfiles.size() == 0){
out("Cannot parse given input directory/file." + (xmlConfiguration != null ? "Please check the configuration file: "+ xmlConfiguration + "!" : "Please check the input parameter!"), true);
}
for(File file: srcfiles)
if(!file.exists())
out("Input " + (file.isDirectory() ? "directory" : "file") + " does not exist!\n" + (xmlConfiguration != null ? "Please check the configuration file: "+ xmlConfiguration + "!" : "Please check the input parameter!"), true);
if(docGenerator.getDestFile().isFile())
out("Output parameters has to be a directory! " + docGenerator.getDestFile().getAbsolutePath(), true);
new Thread(new Runnable() {
public void run() {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date(0));
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
long time = cal.getTimeInMillis();
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
while(!OORexxParser.stopStateThread){
Date dTime = new Date(time);
out(OORexxParser.state + " Time elapsed: " + dateFormat.format(dTime), false);
try {
Thread.sleep(1000l);
} catch (InterruptedException e) {
e.printStackTrace();
}
time += 1000l;
}
OORexxParser.stopStateThread = false;
OORexxParser.state = "";
}
}).start();
List<OORexxPackage> packages = ooRexxParser.parse();
out("Generating files to " + docGenerator.getDestFile().getAbsolutePath(), false);
docGenerator.generate(packages);
out("Finished!", false);