Mercurial > dive4elements > river
diff gwt-client/src/main/java/org/dive4elements/river/client/shared/model/AttributedTheme.java @ 9416:05405292a7ca
Navigationtheme panel now shows themes of dWt and WQ charts grayed out, if the current station is outside the valid range of the theme.
author | gernotbelger |
---|---|
date | Thu, 16 Aug 2018 16:28:03 +0200 |
parents | ea9eef426962 |
children |
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/AttributedTheme.java Thu Aug 16 16:27:53 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/AttributedTheme.java Thu Aug 16 16:28:03 2018 +0200 @@ -18,58 +18,77 @@ */ public class AttributedTheme implements Theme { - protected Map<String, String> attributes; + private static final long serialVersionUID = 1L; + + private Map<String, String> attributes; /** CollectionItem associated with this facet/themes artifact. */ - protected CollectionItem collectionItem; + private CollectionItem collectionItem; public AttributedTheme() { this.attributes = new HashMap<String, String>(); } + /** Remark: only here so attributes is not final and serialization is happy */ + public void setAttributes(final Map<String, String> attributes) { + this.attributes = attributes; + } public Set<String> getKeys() { - return attributes.keySet(); + return this.attributes.keySet(); } - - public void addAttr(String name, String value) { + public void addAttr(final String name, final String value) { if (name != null && value != null) { - attributes.put(name, value); + this.attributes.put(name, value); } } - - public String getAttr(String name) { - return attributes.get(name); + public String getAttr(final String name) { + return this.attributes.get(name); } - - public Integer getAttrAsInt(String name) { - String attr = getAttr(name); + public Integer getAttrAsInt(final String name) { + final String attr = getAttr(name); if (attr != null && attr.length() > 0) { try { return Integer.parseInt(attr); } - catch (NumberFormatException nfe) { + catch (final NumberFormatException nfe) { + nfe.printStackTrace(); } } return null; } + public Double getAttrAsDouble(final String name) { - public boolean getAttrAsBoolean(String name) { - String attr = getAttr(name); + final String attr = getAttr(name); + if (attr == null || attr.isEmpty()) + return null; + + try { + return Double.parseDouble(attr); + } + catch (final NumberFormatException nfe) { + nfe.printStackTrace(); + return null; + } + } + + public boolean getAttrAsBoolean(final String name) { + final String attr = getAttr(name); if (attr != null) { try { - int num = Integer.valueOf(attr); + final int num = Integer.valueOf(attr); return num > 0; } - catch (NumberFormatException nfe) { + catch (final NumberFormatException nfe) { // do nothing + nfe.printStackTrace(); } } @@ -79,21 +98,21 @@ @Override public int getPosition() { - Integer pos = getAttrAsInt("pos"); + final Integer pos = getAttrAsInt("pos"); return pos != null ? pos.intValue() : -1; } @Override - public void setPosition(int pos) { + public void setPosition(final int pos) { addAttr("pos", String.valueOf(pos)); } @Override public int getIndex() { - Integer idx = getAttrAsInt("index"); + final Integer idx = getAttrAsInt("index"); return idx != null ? idx.intValue() : -1; } @@ -106,7 +125,7 @@ @Override - public void setActive(int active) { + public void setActive(final int active) { addAttr("active", String.valueOf(active)); } @@ -130,7 +149,7 @@ @Override - public void setDescription(String description) { + public void setDescription(final String description) { if (description != null && description.length() > 0) { addAttr("description", description); } @@ -144,18 +163,18 @@ @Override - public void setVisible(int visible) { + public void setVisible(final int visible) { addAttr("visible", String.valueOf(visible)); } @Override - public boolean equals(Object o) { + public boolean equals(final Object o) { if (!(o instanceof AttributedTheme)) { return false; } - AttributedTheme other = (AttributedTheme) o; + final AttributedTheme other = (AttributedTheme) o; if (other.getPosition() != getPosition()) { return false; @@ -188,18 +207,15 @@ return true; } - /** Get the CollectionItem representing the facets artifact. */ @Override public CollectionItem getCollectionItem() { - return collectionItem; + return this.collectionItem; } - /** Set the CollectionItem representing the facets artifact. */ @Override - public void setCollectionItem(CollectionItem ci) { + public void setCollectionItem(final CollectionItem ci) { this.collectionItem = ci; } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : +} \ No newline at end of file