View Javadoc

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