Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/state/StateEngine.java @ 104:26bfff409dd3
Added interfaces and engines used in concrete artifact packages.
artifacts/trunk@1289 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 03 Feb 2011 18:00:41 +0000 |
parents | |
children | ece0fdb07975 |
comparison
equal
deleted
inserted
replaced
103:1282cf96d3eb | 104:26bfff409dd3 |
---|---|
1 package de.intevation.artifactdatabase.state; | |
2 | |
3 import java.util.HashMap; | |
4 import java.util.List; | |
5 import java.util.Map; | |
6 | |
7 import org.apache.log4j.Logger; | |
8 | |
9 /** | |
10 * The StateEngine stores all states for each Artifact. | |
11 * | |
12 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
13 */ | |
14 public class StateEngine { | |
15 | |
16 /** The logger used in this class. */ | |
17 private static Logger logger = Logger.getLogger(StateEngine.class); | |
18 | |
19 /** | |
20 * A map that contains the states of the artifacts. The key of this map is | |
21 * the name of an artifact, its value is a list of all states the artifact | |
22 * can reach. | |
23 */ | |
24 protected Map<String, List> states; | |
25 | |
26 | |
27 /** | |
28 * The default constructor. | |
29 */ | |
30 public StateEngine() { | |
31 states = new HashMap<String, List>(); | |
32 } | |
33 | |
34 | |
35 /** | |
36 * Add new states for a specific artifact. | |
37 * | |
38 * @param artifact The name of the artifact. | |
39 * @param states A list of states that the artifact can reach. | |
40 * | |
41 * @return true, if the states were added, otherwise false. | |
42 */ | |
43 public boolean addStates(String artifact, List states) { | |
44 List tmp = this.states.get(artifact); | |
45 | |
46 if (tmp != null) { | |
47 logger.info( | |
48 "States for the artifact '" + artifact + "' already stored."); | |
49 | |
50 return false; | |
51 } | |
52 | |
53 logger.debug("Add new states for the artifact '" + artifact + "'"); | |
54 return this.states.put(artifact, states) != null; | |
55 } | |
56 } | |
57 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |