package osmimport;

import java.io.File;

import org.openstreetmap.osmosis.core.task.v0_6.Sink;
import org.openstreetmap.osmosis.xml.common.CompressionMethod;
import org.openstreetmap.osmosis.xml.v0_6.FastXmlReader;
import org.voltdb.CLIConfig;

public class OSMImport implements Runnable {
  public File input;
  private OSMConfig config;

  public OSMImport(OSMConfig config) {
    this.config = config;
  }


  public void run() {
    CompressionMethod compressionMethod = CompressionMethod.None;
    Sink sink = new VoltDBOsmSink(config.server);
    FastXmlReader fxr = new FastXmlReader(input, false, compressionMethod);
    fxr.setSink(sink);
    fxr.run();

  }

  /**
     * Uses included {@link CLIConfig} class to declaratively state command line
     * options with defaults and validation.
     */
    static class OSMConfig extends CLIConfig {

        @Option(desc = "the server to connect to.")
        String server = "localhost";

        @Option(desc = "The path to the .osm file to import")
        String file = "";

        @Override
        public void validate() {
            if ( "".equals(file)) {
              System.err.println("you need to specify a valid path to an .osm file");
              System.exit(1);
            }
        }
    }

  public static void main(String[] args) {
    OSMConfig config = new OSMConfig();
    config.parse(OSMImport.class.getName(), args);

    OSMImport osm = new OSMImport(config);

    osm.input = new File(config.file);
    osm.run();
  }



}

@@ -284,18 +284,17 @@
 nable %7B%0A
-  
+%09
 public F
@@ -304,18 +304,17 @@
  input;%0A
-  
+%09
 private 
@@ -331,19 +331,19 @@
 config;%0A
-%0A  
+%09%0A%09
 public O
@@ -371,20 +371,18 @@
 nfig) %7B%0A
-    
+%09%09
 this.con
@@ -399,16 +399,16 @@
 ig;%0A
-  %7D%0A%0A%0A  
+%09%7D%0A%09%0A%09%0A%09
 publ
@@ -423,20 +423,18 @@
 run() %7B%0A
-    
+%09%09
 Compress
@@ -487,20 +487,18 @@
 d.None;%0A
-    
+%09%09
 Sink sin
@@ -535,20 +535,18 @@
 erver);%0A
-    
+%09%09
 FastXmlR
@@ -609,20 +609,18 @@
 ethod);%0A
-    
+%09%09
 fxr.setS
@@ -630,20 +630,18 @@
 (sink);%0A
-    
+%09%09
 fxr.run(
@@ -647,16 +647,17 @@
 ();%0A
-%0A  %7D%0A%0A  
+%09%09%0A%09%7D%0A%09%0A%09
 /**%0A
@@ -837,16 +837,24 @@
 onfig %7B%0A
+        
 %0A       
@@ -935,16 +935,24 @@
 lhost%22;%0A
+        
 %0A       
@@ -1124,34 +1124,33 @@
 ) %7B%0A            
-  
+%09
 System.err.print
@@ -1217,18 +1217,17 @@
         
-  
+%09
 System.e
@@ -1264,19 +1264,19 @@
 %7D%0A    %7D%0A
-%0A  
+%09%0A%09
 public s
@@ -1308,20 +1308,18 @@
 args) %7B%0A
-    
+%09%09
 OSMConfi
@@ -1346,20 +1346,18 @@
 nfig();%0A
-    
+%09%09
 config.p
@@ -1395,21 +1395,21 @@
  args);%0A
-%0A    
+%09%09%0A%09%09
 OSMImpor
@@ -1439,21 +1439,27 @@
 onfig);%0A
-%0A
+   
     
+ %0A%09%09
 osm.inpu
@@ -1485,20 +1485,18 @@
 .file);%0A
-    
+%09%09
 osm.run(
@@ -1502,13 +1502,15 @@
 ();%0A
-  %7D%0A%0A%0A
+%09%7D%0A%09%0A%09%0A%09
 %0A%7D%0A

Revert "removed unnecessary whitespace, testing commit hook."