diff src/java/de/intevation/mxd/Converter.java @ 25:cbd67b1100d8

Initial commit of the first prototype.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 08 Apr 2011 11:47:59 +0200
parents c0060abb7457
children 0e71a1f71ec0
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/Converter.java	Mon Apr 04 20:01:25 2011 +0200
+++ b/src/java/de/intevation/mxd/Converter.java	Fri Apr 08 11:47:59 2011 +0200
@@ -1,5 +1,14 @@
-package de.intevation.mxd;
+//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.
@@ -8,8 +17,68 @@
  */
 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) {
-        // TODO FILL ME
+        try{
+            IReader reader = new MXDReader();
+            reader.init();
+//            reader.setFilename("testdata/SubsurfaceSediments-Internet.mxd");
+//            reader.setFilename("testdata/p_single_4pt_c255-0-0.mxd");
+//            reader.setFilename("testdata/Facilities-Internet.mxd");
+//            reader.setFilename("testdata/fernerkundung_albedo.mxd");
+            reader.setFilename("testdata/gevu.mxd");
+
+            reader.read();
+            reader.shutdown();
+        }
+        catch(IOException e){
+            e.printStackTrace();
+        }
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)