1 |
tdb |
1.3 |
//---PACKAGE DECLARATION--- |
2 |
tdb |
1.12 |
package uk.org.iscream.cms.server.util; |
3 |
tdb |
1.3 |
|
4 |
|
|
//---IMPORTS--- |
5 |
pjm2 |
1.7 |
import java.util.*; |
6 |
pjm2 |
1.1 |
|
7 |
tdb |
1.3 |
/** |
8 |
tdb |
1.10 |
* Object in which to store incoming XML data for processing |
9 |
|
|
* by a component of the system. |
10 |
tdb |
1.3 |
* |
11 |
tdb |
1.11 |
* @author $Author: tdb1 $ |
12 |
tdb |
1.12 |
* @version $Id: XMLPacket.java,v 1.11 2001/03/14 23:25:29 tdb1 Exp $ |
13 |
tdb |
1.3 |
*/ |
14 |
|
|
public class XMLPacket { |
15 |
|
|
|
16 |
|
|
//---FINAL ATTRIBUTES--- |
17 |
|
|
|
18 |
|
|
/** |
19 |
|
|
* The current CVS revision of this class |
20 |
|
|
*/ |
21 |
tdb |
1.12 |
public final String REVISION = "$Revision: 1.11 $"; |
22 |
tdb |
1.3 |
|
23 |
|
|
//---STATIC METHODS--- |
24 |
|
|
|
25 |
|
|
//---CONSTRUCTORS--- |
26 |
pjm2 |
1.1 |
|
27 |
tdb |
1.3 |
//---PUBLIC METHODS--- |
28 |
pjm2 |
1.1 |
|
29 |
ajm |
1.9 |
/** |
30 |
|
|
* Add a key and value pair to the HashMap. |
31 |
tdb |
1.10 |
* |
32 |
|
|
* @param key The key value |
33 |
|
|
* @param value The value associated with the key |
34 |
ajm |
1.9 |
*/ |
35 |
pjm2 |
1.1 |
public synchronized void addParam (String key, String value) { |
36 |
pjm2 |
1.6 |
_params.put(key, value); |
37 |
pjm2 |
1.1 |
} |
38 |
|
|
|
39 |
ajm |
1.9 |
/** |
40 |
|
|
* Return the value associated with a particular key. |
41 |
|
|
* Returns null if the key does not exist, although |
42 |
|
|
* this should not necessarily indicate that the key |
43 |
|
|
* does not exist. |
44 |
tdb |
1.10 |
* |
45 |
|
|
* @param key The key to retrieve |
46 |
|
|
* @return The value associated with the key, if one exists, otherwise null. |
47 |
ajm |
1.9 |
*/ |
48 |
pjm2 |
1.1 |
public synchronized String getParam (String key) { |
49 |
tdb |
1.4 |
return (String) _params.get(key); |
50 |
pjm2 |
1.1 |
} |
51 |
|
|
|
52 |
ajm |
1.9 |
/** |
53 |
|
|
* Return a Set of the keys in the HashMap. |
54 |
tdb |
1.10 |
* |
55 |
|
|
* @return a Set of the values in this Packet. |
56 |
ajm |
1.9 |
*/ |
57 |
pjm2 |
1.7 |
public synchronized Set getSet () { |
58 |
|
|
return _params.keySet(); |
59 |
pjm2 |
1.8 |
} |
60 |
|
|
|
61 |
ajm |
1.9 |
/** |
62 |
|
|
* Find if a particular key exists in the HashMap. |
63 |
tdb |
1.10 |
* |
64 |
|
|
* @param key The key to check for |
65 |
|
|
* @return whether the key exists |
66 |
ajm |
1.9 |
*/ |
67 |
pjm2 |
1.8 |
public synchronized boolean containsKey(String key){ |
68 |
|
|
return _params.containsKey(key); |
69 |
pjm2 |
1.7 |
} |
70 |
|
|
|
71 |
ajm |
1.9 |
/** |
72 |
|
|
* Print out the entire HashMap. |
73 |
|
|
* (Mainly for assisting debugging.) |
74 |
tdb |
1.10 |
* |
75 |
|
|
* @return A String representation of the data in this Packet |
76 |
ajm |
1.9 |
*/ |
77 |
pjm2 |
1.2 |
public synchronized String printAll () { |
78 |
tdb |
1.4 |
return _params.toString(); |
79 |
pjm2 |
1.1 |
} |
80 |
|
|
|
81 |
tdb |
1.3 |
/** |
82 |
|
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
83 |
|
|
* method to provide clean logging (every class should have this). |
84 |
|
|
* |
85 |
tdb |
1.12 |
* This uses the uk.org.iscream.cms.server.util.NameFormat class |
86 |
ajm |
1.9 |
* to format the toString() |
87 |
|
|
* |
88 |
tdb |
1.3 |
* @return the name of this class and its CVS revision |
89 |
|
|
*/ |
90 |
ajm |
1.9 |
public String toString() { |
91 |
|
|
return FormatName.getName( |
92 |
|
|
_name, |
93 |
|
|
getClass().getName(), |
94 |
|
|
REVISION); |
95 |
tdb |
1.3 |
} |
96 |
|
|
|
97 |
|
|
//---PRIVATE METHODS--- |
98 |
|
|
|
99 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
100 |
|
|
|
101 |
|
|
//---ATTRIBUTES--- |
102 |
|
|
|
103 |
tdb |
1.10 |
/** |
104 |
|
|
* A HashMap of parameters |
105 |
|
|
*/ |
106 |
tdb |
1.4 |
private HashMap _params = new HashMap(); |
107 |
ajm |
1.9 |
|
108 |
|
|
/** |
109 |
|
|
* This is the friendly identifier of the |
110 |
|
|
* component this class is running in. |
111 |
|
|
* eg, a Filter may be called "filter1", |
112 |
|
|
* If this class does not have an owning |
113 |
|
|
* component, a name from the configuration |
114 |
|
|
* can be placed here. This name could also |
115 |
|
|
* be changed to null for utility classes. |
116 |
|
|
*/ |
117 |
|
|
private String _name = null; |
118 |
tdb |
1.3 |
|
119 |
|
|
//---STATIC ATTRIBUTES--- |
120 |
|
|
|
121 |
pjm2 |
1.6 |
} |