1 19 20 package com.sslexplorer.properties.attributes; 21 22 import java.util.List ; 23 24 import org.jdom.Element; 25 import org.jdom.JDOMException; 26 27 import com.sslexplorer.boot.PropertyDefinition; 28 import com.sslexplorer.boot.XMLPropertyDefinition; 29 30 37 public class XMLAttributeDefinition extends XMLPropertyDefinition implements AttributeDefinition { 38 39 41 private String label; 42 private boolean system; 43 private String categoryLabel; 44 private String description; 45 private boolean replaceable; 46 private int visibility; 47 private String classSpecificKey; 48 49 55 public XMLAttributeDefinition(Element element) throws JDOMException { 56 super(element); 57 replaceable = "true".equalsIgnoreCase(element.getAttributeValue("replaceable")); 58 categoryLabel = element.getAttributeValue("categoryLabel"); 59 description = element.getAttributeValue("description"); 60 label = element.getAttributeValue("label"); 61 visibility = USER_USEABLE_ATTRIBUTE; 62 if (element.getAttribute("visibility") != null) { 63 visibility = element.getAttribute("visibility").getIntValue(); 64 } 65 66 system = true; 68 } 69 70 89 public XMLAttributeDefinition(int type, String name, String typeMeta, int category, String categoryLabel, String defaultValue, 90 int visibility, int sortOrder, String messageResourcesKey, boolean hidden, String label, 91 String description, boolean system, boolean replaceable, String validationString) { 92 super(type, name, typeMeta, category, defaultValue, sortOrder, messageResourcesKey, hidden); 93 this.label = label; 94 this.system = system; 95 this.hidden = hidden; 96 this.categoryLabel = categoryLabel; 97 this.description = description; 98 this.replaceable = replaceable; 99 this.validationString = validationString; 100 this.visibility = visibility; 101 } 102 103 109 public void setVisibility(int visibility) { 110 this.visibility = visibility; 111 } 112 113 119 public int getVisibility() { 120 return visibility; 121 } 122 123 129 public boolean isSystem() { 130 return system; 131 } 132 133 139 public void setSystem(boolean system) { 140 this.system = system; 141 } 142 143 151 public String getLabel() { 152 return label; 153 } 154 155 163 public void setLabel(String label) { 164 this.label = label; 165 } 166 167 174 public String getCategoryLabel() { 175 return categoryLabel; 176 } 177 178 185 public void setCategoryLabel(String categoryLabel) { 186 this.categoryLabel = categoryLabel; 187 } 188 189 197 public String getDescription() { 198 return description; 199 } 200 201 208 public void setDescription(String description) { 209 this.description = description; 210 } 211 212 217 public void setReplaceable(boolean replaceable) { 218 this.replaceable = replaceable; 219 } 220 221 226 public boolean isReplaceable() { 227 return replaceable; 228 } 229 230 235 public void setValidationString(String validationString) { 236 this.validationString = validationString; 237 } 238 239 244 public String formatAttributeValue(Object value) { 245 if (getType() == PropertyDefinition.TYPE_BOOLEAN) { 246 if (getTypeMetaObject() != null && !getTypeMetaObject().equals("")) { 247 String trueVal = (String ) (((List ) getTypeMetaObject()).get(0)); 248 return value == Boolean.TRUE ? trueVal : (String ) (((List ) getTypeMetaObject()).get(1)); 249 } 250 } 251 return value.toString(); 252 } 253 254 260 public Object parseValue(String value) { 261 if (getType() == PropertyDefinition.TYPE_BOOLEAN) { 262 if (getTypeMetaObject() != null) { 263 String trueVal = (String ) (((List ) getTypeMetaObject()).get(0)); 264 return value.equals(trueVal) ? Boolean.TRUE : Boolean.FALSE; 265 } 266 } 267 return value; 268 } 269 270 } 271 | Popular Tags |