--- projects/cms/source/util/uk/org/iscream/cms/util/XMLPacket.java 2000/11/23 09:36:07 1.2 +++ projects/cms/source/util/uk/org/iscream/cms/util/XMLPacket.java 2000/12/05 12:26:22 1.7 @@ -1,17 +1,34 @@ -import java.util.HashMap; +//---PACKAGE DECLARATION--- +package uk.ac.ukc.iscream.util; -// Paul Mutton, pjm2@ukc.ac.uk +//---IMPORTS--- +import java.util.*; -// Object in which to store incoming XML data -// to be passed around the CORBA system. +/** + * Object in which to store incoming XML data + * to be passed around the CORBA system. + * + * @author $Author: pjm2 $ + * @version $Id: XMLPacket.java,v 1.7 2000/12/05 12:26:22 pjm2 Exp $ + */ public class XMLPacket { +//---FINAL ATTRIBUTES--- + + /** + * The current CVS revision of this class + */ + public final String REVISION = "$Revision: 1.7 $"; + +//---STATIC METHODS--- + +//---CONSTRUCTORS--- + +//---PUBLIC METHODS--- + // Add a key and value pair to the HashMap. public synchronized void addParam (String key, String value) { - params.put(key, value); - // debug by println ;-) - // System.out.println("Adding to hash: " + key + " = " + value); - // end debug code + _params.put(key, value); } // Return the value associated with a particular key. @@ -19,15 +36,38 @@ public class XMLPacket { // this should not necessarily indicate that the key // does not exist. public synchronized String getParam (String key) { - return (String)params.get(key); + return (String) _params.get(key); } + // Return a Set of the keys in the HashMap. + public synchronized Set getSet () { + return _params.keySet(); + } + // Print out the entire HashMap. // (Mainly for assisting debugging.) public synchronized String printAll () { - return params.toString(); + return _params.toString(); } - private HashMap params = new HashMap(); - + /** + * Overrides the {@link java.lang.Object#toString() Object.toString()} + * method to provide clean logging (every class should have this). + * + * @return the name of this class and its CVS revision + */ + public String toString () { + return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")"; + } + +//---PRIVATE METHODS--- + +//---ACCESSOR/MUTATOR METHODS--- + +//---ATTRIBUTES--- + + private HashMap _params = new HashMap(); + +//---STATIC ATTRIBUTES--- + }