View Javadoc

1   /*
2    * @(#)NVPair.java					0.3-3 06/05/2001
3    *
4    *  This file is part of the HTTPClient package
5    *  Copyright (C) 1996-2001 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   *  The HTTPClient's home page is located at:
28   *
29   *  http://www.innovation.ch/java/HTTPClient/ 
30   *
31   */
32  
33  package HTTPClient;
34  
35  
36  /**
37   * This class holds a Name/Value pair of strings. It's used for headers,
38   * form-data, attribute-lists, etc. This class is immutable.
39   *
40   * @version	0.3-3  06/05/2001
41   * @author	Ronald Tschalär
42   */
43  public final class NVPair
44  {
45      /** the name */
46      private String name;
47  
48      /** the value */
49      private String value;
50  
51  
52      // Constructors
53  
54      /**
55       * Creates a new name/value pair and initializes it to the
56       * specified name and value.
57       *
58       * @param name  the name
59       * @param value the value
60       */
61      public NVPair(String name, String value)
62      {
63  	this.name  = name;
64  	this.value = value;
65      }
66  
67      /**
68       * Creates a copy of a given name/value pair.
69       *
70       * @param p the name/value pair to copy
71       */
72      public NVPair(NVPair p)
73      {
74  	this(p.name, p.value);
75      }
76  
77  
78      // Methods
79  
80      /**
81       * Get the name.
82       *
83       * @return the name
84       */
85      public final String getName()
86      {
87  	return name;
88      }
89  
90      /**
91       * Get the value.
92       *
93       * @return the value
94       */
95      public final String getValue()
96      {
97  	return value;
98      }
99  
100 
101     /**
102      * Produces a string containing the name and value of this instance.
103      *
104      * @return a string containing the class name and the name and value
105      */
106     public String toString()
107     {
108 	return getClass().getName() + "[name=" + name + ",value=" + value + "]";
109     }
110 }