changeset 4778:a70de5298248

ImportRiver: Add helper implementation of a CrossSectionParserCallback.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 08 Jan 2013 11:57:03 +0100
parents 34398f424cfd
children 18908a3cbb3a
files flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java
diffstat 1 files changed, 36 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Mon Jan 07 11:55:46 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Tue Jan 08 11:57:03 2013 +0100
@@ -156,6 +156,42 @@
 
     protected River peer;
 
+
+    /** Callback-implementation for CrossSectionParsers. */
+    class ImportRiverCrossSectionParserCallback implements CrossSectionParser.Callback {
+        Set<HashedFile> files = new HashSet<HashedFile>();
+        String type;
+
+
+        /**
+         * Create new Callback, given type which is used for logging
+         * purposes only.
+         */
+        public ImportRiverCrossSectionParserCallback (String type) {
+            this.type = type;
+        }
+
+
+        /** Accept file if not duplicate. */
+        public boolean accept(File file) {
+            HashedFile hf = new HashedFile(file);
+            boolean success = files.add(hf);
+            if (!success) {
+                log.warn(type + " file '" + file + "' seems to be a duplicate.");
+            }
+            return success;
+        }
+
+
+        /** Add crosssection. */
+        public void    parsed(CrossSectionParser parser) {
+           log.debug("callback from " + type + " parser");
+
+           addCrossSections(parser);
+        }
+    }
+
+
     public ImportRiver() {
         hyks                      = new ArrayList<ImportHYK>();
         crossSections             = new ArrayList<ImportCrossSection>();

http://dive4elements.wald.intevation.org