KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > util > ValueNamePair


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.util;
15
16 /**
17  * (String) Value Name Pair
18  *
19  * @author Jorg Janke
20  * @version $Id: ValueNamePair.java,v 1.3 2002/06/24 05:02:27 jjanke Exp $
21  */

22 public final class ValueNamePair extends NamePair
23 {
24     /**
25      * Construct KeyValue Pair
26      * @param value value
27      * @param name string representation
28      */

29     public ValueNamePair(String JavaDoc value, String JavaDoc name)
30     {
31         super(name);
32         m_value = value;
33         if (m_value == null)
34             m_value = "";
35     } // ValueNamePair
36

37     /** The Value */
38     private String JavaDoc m_value = null;
39
40     /**
41      * Get Value
42      * @return Value
43      */

44     public String JavaDoc getValue()
45     {
46         return m_value;
47     } // getValue
48

49     /**
50      * Get ID
51      * @return Value
52      */

53     public String JavaDoc getID()
54     {
55         return m_value;
56     } // getID
57

58     /**
59      * Equals
60      * @param obj Object
61      * @return true, if equal
62      */

63     public boolean equals(Object JavaDoc obj)
64     {
65         if (obj instanceof ValueNamePair)
66         {
67             ValueNamePair pp = (ValueNamePair)obj;
68             if (pp.getName() != null && pp.getValue() != null &&
69                 pp.getName().equals(getName()) && pp.getValue().equals(m_value))
70                 return true;
71             return false;
72         }
73         return false;
74     } // equals
75

76     /**
77      * Return Hashcode of value
78      * @return hascode
79      */

80     public int hashCode()
81     {
82         return m_value.hashCode();
83     } // hashCode
84

85 } // KeyValuePair
86

87
Popular Tags