1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean; 26 27 31 public final class ValidationError implements Comparable { 32 33 private final Partition partition; 34 private final String fieldId; 35 private final String message; 36 37 38 private ValidationError(String fieldId, String message) { 39 this(PARTITION_GLOBAL, fieldId, message); 40 } 41 42 43 private ValidationError(Partition partition, String fieldId, String message) { 44 this.partition = partition; 45 this.fieldId = fieldId; 46 this.message = message; 47 } 48 49 55 public Partition getPartition() { 56 return partition; 57 } 58 59 63 public String getFieldId() { 64 return fieldId; 65 } 66 67 72 public String getMessage() { 73 return message; 74 } 75 76 82 public boolean equals(Object obj) { 83 boolean result; 84 85 if(this == obj) { 86 result = true; 87 } else { 88 ValidationError target = (ValidationError) obj; 89 result = partition.equals(target.partition) && fieldId.equals(target.fieldId); 90 } 91 92 return result; 93 } 94 95 private volatile int hashCode = 0; 96 97 102 public int hashCode() { 103 if(hashCode == 0) { 104 int result = fieldId.hashCode(); 105 if(partition != null) { 106 result = 37*result + partition.hashCode(); 107 } 108 hashCode = result; 109 } 110 return hashCode; 111 } 112 113 119 public int compareTo(Object obj) { 120 int result; 121 122 if(this == obj) { 123 result = 0; 124 } else { 125 ValidationError target = (ValidationError) obj; 126 result = partition.compareTo(target.partition); 127 128 if(result == 0) { 129 result = fieldId.compareTo(target.fieldId); 130 } 131 } 132 133 return result; 134 } 135 136 141 public static ValidationError getValidationError(String fieldId, String message) { 142 return new ValidationError(fieldId, message); 143 } 144 145 public static ValidationError getValidationErrorMask(String fieldId) { 146 return new ValidationError(fieldId, ""); 147 } 148 149 155 public static ValidationError getValidationError(Partition partition, String fieldId, String message) { 156 return new ValidationError(partition, fieldId, message); 157 } 158 159 public static ValidationError getValidationErrorMask(Partition partition, String fieldId) { 160 return new ValidationError(partition, fieldId, ""); 161 } 162 163 166 167 public static final Partition PARTITION_GLOBAL = 169 new Partition("Global"); 170 171 public static final Partition PARTITION_WEB_GENERAL = 173 new Partition("WebGeneral", 0); public static final Partition PARTITION_WEB_CLASSLOADER = 175 new Partition("WebClassLoader", 1); public static final Partition PARTITION_WEB_PROPERTIES = 177 new Partition("WebProperties", 2); public static final Partition PARTITION_SESSION_MANAGER = 179 new Partition("SessionManager", 3, 0); public static final Partition PARTITION_SESSION_STORE = 181 new Partition("SessionStore", 3, 1); public static final Partition PARTITION_SESSION_SESSION = 183 new Partition("SessionSession", 3, 2); public static final Partition PARTITION_SESSION_COOKIE = 185 new Partition("SessionCookie", 3, 3); public static final Partition PARTITION_WEB_MESSAGES = 187 new Partition("WebMessages", 4); public static final Partition PARTITION_WEB_LOCALE = 189 new Partition("WebLocale", 5); public static final Partition PARTITION_CACHE_GENERAL = 191 new Partition("CacheGeneral", 6, 0); public static final Partition PARTITION_CACHE_HELPERS = 193 new Partition("CacheHelpers", 6, 1); public static final Partition PARTITION_CACHE_CONSTRAINTS = 195 new Partition("CacheConstraints", 6, 2); 197 public static final Partition PARTITION_SECURITY_ASSIGN = 199 new Partition("SecurityAssign", 0); public static final Partition PARTITION_SECURITY_MASTER = 201 new Partition("SecurityMaster", 1); 203 public static final Partition PARTITION_SERVICEREF_GENERAL = 205 new Partition("ServiceRefGeneral", 0); public static final Partition PARTITION_SERVICEREF_PORTINFO = 207 new Partition("ServiceRefPortInfo", 1); 209 public static final Partition PARTITION_CONNECTOR_ADAPTER = 211 new Partition("ConnectorAdapter", 0); public static final Partition PARTITION_CONNECTOR_ROLES = 213 new Partition("ConnectorRoles", 1); 215 public static final Partition PARTITION_EJBJAR_CMP_RESOURCE = 217 new Partition("EjbJarCmpResource", 0); public static final Partition PARTITION_EJBJAR_PM_DESCRIPTORS = 219 new Partition("EjbJarPmDescriptors", 1); public static final Partition PARTITION_EJBJAR_MESSAGES = 221 new Partition("EjbJarMessages", 2); 223 224 public static final class Partition implements Comparable { 225 private final String partitionName; 226 private int tabIndex; 227 private int subTabIndex; 228 229 private Partition(final String name) { 230 this(name, -1, -1); 231 } 232 233 private Partition(final String name, final int index) { 234 this(name, index, -1); 235 } 236 237 private Partition(final String name, final int index, final int subIndex) { 238 partitionName = name; 239 tabIndex = index; 240 subTabIndex = subIndex; 241 } 242 243 public String toString() { 244 return partitionName; 245 } 246 247 public int getTabIndex() { 248 return tabIndex; 249 } 250 251 public int getSubTabIndex() { 252 return subTabIndex; 253 } 254 255 public int compareTo(Object obj) { 256 Partition target = (Partition) obj; 257 return partitionName.compareTo(target.partitionName); 258 } 259 } 260 } 261 262 | Popular Tags |