001: /*
002: * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/NameValuePair.java,v 1.17 2004/04/18 23:51:35 jsdever Exp $
003: * $Revision: 480424 $
004: * $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
005: *
006: * ====================================================================
007: *
008: * Licensed to the Apache Software Foundation (ASF) under one or more
009: * contributor license agreements. See the NOTICE file distributed with
010: * this work for additional information regarding copyright ownership.
011: * The ASF licenses this file to You under the Apache License, Version 2.0
012: * (the "License"); you may not use this file except in compliance with
013: * the License. You may obtain a copy of the License at
014: *
015: * http://www.apache.org/licenses/LICENSE-2.0
016: *
017: * Unless required by applicable law or agreed to in writing, software
018: * distributed under the License is distributed on an "AS IS" BASIS,
019: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
020: * See the License for the specific language governing permissions and
021: * limitations under the License.
022: * ====================================================================
023: *
024: * This software consists of voluntary contributions made by many
025: * individuals on behalf of the Apache Software Foundation. For more
026: * information on the Apache Software Foundation, please see
027: * <http://www.apache.org/>.
028: *
029: */
030:
031: package org.apache.commons.httpclient;
032:
033: import java.io.Serializable;
034:
035: import org.apache.commons.httpclient.util.LangUtils;
036:
037: /**
038: * <p>A simple class encapsulating a name/value pair.</p>
039: *
040: * @author <a href="mailto:bcholmes@interlog.com">B.C. Holmes</a>
041: * @author Sean C. Sullivan
042: * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
043: *
044: * @version $Revision: 480424 $ $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
045: *
046: */
047: public class NameValuePair implements Serializable {
048:
049: // ----------------------------------------------------------- Constructors
050:
051: /**
052: * Default constructor.
053: *
054: */
055: public NameValuePair() {
056: this (null, null);
057: }
058:
059: /**
060: * Constructor.
061: * @param name The name.
062: * @param value The value.
063: */
064: public NameValuePair(String name, String value) {
065: this .name = name;
066: this .value = value;
067: }
068:
069: // ----------------------------------------------------- Instance Variables
070:
071: /**
072: * Name.
073: */
074: private String name = null;
075:
076: /**
077: * Value.
078: */
079: private String value = null;
080:
081: // ------------------------------------------------------------- Properties
082:
083: /**
084: * Set the name.
085: *
086: * @param name The new name
087: * @see #getName()
088: */
089: public void setName(String name) {
090: this .name = name;
091: }
092:
093: /**
094: * Return the name.
095: *
096: * @return String name The name
097: * @see #setName(String)
098: */
099: public String getName() {
100: return name;
101: }
102:
103: /**
104: * Set the value.
105: *
106: * @param value The new value.
107: */
108: public void setValue(String value) {
109: this .value = value;
110: }
111:
112: /**
113: * Return the current value.
114: *
115: * @return String value The current value.
116: */
117: public String getValue() {
118: return value;
119: }
120:
121: // --------------------------------------------------------- Public Methods
122:
123: /**
124: * Get a String representation of this pair.
125: * @return A string representation.
126: */
127: public String toString() {
128: return ("name=" + name + ", " + "value=" + value);
129: }
130:
131: public boolean equals(final Object object) {
132: if (object == null)
133: return false;
134: if (this == object)
135: return true;
136: if (object instanceof NameValuePair) {
137: NameValuePair that = (NameValuePair) object;
138: return LangUtils.equals(this .name, that.name)
139: && LangUtils.equals(this .value, that.value);
140: } else {
141: return false;
142: }
143: }
144:
145: public int hashCode() {
146: int hash = LangUtils.HASH_SEED;
147: hash = LangUtils.hashCode(hash, this.name);
148: hash = LangUtils.hashCode(hash, this.value);
149: return hash;
150: }
151: }
|