1 /*
2 * $HeadURL: $
3 * $Date: $
4 * $Revision: $
5 * $Author: $
6 *
7 * Copyright (c) 2005 MindTree Consulting Ltd.
8 *
9 * This file is part of Insight.
10 *
11 * Insight is free software: you can redistribute it and/or modify it under the
12 * terms of the GNU General Public License as published by the Free Software
13 * Foundation, either version 3 of the License, or (at your option) any later
14 * version.
15 *
16 * Insight is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
19 * Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along with
22 * Insight. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25 package com.mindtree.techworks.insight.preferences.model;
26
27 import java.io.Serializable;
28 import java.util.HashMap;
29 import java.util.Iterator;
30
31
32 /**
33 * Holds basic information about Preferences.
34 *
35 * @see Preference Preference
36 * @author Bindul Bhowmik
37 * @version $Revision: 27 $ $Date: 2007-12-16 04:58:03 -0700 (Sun, 16 Dec 2007) $
38 */
39 public class PreferenceInfo implements Serializable {
40
41 /**
42 * Used for object serialization
43 */
44 private static final long serialVersionUID = 624275178580461568L;
45
46 /**
47 * The unique identifier for the Preference
48 */
49 private String id;
50
51 /**
52 * The display name of the Preference
53 */
54 private String name;
55
56 /**
57 * Is the preference user modifiable
58 */
59 private boolean isUserModifiable;
60
61 /**
62 * Is the preference aggregated
63 */
64 private boolean isAggregated;
65
66 /**
67 * The complete id of the preference with the parents.
68 */
69 private String completeId;
70
71 /**
72 * Contains the PreferenceInfo objects for the child preferences
73 */
74 private HashMap childPreferenceInfos;
75
76 /**
77 * Default Constructor
78 */
79 public PreferenceInfo () {
80
81 //Default Constructor
82 }
83
84 /**
85 * @return Returns the id.
86 */
87 public String getId () {
88
89 return id;
90 }
91
92 /**
93 * @param id The id to set.
94 */
95 public void setId (String id) {
96
97 this.id = id;
98 }
99
100 /**
101 * @return Returns the name.
102 */
103 public String getName () {
104
105 return name;
106 }
107
108 /**
109 * @param name The name to set.
110 */
111 public void setName (String name) {
112
113 this.name = name;
114 }
115
116 /**
117 * @return Returns the isUserModifiable.
118 */
119 public boolean isUserModifiable () {
120
121 return isUserModifiable;
122 }
123
124 /**
125 * @param isUserModifiable The isUserModifiable to set.
126 */
127 public void setUserModifiable (boolean isUserModifiable) {
128
129 this.isUserModifiable = isUserModifiable;
130 }
131
132
133 /**
134 * @return Returns the isAggregated.
135 */
136 public boolean isAggregated () {
137
138 return isAggregated;
139 }
140
141 /**
142 * @param isAggregated The isAggregated to set.
143 */
144 public void setAggregated (boolean isAggregated) {
145
146 this.isAggregated = isAggregated;
147 }
148
149
150 /**
151 * @return Returns the completeId.
152 */
153 public String getCompleteId () {
154
155 return completeId;
156 }
157
158 /**
159 * @param completeId The completeId to set.
160 */
161 public void setCompleteId (String completeId) {
162
163 this.completeId = completeId;
164 }
165
166 /**
167 * Overridden superclass method.
168 *
169 * @return The name of the preference
170 */
171 public String toString () {
172
173 // Note : This is used for display. DONOT change implementation
174 return this.name;
175 }
176
177 /**
178 * Adds a child preference info to this preference info.
179 *
180 * @param preferenceInfo PreferenceInfo for a child
181 * {@link Preference Preference}
182 */
183 public void addChildPreferenceInfo (PreferenceInfo preferenceInfo) {
184
185 if (null == childPreferenceInfos) {
186 childPreferenceInfos = new HashMap();
187 }
188
189 childPreferenceInfos.put(preferenceInfo.getId(), preferenceInfo);
190 }
191
192 /**
193 * Returns the number of child preference info's present.
194 *
195 * @return The count of Child Preference Infos
196 */
197 public int getChildPreferenceInfoCount () {
198
199 if (null == childPreferenceInfos) {
200 return 0;
201 } else {
202 return childPreferenceInfos.size();
203 }
204 }
205
206 /**
207 * Returns the child preference info.
208 *
209 * @param idKey The id of the child preference
210 * @return The preference info if present, or null
211 */
212 public PreferenceInfo getChildPreferenceInfoById (String idKey) {
213
214 if (null == childPreferenceInfos) {
215 return null;
216 } else {
217 return (PreferenceInfo) childPreferenceInfos.get(idKey);
218 }
219 }
220
221 /**
222 * Creates an iterator for the child preference attributes
223 *
224 * @return An iterator for the child preference attributes, or null if none
225 * are present.
226 */
227 public Iterator iterateChildPreferenceInfos () {
228
229 if (null == childPreferenceInfos) {
230 return null;
231 } else {
232 return childPreferenceInfos.values().iterator();
233 }
234 }
235
236 }