rrenkert@25: //package de.intevation.mxd; ingo@24: rrenkert@25: import java.io.IOException; rrenkert@25: import java.io.File; rrenkert@25: import java.io.FileOutputStream; rrenkert@25: import java.io.OutputStream; rrenkert@25: rrenkert@25: import org.apache.log4j.Logger; rrenkert@25: import org.apache.log4j.PropertyConfigurator; rrenkert@25: rrenkert@25: import java.net.MalformedURLException; ingo@24: ingo@24: /** ingo@24: * The entry point of the MXD converter tool. ingo@24: * ingo@24: * @author Ingo Weinzierl ingo@24: */ ingo@24: public class Converter { ingo@24: rrenkert@25: /** rrenkert@25: * The logging is done via Log4j. To configure the logging rrenkert@25: * a file 'log4j.properties' is search in the configuration rrenkert@25: * directory. rrenkert@25: */ rrenkert@25: public static final String LOG4J_PROPERTIES = "log4j.properties"; rrenkert@25: rrenkert@25: /** rrenkert@25: * rrenkert@25: * The path of the configuration directory. rrenkert@25: */ rrenkert@25: public static final String CONFIG_PATH = System.getProperty("config.dir", rrenkert@25: "conf"); rrenkert@25: rrenkert@25: rrenkert@25: /** rrenkert@25: * The logger used in this class. rrenkert@25: */ rrenkert@25: private static Logger logger; rrenkert@25: rrenkert@25: static { rrenkert@25: configureLogging(); rrenkert@25: logger = Logger.getLogger(Converter.class); rrenkert@25: } rrenkert@25: rrenkert@25: rrenkert@25: /** rrenkert@25: * Trys to load the Log4j configuration rrenkert@25: * from ${config.dir}/log4j.properties. rrenkert@25: */ rrenkert@25: public static final void configureLogging() { rrenkert@25: File configDir = new File(CONFIG_PATH); rrenkert@25: File propFile = new File(configDir, LOG4J_PROPERTIES); rrenkert@25: if (propFile.isFile() && propFile.canRead()) { rrenkert@25: try { rrenkert@25: PropertyConfigurator.configure(propFile.toURI().toURL()); rrenkert@25: } rrenkert@25: catch (MalformedURLException mue) { rrenkert@25: mue.printStackTrace(System.err); rrenkert@25: } rrenkert@25: } rrenkert@25: } rrenkert@25: rrenkert@25: /** rrenkert@25: * Entrypoint for the application. rrenkert@25: */ ingo@24: public static void main(String[] args) { rrenkert@25: try{ rrenkert@28: rrenkert@25: IReader reader = new MXDReader(); rrenkert@25: reader.init(); rrenkert@28: rrenkert@28: String path = System.getProperty("mxd.file"); rrenkert@28: if (path.equals("${MXDFILE}")) { rrenkert@28: System.out.println("No valid MXD file. Use ant parameter" + rrenkert@28: " \"-DMXDFILE=path/to/file.mxd\"."); rrenkert@28: System.exit(-1); rrenkert@28: } rrenkert@28: reader.setFilename(path); rrenkert@25: rrenkert@25: reader.read(); rrenkert@25: reader.shutdown(); rrenkert@25: } rrenkert@25: catch(IOException e){ rrenkert@25: e.printStackTrace(); rrenkert@25: } ingo@24: } ingo@24: } ingo@24: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :