changeset 1200:7c88650ff548

PRFParser: Added a callback to be called from parsePRFs() if a PRF was parsed successfully. flys-backend/trunk@2304 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 07 Jul 2011 14:51:08 +0000
parents cc8f770796cb
children 4e1b475a8cba
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/importer/PRFParser.java
diffstat 2 files changed, 40 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Thu Jul 07 14:41:52 2011 +0000
+++ b/flys-backend/ChangeLog	Thu Jul 07 14:51:08 2011 +0000
@@ -1,3 +1,10 @@
+2011-07-07	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/importer/PRFParser.java:
+	  Added a callback to be called from parsePRFs() if
+	  a PRF was parsed successfully. Useful to scan whole
+	  sub directories for PRF files.
+
 2011-07-07	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/importer/PRFParser.java:
--- a/flys-backend/src/main/java/de/intevation/flys/importer/PRFParser.java	Thu Jul 07 14:41:52 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/PRFParser.java	Thu Jul 07 14:51:08 2011 +0000
@@ -41,6 +41,10 @@
 
     public static final double X_EPSILON = 1e-4;
 
+    public interface PRFCallback {
+        void found(PRFParser parser);
+    } // interface PRFParser
+
     public static final class XY
     implements Comparable<XY>
     {
@@ -65,6 +69,30 @@
             if (index > other.index)     return +1;
             return 0;
         }
+
+        public double getX() {
+            return x;
+        }
+
+        public void setX(double x) {
+            this.x = x;
+        }
+
+        public double getY() {
+            return y;
+        }
+
+        public void setY(double y) {
+            this.y = y;
+        }
+
+        public int getIndex() {
+            return index;
+        }
+
+        public void setIndex(int index) {
+            this.index = index;
+        }
     } // class XY
 
     public static class DataFormat {
@@ -404,7 +432,7 @@
         description = null;
     }
 
-    public static void parsePRFs(File root) {
+    public static void parsePRFs(File root, PRFCallback callback) {
 
         PRFParser parser = new PRFParser();
 
@@ -427,6 +455,9 @@
                 parser.reset();
                 boolean success = parser.parse(file);
                 log.info("parsing " + (success ? "succeeded" : "failed"));
+                if (success && callback != null) {
+                    callback.found(parser);
+                }
             }
         }
     }
@@ -434,7 +465,7 @@
     public static void main(String [] args) {
 
         for (String arg: args) {
-            parsePRFs(new File(arg));
+            parsePRFs(new File(arg), null);
         }
     }
 }

http://dive4elements.wald.intevation.org