KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > barracuda > plankton > data > Param


1 /*
2  * Copyright (C) 2003 Christian Cryder [christianc@granitepeaks.com]
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * $Id: Param.java,v 1.3 2004/02/01 05:16:28 christianc Exp $
19  */

20 package org.enhydra.barracuda.plankton.data;
21
22 import javax.servlet.*;
23 import javax.servlet.http.*;
24
25 /**
26  * <p>Define a Param object as having key and value properties
27  * (both of which are Strings)
28  */

29 public class Param {
30
31     String JavaDoc key = null;
32     String JavaDoc value = null;
33
34     /**
35      * Create an empty Param
36      */

37     public Param() {
38         this(null, null);
39     }
40
41     /**
42      * Create a Param for a given key/value
43      *
44      * @param ikey the param key
45      * @param ivalue the param value
46      */

47     public Param(String JavaDoc ikey, String JavaDoc ivalue) {
48         setKey(ikey);
49         setValue(ivalue);
50     }
51
52     /**
53      * Set the key
54      *
55      * @param ikey the param key
56      */

57     public void setKey(String JavaDoc ikey) {
58         key = ikey;
59     }
60
61     /**
62      * Get the key
63      *
64      * @return the param key
65      */

66     public String JavaDoc getKey() {
67         return key;
68     }
69
70     /**
71      * Set the value
72      *
73      * @param ivalue the param value
74      */

75     public void setValue(String JavaDoc ivalue) {
76         value = ivalue;
77     }
78
79     /**
80      * Get the value
81      *
82      * @return the param value
83      */

84     public String JavaDoc getValue() {
85         return value;
86     }
87
88     /**
89      * Check for equality (if both key & value match)
90      *
91      * @param o the object we are comparing against
92      * @return true if the objects are equal
93      */

94     public boolean equals(Object JavaDoc o) {
95         if (o==null) return false;
96         if (o instanceof Param) {
97             Param p = (Param) o;
98             if (key==null && p.key!=null) return false;
99             if (value==null && p.value!=null) return false;
100             else return (key.equals(p.key) && value.equals(p.value));
101         } else {
102             return false;
103         }
104     }
105
106     /**
107      * Return a string representation of the param
108      */

109     public String JavaDoc toString() {
110         return "Param {k:"+key+" v:"+value+"}";
111     }
112 }
113
Popular Tags