comparison artifact-database/src/main/java/org/dive4elements/artifactdatabase/state/ArtifactAndFacet.java @ 473:d0ac790a6c89 dive4elements-move

Moved directories to org.dive4elements
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 10:57:18 +0200
parents artifact-database/src/main/java/de/intevation/artifactdatabase/state/ArtifactAndFacet.java@71ff234713a6
children 415df0fc4fa1
comparison
equal deleted inserted replaced
472:783cc1b6b615 473:d0ac790a6c89
1 package de.intevation.artifactdatabase.state;
2
3 import java.util.List;
4
5 import de.intevation.artifacts.Artifact;
6 import de.intevation.artifacts.CallContext;
7 import de.intevation.artifacts.DataProvider;
8
9
10 /**
11 * A bundle of a "native" Facet and its Artifact.
12 */
13 public class ArtifactAndFacet implements DataProvider {
14 /** The Artifact. */
15 protected Artifact artifact;
16
17 /** The (native) facet. */
18 protected Facet facet;
19
20 /** An alternative facet description that might be set from outside. */
21 protected String facetDescription;
22
23
24 /** Trivial constructor. */
25 public ArtifactAndFacet(
26 Artifact a,
27 Facet f
28 ) {
29 this.artifact = a;
30 this.facet = f;
31 }
32
33
34 /** Get data (to plot). */
35 public Object getData(CallContext context) {
36 return facet.getData(artifact, context);
37 }
38
39
40 /** Get data (for other facet). */
41 @Override
42 public Object provideData(Object key, Object param, CallContext context) {
43 return facet.provideBlackboardData(artifact, key, param, context);
44 }
45
46
47 /** (Maybe) Register on blackboard (depending on facet). */
48 @Override
49 public void register(CallContext context) {
50 List keys = facet.getDataProviderKeys(this.artifact, context);
51 if (keys == null) {
52 return;
53 }
54 for (Object key: keys) {
55 context.registerDataProvider(key, this);
56 }
57 }
58
59
60 /** Access the artifact. */
61 public Artifact getArtifact() {
62 return artifact;
63 }
64
65
66 /** Access the (native) facet. */
67 public Facet getFacet() {
68 return facet;
69 }
70
71
72 /** Shortcut to facets name. */
73 public String getFacetName() {
74 return facet.getName();
75 }
76
77
78 /**
79 * Returns the description for a facet. The return value depends on the
80 * internal <i>facetDescription</i> instance variable. If this has been set
81 * by setFacetDescription, this value is returned, otherwise the return
82 * value of facet.getDescription().
83 */
84 public String getFacetDescription() {
85 if (facetDescription == null) {
86 return facet.getDescription();
87 }
88
89 return facetDescription;
90 }
91
92
93 public void setFacetDescription(String facetDescription) {
94 this.facetDescription = facetDescription;
95 }
96 }
97 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org