// translate to an ArrayList<String> for munging
ArrayList<String> args = new ArrayList<String>(originalArgs.length);
for (String a: originalArgs) {
args.add(a);
}
ArrayList<String[]> flags = ApiCheck.parseFlags(args);
for (String[] a: flags) {
if (a[0].equals("-error") || a[0].equals("-warning")
|| a[0].equals("-hide")) {
try {
int level = -1;
if (a[0].equals("-error")) {
level = Errors.ERROR;
}
else if (a[0].equals("-warning")) {
level = Errors.WARNING;
}
else if (a[0].equals("-hide")) {
level = Errors.HIDDEN;
}
Errors.setErrorLevel(Integer.parseInt(a[1]), level);
}
catch (NumberFormatException e) {
System.err.println("Bad argument: " + a[0] + " " + a[1]);
System.exit(2);
}
}
}
String xmlFileName = args.get(0);
String xmlFileNameNew = args.get(1);
XMLReader xmlreader = null;
try {
// parse the XML files into our data structures
xmlreader = XMLReaderFactory.createXMLReader();
ApiCheck acheck = new ApiCheck();
MakeHandler handler = acheck.new MakeHandler();
xmlreader.setContentHandler(handler);
xmlreader.setErrorHandler(handler);
FileReader filereader = new FileReader(xmlFileName);
xmlreader.parse(new InputSource(filereader));
FileReader filereaderNew = new FileReader(xmlFileNameNew);
xmlreader.parse(new InputSource(filereaderNew));
// establish the superclass relationships
handler.getOldApi().resolveSuperclasses();
handler.getNewApi().resolveSuperclasses();
// finally, run the consistency check
handler.getOldApi().isConsistent(handler.getNewApi());
} catch (SAXParseException e) {
Errors.error(Errors.PARSE_ERROR,
new SourcePositionInfo(xmlFileName, e.getLineNumber(), 0),
e.getMessage());
} catch (Exception e) {
e.printStackTrace();
Errors.error(Errors.PARSE_ERROR,
new SourcePositionInfo(xmlFileName, 0, 0),
e.getMessage());
}
Errors.printErrors();
System.exit(Errors.hadError ? 1 : 0);