KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > HTTPClient > NVPair


1 /*
2  * @(#)NVPair.java 0.3-2 18/06/1999
3  *
4  * This file is part of the HTTPClient package
5  * Copyright (C) 1996-1999 Ronald Tschalär
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free
19  * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20  * MA 02111-1307, USA
21  *
22  * For questions, suggestions, bug-reports, enhancement-requests etc.
23  * I may be contacted at:
24  *
25  * ronald@innovation.ch
26  *
27  */

28
29 package HTTPClient;
30
31
32 /**
33  * This class holds a Name/Value pair of strings. It's used for headers,
34  * form-data, attribute-lists, etc. This class is immutable.
35  *
36  * @version 0.3-2 18/06/1999
37  * @author Ronald Tschalär
38  */

39
40 public final class NVPair
41 {
42     /** the name */
43     private String JavaDoc name;
44
45     /** the value */
46     private String JavaDoc value;
47
48
49     // Constructors
50

51     /**
52      * Creates an empty name/value pair.
53      */

54     NVPair()
55     {
56     this("", "");
57     }
58
59     /**
60      * Creates a copy of a given name/value pair.
61      * @param p the name/value pair to copy
62      */

63     public NVPair(NVPair p)
64     {
65     this(p.name, p.value);
66     }
67
68     /**
69      * Creates a new name/value pair and initializes it to the
70      * specified name and value.
71      * @param name the name
72      * @param value the value
73      */

74     public NVPair(String JavaDoc name, String JavaDoc value)
75     {
76     this.name = name;
77     this.value = value;
78     }
79
80
81     // Methods
82

83     /**
84      * get the name
85      *
86      * @return the name
87      */

88     public final String JavaDoc getName()
89     {
90     return name;
91     }
92
93     /**
94      * get the value
95      *
96      * @return the value
97      */

98     public final String JavaDoc getValue()
99     {
100     return value;
101     }
102
103
104     /**
105      * produces a string containing the name and value of this instance.
106      * @return a string containing the class name and the name and value
107      */

108     public String JavaDoc toString()
109     {
110     return getClass().getName() + "[name=" + name + ",value=" + value + "]";
111     }
112 }
113
114
Popular Tags