changeset 6336:c4fbd85a33ee

Backend: Added factory to ImportWst to create columns which are derived from ImportWstColumns. This will be handy when creating columns for the official lines.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 14 Jun 2013 13:25:23 +0200
parents b2a470c148a7
children 224d7c4b5291
files backend/src/main/java/org/dive4elements/river/importer/ImportWst.java
diffstat 1 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportWst.java	Fri Jun 14 13:01:26 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportWst.java	Fri Jun 14 13:25:23 2013 +0200
@@ -24,6 +24,18 @@
 {
     private static Logger log = Logger.getLogger(ImportWst.class);
 
+    public interface ImportWstColumnFactory {
+        ImportWstColumn create(ImportWst iw, int position);
+    }
+
+    public static final ImportWstColumnFactory COLUMN_FACTORY =
+        new ImportWstColumnFactory() {
+            @Override
+            public ImportWstColumn create(ImportWst importWst, int position) {
+                return new ImportWstColumn(importWst, null, null, position);
+            }
+        };
+
     protected String description;
 
     protected Integer kind;
@@ -32,16 +44,27 @@
 
     protected ImportUnit unit;
 
+    protected ImportWstColumnFactory columnFactory;
+
     /** Wst as in db. */
     protected Wst peer;
 
     public ImportWst() {
+        this(COLUMN_FACTORY);
+    }
+
+    public ImportWst(ImportWstColumnFactory columnFactory) {
+        this.columnFactory = columnFactory;
         kind = 0;
         columns = new ArrayList<ImportWstColumn>();
     }
 
     public ImportWst(String description) {
-        this();
+        this(description, COLUMN_FACTORY);
+    }
+
+    public ImportWst(String description, ImportWstColumnFactory columnFactory) {
+        this(columnFactory);
         this.description = description;
     }
 
@@ -65,7 +88,7 @@
     /** Create columns that can be accessed with getColumn. */
     public void setNumberColumns(int numColumns) {
         for (int i = 0; i < numColumns; ++i) {
-            columns.add(new ImportWstColumn(this, null, null, i));
+            columns.add(columnFactory.create(this, i));
         }
     }
 

http://dive4elements.wald.intevation.org