diff flys-artifacts/src/main/java/de/intevation/flys/exports/AxisSection.java @ 2058:f97cf2e350c9

Some refactoring done: all Sections subclass TypeSection now to be able to use the convinience methods for string, integer, double and boolean attributes. flys-artifacts/trunk@3550 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 27 Dec 2011 11:37:23 +0000
parents f9a972d375ba
children ca8997aa683e
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/AxisSection.java	Tue Dec 27 11:19:44 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/AxisSection.java	Tue Dec 27 11:37:23 2011 +0000
@@ -12,7 +12,7 @@
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class AxisSection extends DefaultSection {
+public class AxisSection extends TypeSection {
 
     public static final String IDENTIFIER_ATTR = "id";
     public static final String LABEL_ATTR      = "label";
@@ -28,47 +28,22 @@
 
 
     public void setIdentifier(String identifier) {
-        if (identifier == null || identifier.length() == 0) {
-            return;
-        }
-
-        Attribute attr = getAttribute(IDENTIFIER_ATTR);
-        if (attr == null) {
-            attr = new StringAttribute(IDENTIFIER_ATTR, identifier, false);
-            addAttribute(IDENTIFIER_ATTR, attr);
-        }
-        else {
-            attr.setValue(identifier);
-        }
+        setStringValue(IDENTIFIER_ATTR, identifier);
     }
 
 
     public String getIdentifier() {
-        StringAttribute attr = (StringAttribute) getAttribute(IDENTIFIER_ATTR);
-
-        return attr != null ? (String) attr.getValue() : null;
+        return getStringValue(IDENTIFIER_ATTR);
     }
 
 
     public void setLabel(String label) {
-        if (label == null) {
-            return;
-        }
-
-        Attribute attr = getAttribute(LABEL_ATTR);
-        if (attr == null) {
-            attr = new StringAttribute(LABEL_ATTR, label, true);
-            addAttribute(LABEL_ATTR, attr);
-        }
-        else {
-            attr.setValue(label);
-        }
+        setStringValue(LABEL_ATTR, label);
     }
 
 
     public String getLabel() {
-        StringAttribute attr = (StringAttribute) getAttribute(LABEL_ATTR);
-        return attr != null ? (String) attr.getValue() : null;
+        return getStringValue(LABEL_ATTR);
     }
 
 
@@ -77,76 +52,42 @@
             return;
         }
 
-        Attribute attr = getAttribute(FONTSIZE_ATTR);
-        if (attr == null) {
-            attr = new IntegerAttribute(FONTSIZE_ATTR, fontSize, true);
-            addAttribute(FONTSIZE_ATTR, attr);
-        }
-        else {
-            attr.setValue(fontSize);
-        }
+        setIntegerValue(FONTSIZE_ATTR, fontSize);
     }
 
 
     public Integer getFontSize() {
-        IntegerAttribute attr = (IntegerAttribute) getAttribute(FONTSIZE_ATTR);
-        return attr != null ? (Integer) attr.getValue() : null;
+        return getIntegerValue(FONTSIZE_ATTR);
     }
 
 
     public void setFixed(boolean fixed) {
-        Attribute attr = getAttribute(FIXATION_ATTR);
-        if (attr == null) {
-            attr = new BooleanAttribute(FIXATION_ATTR, fixed, true);
-            addAttribute(FIXATION_ATTR, attr);
-        }
-        else {
-            attr.setValue(fixed);
-        }
+        setBooleanValue(FIXATION_ATTR, fixed);
     }
 
 
     public Boolean isFixed() {
-        BooleanAttribute attr = (BooleanAttribute) getAttribute(FIXATION_ATTR);
-        return attr != null ? (Boolean) attr.getValue() : null;
+        return getBooleanValue(FIXATION_ATTR);
     }
 
 
     public void setUpperRange(double upperRange) {
-        Attribute attr = getAttribute(UPPERRANGE_ATTR);
-        if (attr == null) {
-            attr = new DoubleAttribute(UPPERRANGE_ATTR, upperRange, true);
-            addAttribute(UPPERRANGE_ATTR, attr);
-        }
-        else {
-            attr.setValue(upperRange);
-        }
+        setDoubleValue(UPPERRANGE_ATTR, upperRange);
     }
 
 
     public Double getUpperRange() {
-        DoubleAttribute attr = (DoubleAttribute) getAttribute(UPPERRANGE_ATTR);
-
-        return attr != null ? (Double) attr.getValue() : null;
+        return getDoubleValue(UPPERRANGE_ATTR);
     }
 
 
     public void setLowerRange(double lowerRange) {
-        Attribute attr = getAttribute(LOWERRANGE_ATTR);
-        if (attr == null) {
-            attr = new DoubleAttribute(LOWERRANGE_ATTR, lowerRange, true);
-            addAttribute(LOWERRANGE_ATTR, attr);
-        }
-        else {
-            attr.setValue(lowerRange);
-        }
+        setDoubleValue(LOWERRANGE_ATTR, lowerRange);
     }
 
 
     public Double getLowerRange() {
-        DoubleAttribute attr = (DoubleAttribute) getAttribute(LOWERRANGE_ATTR);
-
-        return attr != null ? (Double) attr.getValue() : null;
+        return getDoubleValue(LOWERRANGE_ATTR);
     }
 
 

http://dive4elements.wald.intevation.org