ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/util/uk/org/iscream/cms/util/XMLPacket.java
(Generate patch)

Comparing projects/cms/source/util/uk/org/iscream/cms/util/XMLPacket.java (file contents):
Revision 1.1 by pjm2, Wed Nov 22 08:40:53 2000 UTC vs.
Revision 1.11 by tdb, Wed Mar 14 23:25:29 2001 UTC

# Line 1 | Line 1
1 < import java.util.HashMap;
1 > //---PACKAGE DECLARATION---
2 > package uk.org.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 for processing
9 > * by a component of the system.
10 > *
11 > * @author  $Author$
12 > * @version $Id$
13 > */
14   public class XMLPacket {
15  
16 <    // Add a key and value pair to the HashMap.
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 >    /**
30 >     * Add a key and value pair to the HashMap.
31 >     *
32 >     * @param key The key value
33 >     * @param value The value associated with the key
34 >     */
35      public synchronized void addParam (String key, String value) {
36 <        params.put(key, value);        
12 <        // debug by println ;-)
13 <        // System.out.println("Adding to hash: " + key + " = " + value);
14 <        // end debug code
36 >        _params.put(key, value);
37      }
38      
39 <    // Return the value associated with a particular key.
40 <    // Returns null if the key does not exist, although
41 <    // this should not necessarily indicate that the key
42 <    // does not exist.
39 >    /**
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 >     *
45 >     * @param key The key to retrieve
46 >     * @return The value associated with the key, if one exists, otherwise null.
47 >     */
48      public synchronized String getParam (String key) {
49 <        return (String)params.get(key);
49 >        return (String) _params.get(key);
50      }
51      
52 <    // Print out the entire HashMap.
53 <    // (Mainly for assisting debugging.)
54 <    public synchronized void printAll () {
55 <        System.out.println(params);
52 >    /**
53 >     * Return a Set of the keys in the HashMap.
54 >     *
55 >     * @return a Set of the values in this Packet.
56 >     */
57 >    public synchronized Set getSet () {
58 >        return _params.keySet();
59      }
30
31    private HashMap params = new HashMap();  
60      
61 +    /**
62 +     * Find if a particular key exists in the HashMap.
63 +     *
64 +     * @param key The key to check for
65 +     * @return whether the key exists
66 +     */
67 +    public synchronized boolean containsKey(String key){
68 +        return _params.containsKey(key);
69 +    }
70 +    
71 +    /**
72 +     * Print out the entire HashMap.
73 +     * (Mainly for assisting debugging.)
74 +     *
75 +     * @return A String representation of the data in this Packet
76 +     */
77 +    public synchronized String printAll () {
78 +        return _params.toString();
79 +    }
80 +
81 +    /**
82 +     * Overrides the {@link java.lang.Object#toString() Object.toString()}
83 +     * method to provide clean logging (every class should have this).
84 +     *
85 +     * This uses the uk.org.iscream.util.NameFormat class
86 +     * to format the toString()
87 +     *
88 +     * @return the name of this class and its CVS revision
89 +     */
90 +    public String toString() {
91 +        return FormatName.getName(
92 +            _name,
93 +            getClass().getName(),
94 +            REVISION);
95 +    }
96 +
97 + //---PRIVATE METHODS---
98 +
99 + //---ACCESSOR/MUTATOR METHODS---
100 +
101 + //---ATTRIBUTES---
102 +
103 +    /**
104 +     * A HashMap of parameters
105 +     */
106 +    private HashMap _params = new HashMap();
107 +
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 +
119 + //---STATIC ATTRIBUTES---
120 +
121   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines