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 29 30 /** 31 * This is an individual Attribute in a Preference. A PreferenceAttribute must 32 * have a type, id and indicators whether it is Persistant and UserModifiable. 33 * 34 * @see Preference Preference 35 * @see PreferenceAttributeType PreferenceAttributeType 36 * @author Bindul Bhowmik 37 * @version $Revision: 27 $ $Date: 2007-12-16 04:58:03 -0700 (Sun, 16 Dec 2007) $ 38 */ 39 public class PreferenceAttribute implements Serializable { 40 41 /** 42 * Used for object serialization 43 */ 44 private static final long serialVersionUID = -163229271943985818L; 45 46 /** 47 * Represents an identifier for the attribute which should be unique to the 48 * Preference Group. 49 */ 50 private String id; 51 52 /** 53 * The name of the attribute to be displayed to the user. 54 */ 55 private String name; 56 57 /** 58 * The value associated with the attribute. 59 */ 60 private String value; 61 62 /** 63 * The default value to be used for the attribute in the absence of a value 64 */ 65 private String defaultValue; 66 67 /** 68 * Tells whether the preference attribute value has to be encrypted. 69 */ 70 private boolean isEncrypted; 71 /** 72 * Represents if the value of the attribute will persist across instances of 73 * the application 74 */ 75 private boolean isPersistant; 76 77 /** 78 * Represents whether the attribute can be modified by user GUI 79 */ 80 private boolean isUserModifiable; 81 82 /** 83 * Identifies the type of this Preference Attribute 84 */ 85 private PreferenceAttributeType type; 86 87 /** 88 * The Preference which is the parent of the Preference Attribute 89 */ 90 private Preference parent; 91 92 /** 93 * The constructor for this class. 94 * 95 * @param type Identifies the type of this Preference Attribute 96 * @param id Represents an identifier for the attribute 97 * @param value he value associated with the attribute. 98 * @param isPersistant Represents if the value of the attribute will persist 99 * across instances of the application 100 * @param isUserModifiable Represents whether the attribute can be modified 101 * by user GUI 102 * @param parent The Preference which is the parent of the Preference 103 * Attribute 104 */ 105 public PreferenceAttribute (PreferenceAttributeType type, String id, 106 String value, boolean isEncrypted, boolean isPersistant, boolean isUserModifiable, 107 Preference parent) { 108 109 this.type = type; 110 this.id = id; 111 this.value = value; 112 this.isEncrypted = isEncrypted; 113 this.isPersistant = isPersistant; 114 this.isUserModifiable = isUserModifiable; 115 this.parent = parent; 116 } 117 118 /** 119 * @return Returns the name. 120 */ 121 public String getName () { 122 123 return name; 124 } 125 126 /** 127 * @param name The name to set. 128 */ 129 public void setName (String name) { 130 131 this.name = name; 132 } 133 134 /** 135 * @return Returns the value. 136 */ 137 public String getValue () { 138 139 return value; 140 } 141 142 /** 143 * @param value The value to set. 144 */ 145 public void setValue (String value) { 146 147 if (!value.equals(this.value)) { 148 this.value = value; 149 parent.notifyAttributeValueChange(id, value); 150 } 151 152 } 153 154 /** 155 * @return Returns the defaultValue. 156 */ 157 public String getDefaultValue () { 158 159 return defaultValue; 160 } 161 162 /** 163 * @return Returns the id. 164 */ 165 public String getId () { 166 167 return id; 168 } 169 170 /** 171 * @return Returns the isPersistant. 172 */ 173 public boolean isPersistant () { 174 175 return isPersistant; 176 } 177 178 /** 179 * @return Returns the isUserModifiable. 180 */ 181 public boolean isUserModifiable () { 182 183 return isUserModifiable; 184 } 185 186 /** 187 * @return Returns the parent. 188 */ 189 public Preference getParent () { 190 191 return parent; 192 } 193 194 /** 195 * @return Returns the type. 196 */ 197 public PreferenceAttributeType getType () { 198 199 return type; 200 } 201 202 /** 203 * @param defaultValue The defaultValue to set. 204 */ 205 public void setDefaultValue (String defaultValue) { 206 207 this.defaultValue = defaultValue; 208 } 209 210 public boolean isEncrypted() { 211 return isEncrypted; 212 } 213 214 public void setEncrypted(boolean isEncrypted) { 215 this.isEncrypted = isEncrypted; 216 } 217 }