changeset 360:c065a1a90ba0

Modified the Attribute interface and added a default implementation of Attribute. artifacts/trunk@3417 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 14 Dec 2011 14:03:28 +0000
parents f93edbfcf2bc
children b47d0464f0db
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/state/Attribute.java artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultAttribute.java
diffstat 3 files changed, 73 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Dec 14 12:20:06 2011 +0000
+++ b/ChangeLog	Wed Dec 14 14:03:28 2011 +0000
@@ -1,3 +1,12 @@
+2011-12-14  Ingo Weinzierl <ingo@intevation.de>
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/state/Attribute.java:
+	  Added a setValue(Object) method and modified the signature of toXML()
+	  which now returns a Node.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultAttribute.java:
+	  New. A default implementation of Attribute.
+
 2011-12-14  Ingo Weinzierl <ingo@intevation.de>
 
 	* artifact-database/src/main/java/de/intevation/artifactdatabase/state/Settings.java:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/state/Attribute.java	Wed Dec 14 12:20:06 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/Attribute.java	Wed Dec 14 14:03:28 2011 +0000
@@ -25,10 +25,19 @@
     Object getValue();
 
     /**
+     * Sets the value of this Attribute.
+     *
+     * @param value The new value.
+     */
+    void setValue(Object value);
+
+    /**
      * Transforms this Attribute into XML.
      *
      * @param parent The parent node.
+     *
+     * @return the Node that represents this Attribute.
      */
-    void toXML(Node parent);
+    Node toXML(Node parent);
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultAttribute.java	Wed Dec 14 14:03:28 2011 +0000
@@ -0,0 +1,54 @@
+package de.intevation.artifactdatabase.state;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class DefaultAttribute implements Attribute {
+
+    protected String name;
+
+    protected Object value;
+
+
+    public DefaultAttribute(String name, Object value) {
+        this.name  = name;
+        this.value = value;
+    }
+
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+
+    @Override
+    public Object getValue() {
+        return value;
+    }
+
+
+    @Override
+    public void setValue(Object value) {
+        this.value = value;
+    }
+
+
+    @Override
+    public Node toXML(Node parent) {
+        Document owner = parent.getOwnerDocument();
+        Element   attr = owner.createElement(getName());
+
+        parent.appendChild(attr);
+
+        attr.setTextContent(String.valueOf(getValue()));
+
+        return attr;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org