001: /*
002: * @(#)NVPair.java 0.3-2 18/06/1999
003: *
004: * This file is part of the HTTPClient package
005: * Copyright (C) 1996-1999 Ronald Tschalär
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free
019: * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
020: * MA 02111-1307, USA
021: *
022: * For questions, suggestions, bug-reports, enhancement-requests etc.
023: * I may be contacted at:
024: *
025: * ronald@innovation.ch
026: *
027: */
028:
029: package HTTPClient;
030:
031: /**
032: * This class holds a Name/Value pair of strings. It's used for headers,
033: * form-data, attribute-lists, etc. This class is immutable.
034: *
035: * @version 0.3-2 18/06/1999
036: * @author Ronald Tschalär
037: */
038:
039: public final class NVPair {
040: /** the name */
041: private String name;
042:
043: /** the value */
044: private String value;
045:
046: // Constructors
047:
048: /**
049: * Creates an empty name/value pair.
050: */
051: NVPair() {
052: this ("", "");
053: }
054:
055: /**
056: * Creates a copy of a given name/value pair.
057: * @param p the name/value pair to copy
058: */
059: public NVPair(NVPair p) {
060: this (p.name, p.value);
061: }
062:
063: /**
064: * Creates a new name/value pair and initializes it to the
065: * specified name and value.
066: * @param name the name
067: * @param value the value
068: */
069: public NVPair(String name, String value) {
070: this .name = name;
071: this .value = value;
072: }
073:
074: // Methods
075:
076: /**
077: * get the name
078: *
079: * @return the name
080: */
081: public final String getName() {
082: return name;
083: }
084:
085: /**
086: * get the value
087: *
088: * @return the value
089: */
090: public final String getValue() {
091: return value;
092: }
093:
094: /**
095: * produces a string containing the name and value of this instance.
096: * @return a string containing the class name and the name and value
097: */
098: public String toString() {
099: return getClass().getName() + "[name=" + name + ",value="
100: + value + "]";
101: }
102: }
|