# HG changeset patch # User Sascha L. Teichmann # Date 1310050268 0 # Node ID 7c88650ff5489b4b8569f7240dccca68c6221877 # Parent cc8f770796cb05f7bde000441967fceab12978e5 PRFParser: Added a callback to be called from parsePRFs() if a PRF was parsed successfully. flys-backend/trunk@2304 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r cc8f770796cb -r 7c88650ff548 flys-backend/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/importer/PRFParser.java: diff -r cc8f770796cb -r 7c88650ff548 flys-backend/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 { @@ -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); } } }