View Javadoc
1   //////////////////////////////////////////////////////////////////////////////
2   // dexterIM - Instant Messaging Framework
3   // Copyright (C) 2003  Christoph Walcher
4   //
5   // This program is free software; you can redistribute it and/or modify
6   // it under the terms of the GNU General Public License as published by
7   // the Free Software Foundation; either version 2 of the License, or
8   // (at your option) any later version.
9   //
10  // This program is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  // GNU General Public License for more details.
14  //
15  // You should have received a copy of the GNU General Public License
16  // along with this program; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  //////////////////////////////////////////////////////////////////////////////
19  package net.sf.dexterim.core;
20  
21  /***
22   *@author     Christoph Walcher
23   */
24  public abstract class AbstractContact implements Contact {
25    private String nick;
26    private String account;
27    private String status;
28    private java.util.Map properties;
29  
30    /***
31     *  Creates a new instance of DefaultContact
32     */
33    public AbstractContact() {
34      this(null, null, null);
35    }
36  
37    /***
38     *  Constructor for the AbstractContact object
39     *
40     *@param  account  Description of the Parameter
41     *@param  nick     Description of the Parameter
42     *@param  status   Description of the Parameter
43     */
44    public AbstractContact(String account, String nick, String status) {
45      this.nick = nick;
46      this.account = account;
47      this.status = status;
48  
49      this.properties = new java.util.HashMap();
50    }
51  
52    /***
53     *  Gets the nick attribute of the AbstractContact object
54     *
55     *@return    The nick value
56     */
57    public String getNick() {
58      return nick;
59    }
60  
61    /***
62     *  Gets the account attribute of the AbstractContact object
63     *
64     *@return    The account value
65     */
66    public String getAccount() {
67      return account;
68    }
69  
70    /***
71     *  Gets the status attribute of the AbstractContact object
72     *
73     *@return    The status value
74     */
75    public String getStatus() {
76      return status;
77    }
78  
79    /***
80     *  Sets the nick attribute of the AbstractContact object
81     *
82     *@param  nick  The new nick value
83     */
84    public void setNick(String nick) {
85      this.nick = nick;
86    }
87  
88    /***
89     *  Sets the status attribute of the AbstractContact object
90     *
91     *@param  status  The new status value
92     */
93    public void setStatus(String status) {
94      this.status = status;
95    }
96  
97    /***
98     *  Gets the value attribute of the AbstractContact object
99     *
100    *@param  key  Description of the Parameter
101    *@return      The value value
102    */
103   public Object getValue(Object key) {
104     return properties.get(key);
105   }
106 
107   /***
108    *  Description of the Method
109    *
110    *@return    Description of the Return Value
111    */
112   public int hashCode() {
113     return getIdentity().hashCode();
114   }
115 
116   /***
117    *  Description of the Method
118    *
119    *@return    Description of the Return Value
120    */
121   public String toString() {
122     if (nick != null) {
123       return nick;
124     }
125     else {
126       return account;
127     }
128   }
129 
130   /***
131    *  Description of the Method
132    *
133    *@param  obj  Description of the Parameter
134    *@return      Description of the Return Value
135    */
136   public boolean equals(Object obj) {
137     if ((obj != null) && obj instanceof Contact) {
138       return getIdentity().equals(((Contact)obj).getIdentity());
139     }
140 
141     return false;
142   }
143 }