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
Revision: 1.13
Committed: Sat May 18 18:16:04 2002 UTC (21 years, 11 months ago) by tdb
Branch: MAIN
Changes since 1.12: +22 -3 lines
Log Message:
i-scream is now licensed under the GPL. I've added the GPL headers to every
source file, and put a full copy of the license in the appropriate places.
I think I've covered everything. This is going to be a mad commit ;)

File Contents

# User Rev Content
1 tdb 1.13 /*
2     * i-scream central monitoring system
3     * Copyright (C) 2000-2002 i-scream
4     *
5     * This program is free software; you can redistribute it and/or
6     * modify it under the terms of the GNU General Public License
7     * as published by the Free Software Foundation; either version 2
8     * of the License, or (at your option) any later version.
9     *
10     * This program is distributed in the hope that it will be useful,
11     * but WITHOUT ANY WARRANTY; without even the implied warranty of
12     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     * GNU General Public License for more details.
14     *
15     * You should have received a copy of the GNU General Public License
16     * along with this program; if not, write to the Free Software
17     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18     */
19    
20 tdb 1.3 //---PACKAGE DECLARATION---
21 tdb 1.12 package uk.org.iscream.cms.server.util;
22 tdb 1.3
23     //---IMPORTS---
24 pjm2 1.7 import java.util.*;
25 pjm2 1.1
26 tdb 1.3 /**
27 tdb 1.10 * Object in which to store incoming XML data for processing
28     * by a component of the system.
29 tdb 1.3 *
30 tdb 1.13 * @author $Author: tdb $
31     * @version $Id: XMLPacket.java,v 1.12 2001/05/29 17:02:35 tdb Exp $
32 tdb 1.3 */
33     public class XMLPacket {
34    
35     //---FINAL ATTRIBUTES---
36    
37     /**
38     * The current CVS revision of this class
39     */
40 tdb 1.13 public final String REVISION = "$Revision: 1.12 $";
41 tdb 1.3
42     //---STATIC METHODS---
43    
44     //---CONSTRUCTORS---
45 pjm2 1.1
46 tdb 1.3 //---PUBLIC METHODS---
47 pjm2 1.1
48 ajm 1.9 /**
49     * Add a key and value pair to the HashMap.
50 tdb 1.10 *
51     * @param key The key value
52     * @param value The value associated with the key
53 ajm 1.9 */
54 pjm2 1.1 public synchronized void addParam (String key, String value) {
55 pjm2 1.6 _params.put(key, value);
56 pjm2 1.1 }
57    
58 ajm 1.9 /**
59     * Return the value associated with a particular key.
60     * Returns null if the key does not exist, although
61     * this should not necessarily indicate that the key
62     * does not exist.
63 tdb 1.10 *
64     * @param key The key to retrieve
65     * @return The value associated with the key, if one exists, otherwise null.
66 ajm 1.9 */
67 pjm2 1.1 public synchronized String getParam (String key) {
68 tdb 1.4 return (String) _params.get(key);
69 pjm2 1.1 }
70    
71 ajm 1.9 /**
72     * Return a Set of the keys in the HashMap.
73 tdb 1.10 *
74     * @return a Set of the values in this Packet.
75 ajm 1.9 */
76 pjm2 1.7 public synchronized Set getSet () {
77     return _params.keySet();
78 pjm2 1.8 }
79    
80 ajm 1.9 /**
81     * Find if a particular key exists in the HashMap.
82 tdb 1.10 *
83     * @param key The key to check for
84     * @return whether the key exists
85 ajm 1.9 */
86 pjm2 1.8 public synchronized boolean containsKey(String key){
87     return _params.containsKey(key);
88 pjm2 1.7 }
89    
90 ajm 1.9 /**
91     * Print out the entire HashMap.
92     * (Mainly for assisting debugging.)
93 tdb 1.10 *
94     * @return A String representation of the data in this Packet
95 ajm 1.9 */
96 pjm2 1.2 public synchronized String printAll () {
97 tdb 1.4 return _params.toString();
98 pjm2 1.1 }
99    
100 tdb 1.3 /**
101     * Overrides the {@link java.lang.Object#toString() Object.toString()}
102     * method to provide clean logging (every class should have this).
103     *
104 tdb 1.12 * This uses the uk.org.iscream.cms.server.util.NameFormat class
105 ajm 1.9 * to format the toString()
106     *
107 tdb 1.3 * @return the name of this class and its CVS revision
108     */
109 ajm 1.9 public String toString() {
110     return FormatName.getName(
111     _name,
112     getClass().getName(),
113     REVISION);
114 tdb 1.3 }
115    
116     //---PRIVATE METHODS---
117    
118     //---ACCESSOR/MUTATOR METHODS---
119    
120     //---ATTRIBUTES---
121    
122 tdb 1.10 /**
123     * A HashMap of parameters
124     */
125 tdb 1.4 private HashMap _params = new HashMap();
126 ajm 1.9
127     /**
128     * This is the friendly identifier of the
129     * component this class is running in.
130     * eg, a Filter may be called "filter1",
131     * If this class does not have an owning
132     * component, a name from the configuration
133     * can be placed here. This name could also
134     * be changed to null for utility classes.
135     */
136     private String _name = null;
137 tdb 1.3
138     //---STATIC ATTRIBUTES---
139    
140 pjm2 1.6 }