1 |
< |
import java.util.HashMap; |
1 |
> |
//---PACKAGE DECLARATION--- |
2 |
> |
package uk.ac.ukc.iscream.util; |
3 |
|
|
4 |
< |
// Paul Mutton, pjm2@ukc.ac.uk |
4 |
> |
//---IMPORTS--- |
5 |
> |
import java.util.*; |
6 |
|
|
7 |
< |
// Object in which to store incoming XML data |
8 |
< |
// to be passed around the CORBA system. |
7 |
> |
/** |
8 |
> |
* Object in which to store incoming XML data |
9 |
> |
* to be passed around the CORBA system. |
10 |
> |
* |
11 |
> |
* @author $Author$ |
12 |
> |
* @version $Id$ |
13 |
> |
*/ |
14 |
|
public class XMLPacket { |
15 |
|
|
16 |
+ |
//---FINAL ATTRIBUTES--- |
17 |
+ |
|
18 |
+ |
/** |
19 |
+ |
* The current CVS revision of this class |
20 |
+ |
*/ |
21 |
+ |
public final String REVISION = "$Revision$"; |
22 |
+ |
|
23 |
+ |
//---STATIC METHODS--- |
24 |
+ |
|
25 |
+ |
//---CONSTRUCTORS--- |
26 |
+ |
|
27 |
+ |
//---PUBLIC METHODS--- |
28 |
+ |
|
29 |
|
// Add a key and value pair to the HashMap. |
30 |
|
public synchronized void addParam (String key, String value) { |
31 |
< |
params.put(key, value); |
12 |
< |
// debug by println ;-) |
13 |
< |
// System.out.println("Adding to hash: " + key + " = " + value); |
14 |
< |
// end debug code |
31 |
> |
_params.put(key, value); |
32 |
|
} |
33 |
|
|
34 |
|
// Return the value associated with a particular key. |
36 |
|
// this should not necessarily indicate that the key |
37 |
|
// does not exist. |
38 |
|
public synchronized String getParam (String key) { |
39 |
< |
return (String)params.get(key); |
39 |
> |
return (String) _params.get(key); |
40 |
|
} |
41 |
|
|
42 |
+ |
// Return a Set of the keys in the HashMap. |
43 |
+ |
public synchronized Set getSet () { |
44 |
+ |
return _params.keySet(); |
45 |
+ |
} |
46 |
+ |
|
47 |
+ |
// Find if a particular key exists in the HashMap. |
48 |
+ |
public synchronized boolean containsKey(String key){ |
49 |
+ |
return _params.containsKey(key); |
50 |
+ |
} |
51 |
+ |
|
52 |
|
// Print out the entire HashMap. |
53 |
|
// (Mainly for assisting debugging.) |
54 |
|
public synchronized String printAll () { |
55 |
< |
return params.toString(); |
55 |
> |
return _params.toString(); |
56 |
|
} |
57 |
|
|
58 |
< |
private HashMap params = new HashMap(); |
59 |
< |
|
58 |
> |
/** |
59 |
> |
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
60 |
> |
* method to provide clean logging (every class should have this). |
61 |
> |
* |
62 |
> |
* @return the name of this class and its CVS revision |
63 |
> |
*/ |
64 |
> |
public String toString () { |
65 |
> |
return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
66 |
> |
} |
67 |
> |
|
68 |
> |
//---PRIVATE METHODS--- |
69 |
> |
|
70 |
> |
//---ACCESSOR/MUTATOR METHODS--- |
71 |
> |
|
72 |
> |
//---ATTRIBUTES--- |
73 |
> |
|
74 |
> |
private HashMap _params = new HashMap(); |
75 |
> |
|
76 |
> |
//---STATIC ATTRIBUTES--- |
77 |
> |
|
78 |
|
} |