comparison artifact-database/src/main/java/de/intevation/artifactdatabase/state/ArtifactAndFacet.java @ 355:6bd37edd9a80

Added handy implementation of a DataProvider. artifacts/trunk@3333 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 30 Nov 2011 08:28:04 +0000
parents
children 079ab7c971a4
comparison
equal deleted inserted replaced
354:c83519249fea 355:6bd37edd9a80
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 /** The (native) facet. */
17 protected Facet facet;
18
19
20 /** Trivial constructor. */
21 public ArtifactAndFacet(
22 Artifact a,
23 Facet f
24 ) {
25 this.artifact = a;
26 this.facet = f;
27 }
28
29
30 /** Get data (to plot). */
31 public Object getData(CallContext context) {
32 return facet.getData(artifact, context);
33 }
34
35
36 /** Get data (for other facet). */
37 public Object provideData(Object key, Object param, CallContext context) {
38 return facet.provideBlackboardData(artifact, key, param, context);
39 }
40
41
42 /** (Maybe) Register on blackboard (depending on facet). */
43 public void register(CallContext context) {
44 List keys = facet.getDataProviderKeys();
45 if (keys == null) {
46 return;
47 }
48 for (Object key: keys) {
49 context.registerDataProvider(key, this);
50 }
51 }
52
53
54 /** Access the artifact. */
55 public Artifact getArtifact() {
56 return artifact;
57 }
58
59
60 /** Access the (native) facet. */
61 public Facet getFacet() {
62 return facet;
63 }
64
65
66 /** Shortcut to facets name. */
67 public String getFacetName() {
68 return facet.getName();
69 }
70 }
71 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org