*
* @param xmlFile xml file associated with configuration info
*/
public XmlConfig(String xmlFile, String tag) {
file = xmlFile;
XMLElement el = null;
boolean fileMissing = false;
try {
try{
try {
IXMLParser parser = XMLParserFactory.createDefaultXMLParser();
// IXMLReader reader = StdXMLReader.fileReader(file); // fails on pc
BufferedReader breader = new BufferedReader(new FileReader(file));
IXMLReader reader = new StdXMLReader(breader);
parser.setReader(reader);
el = (XMLElement) parser.parse();
if (el == null) {
el = promptToOverwrite(xmlFile, tag);
} else {
LogBuffer.println("created xml config from file " + file);
}
} catch (java.io.FileNotFoundException e) {
LogBuffer.println("File not found, will try from URL");
fileMissing = true;
url = new URL(xmlFile);
el = getXMLElementFromURL();
} catch (java.security.AccessControlException e) {
LogBuffer.println("AccessControlException, will try from URL");
url = new URL(xmlFile);
el = getXMLElementFromURL();
}
} catch (java.net.MalformedURLException e) {
if (!file.contains(":")) {
url = new URL("file://" + xmlFile);
el = getXMLElementFromURL();
} else if (fileMissing) {
// well, let's make our own...
el = makeNewConfig(tag);
} else {
System.out.println("Invalid URL");
System.out.println(e);
}
}
} catch (XMLException ex) {
try {
el = promptToOverwrite(xmlFile, tag);
} catch (Exception e) {
System.out.println("Problem opening window: " + e.toString());
System.out.println("Error parsing XML code in configuration file");
System.out.println(file);
System.out.println("Manually deleting file may fix, but you'll lose settings.");
System.out.println("error was: " + ex);
file = null;
el = new XMLElement(tag);
}
} catch (java.io.FileNotFoundException e) {
// well, let's make our own...
el = makeNewConfig(tag);
} catch (Exception ex) {