KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nl > hippo > cms > sitesdirectory > SiteInformation


1 /*
2  * Copyright 2004 Hippo Webworks.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package nl.hippo.cms.sitesdirectory;
17
18 import java.util.HashMap JavaDoc;
19 import java.util.Map JavaDoc;
20 import nl.hippo.cms.repositorylocation.RepositoryInformation;
21
22 /**
23  * <p>
24  * Information about a destination site for content being edited in the CMS.
25  * </p>
26  *
27  * @author Johan Stuyts
28  */

29 public class SiteInformation
30 {
31     /**
32      * <p>
33      * The ID of the site.
34      * </p>
35      */

36     private String JavaDoc m_id;
37
38     /**
39      * <p>
40      * The localized names of the site.
41      * </p>
42      */

43     private Map JavaDoc m_names = new HashMap JavaDoc();
44
45     /**
46      * <p>
47      * The namespace URI of the privilege which is used to determine whether a
48      * person is an editor of this site.
49      * </p>
50      */

51     private String JavaDoc m_editorMarkerPrivilegeNamespaceUri;
52
53     /**
54      * <p>
55      * The name of the privilege which is used to determine whether a person is
56      * an editor of this site.
57      * </p>
58      */

59     private String JavaDoc m_editorMarkerPrivilegeName;
60
61     /**
62      * <p>
63      * The preview repository information.
64      * </p>
65      */

66     private RepositoryInformation m_previewRepository;
67
68     /**
69      * <p>
70      * The live repository information.
71      * </p>
72      */

73     private RepositoryInformation m_liveRepository;
74
75     /**
76      * <p>
77      * Create a site information object.
78      * </p>
79      *
80      * @param id
81      * The site ID.
82      * @param editorMarkerPrivilegeNamespaceUri
83      * The namespace URI of the editor marker privilege.
84      * @param editorMarkerPrivilegeName
85      * The name of the editor marker privilege.
86      */

87     public SiteInformation(String JavaDoc id, String JavaDoc editorMarkerPrivilegeNamespaceUri,
88             String JavaDoc editorMarkerPrivilegeName)
89     {
90         super();
91
92         m_id = id;
93         m_editorMarkerPrivilegeNamespaceUri = editorMarkerPrivilegeNamespaceUri;
94         m_editorMarkerPrivilegeName = editorMarkerPrivilegeName;
95     }
96
97     public String JavaDoc getId()
98     {
99         return m_id;
100     }
101
102     /**
103      * <p>
104      * Get a localized name of the site.
105      * </p>
106      *
107      * @param languageId
108      * The lowercase two-letter language code for which to retrieve
109      * the name.
110      * @return The localized name or <code>null</code> if there is no name for
111      * the requested language.
112      */

113     public String JavaDoc getName(String JavaDoc languageId)
114     {
115         return (String JavaDoc) m_names.get(languageId);
116     }
117
118     /**
119      * <p>
120      * Add a localized name to the site.
121      * </p>
122      *
123      * @param languageId
124      * The lowercase two-letter language code of the language.
125      * @param name
126      * The name in the language associated with
127      * <code>languageId</code>.
128      */

129     public void addName(String JavaDoc languageId, String JavaDoc name)
130     {
131         m_names.put(languageId, name);
132     }
133
134     public String JavaDoc getEditorMarkerPrivilegeNamespaceUri()
135     {
136         return m_editorMarkerPrivilegeNamespaceUri;
137     }
138
139     public String JavaDoc getEditorMarkerPrivilegeName()
140     {
141         return m_editorMarkerPrivilegeName;
142     }
143
144     public RepositoryInformation getPreviewRepository()
145     {
146         return m_previewRepository;
147     }
148
149     public void setPreviewRepository(RepositoryInformation repository)
150     {
151         m_previewRepository = repository;
152     }
153
154     public RepositoryInformation getLiveRepository()
155     {
156         return m_liveRepository;
157     }
158
159     public void setLiveRepository(RepositoryInformation repository)
160     {
161         m_liveRepository = repository;
162     }
163
164     /**
165      * <p>
166      * Get the hash code of this object.
167      * </p>
168      *
169      * @return The hash code of this object.
170      */

171     public int hashCode()
172     {
173         int result;
174
175         result = m_id.hashCode();
176         result |= m_editorMarkerPrivilegeNamespaceUri.hashCode();
177         result |= m_editorMarkerPrivilegeName.hashCode();
178         result |= m_previewRepository.hashCode();
179         result |= m_liveRepository.hashCode();
180
181         return result;
182     }
183
184     /**
185      * <p>
186      * Compare this object with another object.
187      * </p>
188      *
189      * <p>
190      * Please note that the localized names are not taken into account.
191      * </p>
192      *
193      * @param other
194      * The object to compare this object to.
195      * @return <code>true</code> if this object equals <code>other</code>,
196      * <code>false</code> otherwise.
197      */

198     public boolean equals(Object JavaDoc other)
199     {
200         boolean result;
201         
202
203         if (other == null || !(other instanceof SiteInformation))
204         {
205             result = false;
206         }
207         else if (other == this)
208         {
209             result = true;
210         }
211         else
212         {
213             SiteInformation otherSiteInfo = (SiteInformation) other;
214
215             result = otherSiteInfo.getId().equals(m_id);
216             result = result && otherSiteInfo.getEditorMarkerPrivilegeNamespaceUri() == m_editorMarkerPrivilegeNamespaceUri;
217             result = result && otherSiteInfo.getEditorMarkerPrivilegeName().equals(m_editorMarkerPrivilegeName);
218             result = result && otherSiteInfo.getPreviewRepository().equals(m_previewRepository);
219             result = result && otherSiteInfo.getLiveRepository().equals(m_liveRepository);
220         }
221         
222         return result;
223     }
224
225     /**
226      * <p>
227      * Get a <code>String</code> representation of this object.
228      * </p>
229      *
230      * @return The <code>String</code> representation of this object.
231      */

232     public String JavaDoc toString()
233     {
234         return "Site: " + m_id;
235     }
236 }
237
Popular Tags