Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/org/dive4elements/artifactdatabase/DefaultArtifactContext.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/DefaultArtifactContext.java@b77465617071 |
children | 415df0fc4fa1 |
comparison
equal
deleted
inserted
replaced
472:783cc1b6b615 | 473:d0ac790a6c89 |
---|---|
1 /* | |
2 * Copyright (c) 2010 by Intevation GmbH | |
3 * | |
4 * This program is free software under the LGPL (>=v2.1) | |
5 * Read the file LGPL.txt coming with the software for details | |
6 * or visit http://www.gnu.org/licenses/ if it does not exist. | |
7 */ | |
8 | |
9 package de.intevation.artifactdatabase; | |
10 | |
11 import java.util.HashMap; | |
12 | |
13 import org.w3c.dom.Document; | |
14 | |
15 import de.intevation.artifacts.GlobalContext; | |
16 | |
17 /** | |
18 * Default implementation of the context. | |
19 * Besides of the configuration it hosts a map to store key/value pairs. | |
20 * | |
21 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> | |
22 */ | |
23 public class DefaultArtifactContext implements GlobalContext | |
24 { | |
25 /** | |
26 * The global configuration document of the artifact database. | |
27 */ | |
28 protected Document config; | |
29 | |
30 /** | |
31 * Custom key/value pairs to be used globally in the whole server. | |
32 */ | |
33 protected HashMap map; | |
34 | |
35 /** | |
36 * Default constructor | |
37 */ | |
38 public DefaultArtifactContext() { | |
39 this(null); | |
40 } | |
41 | |
42 /** | |
43 * Constructor to create a context with a given global | |
44 * configuration document and an empty map of custom | |
45 * key/value pairs. | |
46 * @param config | |
47 */ | |
48 public DefaultArtifactContext(Document config) { | |
49 this.config = config; | |
50 map = new HashMap(); | |
51 } | |
52 | |
53 /** | |
54 * Fetch a custom value from the global key/value map using | |
55 * a given key. | |
56 * @param key The key. | |
57 * @return The stored value or null if no value was found under | |
58 * this key. | |
59 */ | |
60 public synchronized Object get(Object key) { | |
61 return map.get(key); | |
62 } | |
63 | |
64 /** | |
65 * Store a custom key/value pair in the global map. | |
66 * @param key The key to store | |
67 * @param value The value to store | |
68 * @return The old value registered under the key or null | |
69 * if none wa there before. | |
70 */ | |
71 public synchronized Object put(Object key, Object value) { | |
72 return map.put(key, value); | |
73 } | |
74 | |
75 /** | |
76 * Returns a reference to the global configuration document. | |
77 * @return The global configuration document. | |
78 */ | |
79 public Document getConfig() { | |
80 return config; | |
81 } | |
82 } | |
83 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |