1 19 20 package com.sslexplorer.boot; 21 22 import org.jdom.Element; 23 import org.jdom.JDOMException; 24 25 26 33 public class XMLPropertyDefinition extends DefaultPropertyDefinition { 34 35 39 public XMLPropertyDefinition() { 40 super(); 41 } 42 43 55 public XMLPropertyDefinition(int type, String name, String typeMeta, int category, String defaultValue, int sortOrder, boolean hidden, String validationString) { 56 super(type, name, typeMeta, category, defaultValue, sortOrder, hidden, validationString); 57 } 58 59 70 public XMLPropertyDefinition(int type, String name, String typeMeta, int category, String defaultValue, int sortOrder, boolean hidden) { 71 super(type, name, typeMeta, category, defaultValue, sortOrder, hidden); 72 } 73 74 87 public XMLPropertyDefinition(int type, String name, String typeMeta, int category, String defaultValue, int sortOrder, String messageResourcesKey, boolean hidden, String validationString) { 88 super(type, name, typeMeta, category, defaultValue, sortOrder, messageResourcesKey, hidden, validationString); 89 } 90 91 103 public XMLPropertyDefinition(int type, String name, String typeMeta, int category, String defaultValue, int sortOrder, String messageResourcesKey, boolean hidden) { 104 super(type, name, typeMeta, category, defaultValue, sortOrder, messageResourcesKey, hidden); 105 } 106 107 113 public XMLPropertyDefinition(Element element) throws JDOMException { 114 super(); 115 116 name = element.getAttributeValue("name"); 118 if (name == null || name.equals("")) { 119 throw new JDOMException("Missing or empty name attribute in <parameter>"); 120 } 121 122 try { 124 type = Integer.parseInt(element.getAttributeValue("type")); 125 } catch (Exception e) { 126 throw new JDOMException("Missing or invalid type attribute in <parameter>"); 127 } 128 129 try { 131 sortOrder = Integer.parseInt(element.getAttributeValue("sortOrder")); 132 } catch (Exception e) { 133 sortOrder = 0; 134 } 135 136 typeMeta = Util.trimmedOrBlank(element.getAttributeValue("typeMeta")); 138 139 validationString = element.getAttributeValue("validation"); 141 142 hidden = "true".equalsIgnoreCase(element.getAttributeValue("hidden")); 144 145 try { 147 String c = element.getAttributeValue("category"); 148 if (c != null) { 149 category = Integer.parseInt(c); 150 } 151 } catch (Exception e) { 152 throw new JDOMException("Invalid category attribute in <parameter>"); 153 } 154 155 restartRequired = "true".equalsIgnoreCase(element.getAttributeValue("restartRequired")); 157 158 messageResourcesKey = element.getAttributeValue("messageResourcesKey"); 160 messageResourcesKey = messageResourcesKey == null ? "properties" : messageResourcesKey; 161 162 defaultValue = element.getAttributeValue("defaultValue"); 164 defaultValue = defaultValue == null ? UNDEFINED_PARAMETER : defaultValue; 165 defaultValue = defaultValue.replaceAll("\\\\n", "\n"); 166 167 } 169 170 } | Popular Tags |