View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/community/common/src/java/org/astrogrid/community/common/policy/data/AccountData.java,v $</cvs:source>
3    * <cvs:author>$Author: dave $</cvs:author>
4    * <cvs:date>$Date: 2004/09/16 23:18:08 $</cvs:date>
5    * <cvs:version>$Revision: 1.11 $</cvs:version>
6    *
7    * <cvs:log>
8    *   $Log: AccountData.java,v $
9    *   Revision 1.11  2004/09/16 23:18:08  dave
10   *   Replaced debug logging in Community.
11   *   Added stream close() to FileStore.
12   *
13   *   Revision 1.10.82.1  2004/09/16 09:58:48  dave
14   *   Replaced debug with commons logging ....
15   *
16   *   Revision 1.10  2004/06/18 13:45:20  dave
17   *   Merged development branch, dave-dev-200406081614, into HEAD
18   *
19   *   Revision 1.9.36.1  2004/06/17 13:38:58  dave
20   *   Tidied up old CVS log entries
21   *
22   * </cvs:log>
23   *
24   *
25   */
26  package org.astrogrid.community.common.policy.data ;
27  
28  /***
29   * A data object to represent an Account.
30   * @todo Refactor this into AccountData and AccountDetails.
31   * @todo Refactor this to inherit from CommunityBase (common code for equals and ident handling).
32   *
33   */
34  public class AccountData
35      {
36      /***
37       * Public constructor.
38       *
39       */
40      public AccountData()
41          {
42          this(null) ;
43          }
44  
45      /***
46       * Public constructor.
47       * @param ident The Account ident.
48       * @todo Add syntax checking.
49       *
50       */
51      public AccountData(String ident)
52          {
53          this.setIdent(ident) ;
54          }
55  
56      /***
57       * The Account identifier.
58       * @todo Move this to a common data object base class
59       *
60       */
61      private String ident ;
62  
63      /***
64       * Access to the Account identifier.
65       * @return The Account identifier.
66       * @todo Move this to a common data object base class
67       *
68       */
69      public String getIdent()
70          {
71          return this.ident ;
72          }
73  
74      /***
75       * Access to the Account identifier.
76       * This will fail the the identifier is already set - you can't change the identifier of an existing Account.
77       * No syntax checking is applied to the value.
78       * @param value The Account identifier.
79       * @todo Refactor to use Ivorns.
80       * @todo Move this to a common data object base class
81       *
82       */
83      public void setIdent(String value)
84          {
85          if (null == this.ident)
86              {
87              this.ident = value ;
88              }
89          }
90  
91      /***
92       * The Account display name.
93       * This is intended for use in the portal display pages.
94       *
95       */
96      private String display ;
97  
98      /***
99       * Access to the Account display name.
100      * @return The current display name.
101      *
102      */
103     public String getDisplayName()
104         {
105         return this.display ;
106         }
107 
108     /***
109      * Access to the Account display name.
110      * @param value The new display name.
111      *
112      */
113     public void setDisplayName(String value)
114         {
115         this.display = value ;
116         }
117 
118     /***
119      * The Account description.
120      * This is intended for use in the portal display pages.
121      *
122      */
123     private String description ;
124 
125     /***
126      * Access to the Account description.
127      * @return The current description.
128      *
129      */
130     public String getDescription()
131         {
132         return this.description ;
133         }
134 
135     /***
136      * Access to the Account description.
137      * @param value The new description.
138      *
139      */
140     public void setDescription(String value)
141         {
142         this.description = value ;
143         }
144 
145     /***
146      * The Account home space URI.
147      * This is the MySpace or VoSpace URI for the account home.
148      * @todo Add syntax checking.
149      *
150      */
151     private String home ;
152 
153     /***
154      * Access to the Account home space URI.
155      * @return The current home space URI.
156      *
157      */
158     public String getHomeSpace()
159         {
160         return this.home ;
161         }
162 
163     /***
164      * Access to the Account home space URI (Ivorn).
165      * No syntax checking is applied to the value.
166      * @param value The new home space URI.
167      * @todo Add syntax checking.
168      *
169      */
170     public void setHomeSpace(String value)
171         {
172         this.home = value ;
173         }
174 
175     /***
176      * The Account email address.
177      * The contact email address for the Account owner.
178      * No syntax checking is applied to the value.
179      * @todo Add syntax checking.
180      *
181      */
182     private String email ;
183 
184     /***
185      * Access to the Account email address.
186      * @return The current email address.
187      *
188      */
189     public String getEmailAddress()
190         {
191         return this.email ;
192         }
193 
194     /***
195      * Access to the Account email address.
196      * No syntax checking is applied to the value.
197      * @param value The new email address.
198      * @todo Add syntax checking.
199      *
200      */
201     public void setEmailAddress(String value)
202         {
203         this.email = value ;
204         }
205 
206     /*
207      * Compare this with another AccountData.
208      * All we want to check is the Account ident.
209      * @param object The Object to compare.
210      * @return true if the two object represetnt the same Account (the idents are equivalent).
211      * @todo Needs to refactored to check for local community in the ident.
212      * @todo Move this to a common data object base class
213      *
214      */
215     public synchronized boolean equals(Object object)
216         {
217         //
218         // If the object is null.
219         if (null == object)
220             {
221             return false ;
222             }
223         //
224         // If the object is not null.
225         else {
226             //
227             // If the object is an AccountData
228             if (object instanceof AccountData)
229                 {
230                 AccountData that = (AccountData) object ;
231                 //
232                 // If our ident is null
233                 if (null == this.ident)
234                     {
235                     //
236                     // Check that ident is null.
237                     return (null == that.getIdent()) ;
238                     }
239                 //
240                 // If our ident is not null.
241                 else {
242                     //
243                     // Check that ident is the same.
244                     return (this.ident.equals(that.getIdent())) ;
245                     }
246                 }
247             //
248             // If that is not an AccountData
249             else {
250                 return false ;
251                 }
252             }
253         }
254 
255     /***
256      * Generate a hash code for comparison tests.
257      * At the moment, this just uses the ident.hashCode().
258      * @todo This needs to refactored to check for local community in the ident.
259      * @todo Move this to a common data object base class
260      *
261      */
262     public synchronized int hashCode()
263         {
264         return (null != this.ident) ? this.ident.hashCode() : 0 ;
265         }
266     }