annotate artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultFacet.java @ 339:f6beb4ffcf23

Added accidentally ommitted ChangeLog entry for last commit (cosmetics). artifacts/trunk@2914 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 10 Oct 2011 07:40:49 +0000
parents 93a774fe2bb4
children eb1136134d09
rev   line source
226
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.artifactdatabase.state;
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
295
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
3 import org.w3c.dom.Document;
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
4 import org.w3c.dom.Element;
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
5 import org.w3c.dom.Node;
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
6
280
7fbe674d758a Facets got a method that return its required data from the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
7 import de.intevation.artifacts.Artifact;
295
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
8 import de.intevation.artifacts.ArtifactNamespaceContext;
280
7fbe674d758a Facets got a method that return its required data from the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
9 import de.intevation.artifacts.CallContext;
7fbe674d758a Facets got a method that return its required data from the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
10
295
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
11 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
12
226
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 /**
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 * The default implementation of a Facet.
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 *
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 */
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 public class DefaultFacet implements Facet {
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
277
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
21 /** The index of this facet.*/
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
22 protected int index;
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
23
226
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 /** The name of this facet.*/
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 protected String name;
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 /** The description of this facet.*/
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 protected String description;
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
322
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
30 public DefaultFacet() {
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
31 }
226
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 /**
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 * The default constructor to create new Facet objects.
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 *
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 * @param name The name of this new facet.
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 * @param description The description of this new facet.
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 */
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 public DefaultFacet(String name, String description) {
277
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
40 this(0, name, description);
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
41 }
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
42
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
43
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
44 /**
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
45 * The default constructor to create new Facet objects.
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
46 *
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
47 * @param index The index of this new facet.
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
48 * @param name The name of this new facet.
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
49 * @param description The description of this new facet.
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
50 */
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
51 public DefaultFacet(int index, String name, String description) {
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
52 this.index = index;
226
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 this.name = name;
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 this.description = description;
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 }
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
322
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
57 public void set(Facet other) {
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
58 index = other.getIndex();
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
59 name = other.getName();
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
60 description = other.getDescription();
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
61 }
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
62
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
63 public Facet deepCopy() {
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
64 DefaultFacet copy = new DefaultFacet();
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
65 copy.set(this);
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
66 return copy;
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
67 }
93a774fe2bb4 Added deepCopy() method to facets and state data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 295
diff changeset
68
226
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69
277
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
70 public int getIndex() {
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
71 return index;
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
72 }
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
73
0a579b71496b Facets have indices now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
74
226
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 public String getName() {
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 return name;
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 }
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 public String getDescription() {
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 return description;
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 }
280
7fbe674d758a Facets got a method that return its required data from the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
83
7fbe674d758a Facets got a method that return its required data from the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
84
7fbe674d758a Facets got a method that return its required data from the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
85 public Object getData(Artifact artifact, CallContext context) {
7fbe674d758a Facets got a method that return its required data from the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
86 return null;
7fbe674d758a Facets got a method that return its required data from the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 277
diff changeset
87 }
283
7c33cac15134 Added DefaultFacet.toString() method to help debugging.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 280
diff changeset
88
7c33cac15134 Added DefaultFacet.toString() method to help debugging.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 280
diff changeset
89 public String toString() {
7c33cac15134 Added DefaultFacet.toString() method to help debugging.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 280
diff changeset
90 return new StringBuilder("name = '")
7c33cac15134 Added DefaultFacet.toString() method to help debugging.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 280
diff changeset
91 .append(name).append("', index = ")
7c33cac15134 Added DefaultFacet.toString() method to help debugging.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 280
diff changeset
92 .append(index).append(", description = '")
7c33cac15134 Added DefaultFacet.toString() method to help debugging.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 280
diff changeset
93 .append(description).append("'")
7c33cac15134 Added DefaultFacet.toString() method to help debugging.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 280
diff changeset
94 .toString();
7c33cac15134 Added DefaultFacet.toString() method to help debugging.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 280
diff changeset
95 }
295
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
96
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
97
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
98 public Node toXML(Document doc) {
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
99 ElementCreator ec = new ElementCreator(
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
100 doc,
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
101 ArtifactNamespaceContext.NAMESPACE_URI,
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
102 ArtifactNamespaceContext.NAMESPACE_PREFIX);
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
103
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
104 Element facet = ec.create("facet");
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
105 ec.addAttr(facet, "description", description, true);
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
106 ec.addAttr(facet, "name", name, true);
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
107 ec.addAttr(facet, "index", String.valueOf(index), true);
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
108
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
109 return facet;
e5bc48dc3ec3 Facets can write its internal representation to XML using a toXML() method now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 283
diff changeset
110 }
226
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 }
41404961c804 Added support for facets - facets of output modes are read from configuration now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org