1 |
+ |
/* |
2 |
+ |
* i-scream central monitoring system |
3 |
+ |
* Copyright (C) 2000-2002 i-scream |
4 |
+ |
* |
5 |
+ |
* This program is free software; you can redistribute it and/or |
6 |
+ |
* modify it under the terms of the GNU General Public License |
7 |
+ |
* as published by the Free Software Foundation; either version 2 |
8 |
+ |
* of the License, or (at your option) any later version. |
9 |
+ |
* |
10 |
+ |
* This program is distributed in the hope that it will be useful, |
11 |
+ |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
+ |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
+ |
* GNU General Public License for more details. |
14 |
+ |
* |
15 |
+ |
* You should have received a copy of the GNU General Public License |
16 |
+ |
* along with this program; if not, write to the Free Software |
17 |
+ |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 |
+ |
*/ |
19 |
+ |
|
20 |
|
//---PACKAGE DECLARATION--- |
21 |
< |
package uk.ac.ukc.iscream.util; |
21 |
> |
package uk.org.iscream.cms.server.util; |
22 |
|
|
23 |
|
//---IMPORTS--- |
24 |
< |
import java.util.HashMap; |
24 |
> |
import java.util.*; |
25 |
|
|
26 |
|
/** |
27 |
< |
* Object in which to store incoming XML data |
28 |
< |
* to be passed around the CORBA system. |
27 |
> |
* Object in which to store incoming XML data for processing |
28 |
> |
* by a component of the system. |
29 |
|
* |
30 |
|
* @author $Author$ |
31 |
|
* @version $Id$ |
45 |
|
|
46 |
|
//---PUBLIC METHODS--- |
47 |
|
|
48 |
< |
// Add a key and value pair to the HashMap. |
48 |
> |
/** |
49 |
> |
* Add a key and value pair to the HashMap. |
50 |
> |
* |
51 |
> |
* @param key The key value |
52 |
> |
* @param value The value associated with the key |
53 |
> |
*/ |
54 |
|
public synchronized void addParam (String key, String value) { |
55 |
|
_params.put(key, value); |
56 |
|
} |
57 |
|
|
58 |
< |
// Return the value associated with a particular key. |
59 |
< |
// Returns null if the key does not exist, although |
60 |
< |
// this should not necessarily indicate that the key |
61 |
< |
// does not exist. |
58 |
> |
/** |
59 |
> |
* Return the value associated with a particular key. |
60 |
> |
* Returns null if the key does not exist, although |
61 |
> |
* this should not necessarily indicate that the key |
62 |
> |
* does not exist. |
63 |
> |
* |
64 |
> |
* @param key The key to retrieve |
65 |
> |
* @return The value associated with the key, if one exists, otherwise null. |
66 |
> |
*/ |
67 |
|
public synchronized String getParam (String key) { |
68 |
|
return (String) _params.get(key); |
69 |
|
} |
70 |
|
|
71 |
< |
// Print out the entire HashMap. |
72 |
< |
// (Mainly for assisting debugging.) |
71 |
> |
/** |
72 |
> |
* Return a Set of the keys in the HashMap. |
73 |
> |
* |
74 |
> |
* @return a Set of the values in this Packet. |
75 |
> |
*/ |
76 |
> |
public synchronized Set getSet () { |
77 |
> |
return _params.keySet(); |
78 |
> |
} |
79 |
> |
|
80 |
> |
/** |
81 |
> |
* Find if a particular key exists in the HashMap. |
82 |
> |
* |
83 |
> |
* @param key The key to check for |
84 |
> |
* @return whether the key exists |
85 |
> |
*/ |
86 |
> |
public synchronized boolean containsKey(String key){ |
87 |
> |
return _params.containsKey(key); |
88 |
> |
} |
89 |
> |
|
90 |
> |
/** |
91 |
> |
* Print out the entire HashMap. |
92 |
> |
* (Mainly for assisting debugging.) |
93 |
> |
* |
94 |
> |
* @return A String representation of the data in this Packet |
95 |
> |
*/ |
96 |
|
public synchronized String printAll () { |
97 |
|
return _params.toString(); |
98 |
|
} |
101 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
102 |
|
* method to provide clean logging (every class should have this). |
103 |
|
* |
104 |
+ |
* This uses the uk.org.iscream.cms.server.util.NameFormat class |
105 |
+ |
* to format the toString() |
106 |
+ |
* |
107 |
|
* @return the name of this class and its CVS revision |
108 |
|
*/ |
109 |
|
public String toString() { |
110 |
< |
return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
110 |
> |
return FormatName.getName( |
111 |
> |
_name, |
112 |
> |
getClass().getName(), |
113 |
> |
REVISION); |
114 |
|
} |
115 |
|
|
116 |
|
//---PRIVATE METHODS--- |
119 |
|
|
120 |
|
//---ATTRIBUTES--- |
121 |
|
|
122 |
+ |
/** |
123 |
+ |
* A HashMap of parameters |
124 |
+ |
*/ |
125 |
|
private HashMap _params = new HashMap(); |
126 |
+ |
|
127 |
+ |
/** |
128 |
+ |
* This is the friendly identifier of the |
129 |
+ |
* component this class is running in. |
130 |
+ |
* eg, a Filter may be called "filter1", |
131 |
+ |
* If this class does not have an owning |
132 |
+ |
* component, a name from the configuration |
133 |
+ |
* can be placed here. This name could also |
134 |
+ |
* be changed to null for utility classes. |
135 |
+ |
*/ |
136 |
+ |
private String _name = null; |
137 |
|
|
138 |
|
//---STATIC ATTRIBUTES--- |
139 |
|
|