}
public void run() throws DmcValueExceptionSet, DmcRuleExceptionSet {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String currLine = null;
TokenArrayList tokens = null;
// boolean shared = false;
if (autogen.booleanValue()){
for(ConfigVersion version: finder.getVersions().values()){
ConfigLocation loc = version.getLatestVersion();
if (!loc.isFromJAR()){
// Wasn't in a jar, so try to generate
generateFromConfig(loc);
}
}
try {
if (docdir.length() > 0){
if (workspace.length() > 0)
docGenerator.dumpDocumentation(workspace.toString() + "/" + docdir.toString());
else
docGenerator.dumpDocumentation(docdir.toString());
}
} catch (IOException e) {
System.err.println(e.toString());
e.printStackTrace();
System.exit(1);
}
System.exit(0);
}
System.out.println("\n-- dmo generator utility --\n");
System.out.println("Enter the name of a local (non-JAR) schema to generate its code\n");
System.out.println("Enter ? for a list of schemas...\n\n");
while(true){
try{
String s = in.readLine();
if (s == null)
return;
currLine = s.trim();
if (currLine.length() == 0)
continue;
tokens = classifier.classify(currLine, false);
// DmsSchemaLocation currLoc = finder.getLocation(tokens.nth(0).getValue());
// DmsSchemaLocation currLoc = finder.getLocation(tokens.nth(0).getValue());
ConfigVersion config = finder.getConfig(tokens.nth(0).getValue());
ConfigLocation currLoc = null;
if (config != null)
currLoc = config.getLatestVersion();
if (currLine.equals("?")){
System.out.println("");
System.out.println(finder.getSearchInfo() + "\n");
Iterator<ConfigVersion> it = finder.getVersions().values().iterator();
while(it.hasNext()){
ConfigVersion version = it.next();
ConfigLocation loc = version.getLatestVersion();
if (loc.getJarFilename() == null){
System.out.println(format.sprintf(loc.getConfigName()) + " version: " + loc.getVersion());
// System.out.println(format.sprintf(loc.getConfigName()) + " " + loc.getDirectory());
System.out.println(format.sprintf("") + " " + loc.getConfigParentDirectory() + "\n");
}
else{
System.out.println(format.sprintf("JAR " + loc.getConfigName()) + " " + loc.getDirectory());
System.out.println(format.sprintf("") + " " + loc.getConfigParentDirectory() + "\n");
}
}
System.out.println("");
}
else if (currLoc == null){
System.err.println("\n" + currLine + " is not a recoginized schema name.\n\n");
}
else{
if (currLoc.isFromJAR()){
System.out.println("You can only generate code from schemas in your local environment.\n\n");
continue;
}
try {
// Create a new manager into which the parsed schemas will be loaded
readSchemas = new SchemaManager();
// Parse the specified schema
SchemaDefinition sd = parser.parseSchema(readSchemas, tokens.nth(0).getValue(), false);
// Generate the code
FileUpdateManager.instance().reportProgress(System.out);
FileUpdateManager.instance().reportErrors(System.err);