Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSection.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 | 2ae0627f956e |
children | ca8997aa683e |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSection.java Tue Dec 27 11:19:44 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSection.java Tue Dec 27 11:37:23 2011 +0000 @@ -7,7 +7,7 @@ /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ -public class ChartSection extends DefaultSection { +public class ChartSection extends TypeSection { public static final String TITLE_ATTR = "title"; public static final String SUBTITLE_ATTR = "subtitle"; @@ -20,64 +20,32 @@ public void setTitle(String title) { - if (title == null || title.length() == 0) { - return; - } - - Attribute attr = getAttribute(TITLE_ATTR); - if (attr == null) { - attr = new StringAttribute(TITLE_ATTR, title, true); - addAttribute(TITLE_ATTR, attr); - } - else { - attr.setValue(title); - } + setStringValue(TITLE_ATTR, title); } public String getTitle() { - StringAttribute attr = (StringAttribute) getAttribute(TITLE_ATTR); - return attr != null ? (String) attr.getValue() : null; + return getStringValue(TITLE_ATTR); } public void setSubtitle(String subtitle) { - if (subtitle == null || subtitle.length() == 0) { - return; - } - - Attribute attr = getAttribute(SUBTITLE_ATTR); - if (attr == null) { - attr = new StringAttribute(SUBTITLE_ATTR, subtitle, true); - addAttribute(SUBTITLE_ATTR, attr); - } - else { - attr.setValue(subtitle); - } + setStringValue(SUBTITLE_ATTR, subtitle); } public String getSubtitle() { - StringAttribute attr = (StringAttribute) getAttribute(SUBTITLE_ATTR); - return attr != null ? (String) attr.getValue() : null; + return getStringValue(SUBTITLE_ATTR); } public void setDisplayGird(boolean displayGrid) { - Attribute attr = getAttribute(DISPLAYGRID_ATTR); - if (attr == null) { - attr = new BooleanAttribute(DISPLAYGRID_ATTR, displayGrid, true); - addAttribute(DISPLAYGRID_ATTR, attr); - } - else { - attr.setValue(displayGrid); - } + setBooleanValue(DISPLAYGRID_ATTR, displayGrid); } public Boolean getDisplayGrid() { - BooleanAttribute ba = (BooleanAttribute) getAttribute(DISPLAYGRID_ATTR); - return ba != null ? (Boolean) ba.getValue() : null; + return getBooleanValue(DISPLAYGRID_ATTR); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :