diff artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultFacet.java @ 295:e5bc48dc3ec3

Facets can write its internal representation to XML using a toXML() method now. artifacts/trunk@2352 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 18 Jul 2011 15:05:20 +0000
parents 7c33cac15134
children 93a774fe2bb4
line wrap: on
line diff
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultFacet.java	Thu Jul 14 14:41:00 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultFacet.java	Mon Jul 18 15:05:20 2011 +0000
@@ -1,8 +1,15 @@
 package de.intevation.artifactdatabase.state;
 
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
 import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.ArtifactNamespaceContext;
 import de.intevation.artifacts.CallContext;
 
+import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
+
 
 /**
  * The default implementation of a Facet.
@@ -72,5 +79,20 @@
             .append(description).append("'")
             .toString();
     }
+
+
+    public Node toXML(Document doc) {
+        ElementCreator ec = new ElementCreator(
+            doc,
+            ArtifactNamespaceContext.NAMESPACE_URI,
+            ArtifactNamespaceContext.NAMESPACE_PREFIX);
+
+        Element facet = ec.create("facet");
+        ec.addAttr(facet, "description", description, true);
+        ec.addAttr(facet, "name", name, true);
+        ec.addAttr(facet, "index", String.valueOf(index), true);
+
+        return facet;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org