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.2 by pjm2, Thu Nov 23 09:36:07 2000 UTC vs.
Revision 1.9 by ajm, Tue Dec 12 20:44:30 2000 UTC

# Line 1 | Line 1
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 <    // 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      public synchronized void addParam (String key, String value) {
33 <        params.put(key, value);        
12 <        // debug by println ;-)
13 <        // System.out.println("Adding to hash: " + key + " = " + value);
14 <        // end debug code
33 >        _params.put(key, value);
34      }
35      
36 <    // Return the value associated with a particular key.
37 <    // Returns null if the key does not exist, although
38 <    // this should not necessarily indicate that the key
39 <    // does not exist.
36 >    /**
37 >     * Return the value associated with a particular key.
38 >     * Returns null if the key does not exist, although
39 >     * this should not necessarily indicate that the key
40 >     * does not exist.
41 >     */
42      public synchronized String getParam (String key) {
43 <        return (String)params.get(key);
43 >        return (String) _params.get(key);
44      }
45      
46 <    // Print out the entire HashMap.
47 <    // (Mainly for assisting debugging.)
46 >    /**
47 >     * Return a Set of the keys in the HashMap.
48 >     */
49 >    public synchronized Set getSet () {
50 >        return _params.keySet();
51 >    }
52 >    
53 >    /**
54 >     * Find if a particular key exists in the HashMap.
55 >     */
56 >    public synchronized boolean containsKey(String key){
57 >        return _params.containsKey(key);
58 >    }
59 >    
60 >    /**
61 >     * Print out the entire HashMap.
62 >     * (Mainly for assisting debugging.)
63 >     */
64      public synchronized String printAll () {
65 <        return params.toString();
65 >        return _params.toString();
66      }
67  
68 <    private HashMap params = new HashMap();  
69 <    
68 >    /**
69 >     * Overrides the {@link java.lang.Object#toString() Object.toString()}
70 >     * method to provide clean logging (every class should have this).
71 >     *
72 >     * This uses the uk.ac.ukc.iscream.util.NameFormat class
73 >     * to format the toString()
74 >     *
75 >     * @return the name of this class and its CVS revision
76 >     */
77 >    public String toString() {
78 >        return FormatName.getName(
79 >            _name,
80 >            getClass().getName(),
81 >            REVISION);
82 >    }
83 >
84 > //---PRIVATE METHODS---
85 >
86 > //---ACCESSOR/MUTATOR METHODS---
87 >
88 > //---ATTRIBUTES---
89 >
90 >    private HashMap _params = new HashMap();
91 >
92 >    /**
93 >     * This is the friendly identifier of the
94 >     * component this class is running in.
95 >     * eg, a Filter may be called "filter1",
96 >     * If this class does not have an owning
97 >     * component,  a name from the configuration
98 >     * can be placed here.  This name could also
99 >     * be changed to null for utility classes.
100 >     */
101 >    private String _name = null;
102 >
103 > //---STATIC ATTRIBUTES---
104 >
105   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines