changeset 3920:8483d190b2e7

Convert FKYSArtifact data member to a private variable Add setData and use getAllData in classes which access data directly. flys-artifacts/trunk@5600 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Wed, 26 Sep 2012 10:56:52 +0000
parents 355c843245c1
children deff2c337111
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterlevelArtifact.java
diffstat 4 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Sep 26 08:20:46 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Sep 26 10:56:52 2012 +0000
@@ -1,3 +1,10 @@
+2012-09-26	Björn Ricks	<bjoern.ricks@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/WaterlevelArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java,
+	  src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java:
+	  Mark FLYSArtifact data member as private and add setter method.
+
 2012-09-26	Christian Lins	<christian.lins@intevation.de>
 
 	* doc/conf/second-themes.xml,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Wed Sep 26 08:20:46 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Wed Sep 26 10:56:52 2012 +0000
@@ -92,7 +92,7 @@
     protected String name;
 
     /** The data that have been inserted into this artifact. */
-    protected Map<String, StateData> data;
+    private Map<String, StateData> data;
 
     /** Mapping of state names to created facets. */
     protected Map<String, List<Facet>> facets;
@@ -757,6 +757,12 @@
         return data.get(name);
     }
 
+    /**
+     * A derived Artifact class can use this method to set the data
+     */
+    protected void setData(Map<String, StateData> data) {
+        this.data = data;
+    }
 
     /** Return named data item, null if not found. */
     public String getDataAsString(String name) {
@@ -869,7 +875,10 @@
         addData(name, new DefaultStateData(name, null, null, value));
     }
 
-
+    /**
+     * This method returns all stored StateData in this artifact as a Collection
+     * @return a Collection of all StateData objects in this artifact
+     */
     public Collection<StateData> getAllData() {
         return data.values();
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java	Wed Sep 26 08:20:46 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticFLYSArtifact.java	Wed Sep 26 10:56:52 2012 +0000
@@ -54,7 +54,7 @@
         root.appendChild(createOutputModes(cc, desc, creator));
 
         // Add the data to an anonymous state.
-        Collection<StateData> datas = this.data.values();
+        Collection<StateData> datas = getAllData();
         if (datas.size() > 0) {
             Element ui = creator.create("ui");
             Element staticE = creator.create("static");
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterlevelArtifact.java	Wed Sep 26 08:20:46 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WaterlevelArtifact.java	Wed Sep 26 10:56:52 2012 +0000
@@ -88,7 +88,7 @@
         CallMeta meta)
     {
         WINFOArtifact winfo = (WINFOArtifact) artifact;
-        this.data = winfo.cloneData();
+        setData(winfo.cloneData());
         logger.debug("Cloned data of winfo artifact.");
         // Statically add Facets.
         List<Facet> fs = new ArrayList<Facet>();

http://dive4elements.wald.intevation.org