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