KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > context > AbstractMapBasedContext


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.context;
14
15 import java.util.HashMap JavaDoc;
16 import java.util.Map JavaDoc;
17
18
19 /**
20  * This is a simple Map based implementation. Ignores scopes!
21  * @author Philipp Bracher
22  * @version $Revision: 6341 $ ($Author: philipp $)
23  */

24 public abstract class AbstractMapBasedContext extends AbstractContext {
25
26     /**
27      * The map containing the values
28      */

29     private Map JavaDoc map = new HashMap JavaDoc();
30     
31
32     public AbstractMapBasedContext() {
33     }
34
35     public AbstractMapBasedContext(Map JavaDoc map) {
36         super();
37         this.map = map;
38     }
39
40     /**
41      * Use the Map.put()
42      */

43     public void setAttribute(String JavaDoc name, Object JavaDoc value, int scope) {
44         this.map.put(name, value);
45     }
46
47     /**
48      * Use the Map.get()
49      */

50     public Object JavaDoc getAttribute(String JavaDoc name, int scope) {
51         return this.map.get(name);
52     }
53
54     /**
55      * use the Map.remove()
56      */

57     public void removeAttribute(String JavaDoc name, int scope) {
58         this.map.remove(name);
59     }
60
61     /**
62      * Ignore scope and return the inner map
63      */

64     public Map JavaDoc getAttributes(int scope) {
65         return this.getAttributes();
66     }
67
68     /**
69      * Returns the inner map
70      */

71     public Map JavaDoc getAttributes() {
72         return this.map;
73     }
74
75     
76     public Map JavaDoc getMap() {
77         return map;
78     }
79
80     
81     public void setMap(Map JavaDoc map) {
82         this.map = map;
83     }
84
85 }
86
Popular Tags