1 23 24 package com.sun.enterprise.config.serverbeans.validation; 25 26 27 import com.sun.enterprise.config.ConfigContextEvent; 28 import com.sun.enterprise.config.ConfigContext; 29 import com.sun.enterprise.config.ConfigBean; 30 import com.sun.enterprise.config.serverbeans.validation.tests.StaticTest; 31 32 import com.sun.enterprise.util.LocalStringManagerImpl; 34 35 36 public class ValidationContext { 37 public Result result; 38 public Object value; 39 public Object classObject; 40 public String beanName; 41 public ConfigContext context; 42 public String name; 43 public String choice; 44 public LocalStringManagerImpl smh; 45 public String primaryKeyName; 46 public ValidationDescriptor validationDescriptor; 47 public String attrName; 49 public Object attrValue; 50 51 52 53 54 public ValidationContext(Result result, Object value, Object classObject, String beanName, ConfigContext context, String name, String choice, String primaryKeyName, LocalStringManagerImpl smh, ValidationDescriptor validationDescriptor) { 55 this.result = result; 56 this.value = value; 57 this.beanName = beanName; 58 this.context = context; 59 this.name = name; 60 this.choice = choice; 61 this.smh = smh; 62 this.primaryKeyName = primaryKeyName; 63 this.classObject = classObject; 64 this.validationDescriptor = validationDescriptor; 65 attrName = null; 66 } 67 68 public void setAttrName(String name) { 69 attrName = name; 70 } 71 72 public String getPrimaryKeyName() { 73 return primaryKeyName; 74 } 75 public boolean isUPDATEorSET() 76 { 77 return (choice != null && choice.equals(StaticTest.UPDATE) || choice.equals(StaticTest.SET)); 78 } 79 public boolean isUPDATE() 80 { 81 return (choice != null && 82 (choice.equals(StaticTest.UPDATE) || 83 (choice.equals(StaticTest.SET) && 84 ((value instanceof String )) || (value instanceof String []))) ); 85 } 86 public boolean isSET() 87 { 88 return (choice != null && choice.equals(StaticTest.SET) && (value instanceof ConfigBean) ); 89 } 90 public boolean isADD() 91 { 92 return (choice != null && choice.equals(StaticTest.ADD)); 93 } 94 public boolean isDELETE() 95 { 96 return (choice != null && choice.equals(StaticTest.DELETE)); 97 } 98 public boolean isVALIDATE() 99 { 100 return (choice != null && choice.equals(StaticTest.VALIDATE)); 101 } 102 public ConfigBean getTargetBean() 103 { 104 if ((isSET()||isADD()||isDELETE()||isVALIDATE()) && (value instanceof ConfigBean) ) 105 return (ConfigBean)value; 106 if ((isUPDATE()) && (classObject instanceof ConfigBean)) 107 return (ConfigBean)classObject; 108 return null; 109 } 110 public ConfigBean getParentBean() 111 { 112 if ((isSET()||isADD()) && (classObject instanceof ConfigBean) ) 113 return (ConfigBean)classObject; 114 ConfigBean self = getTargetBean(); 115 try { 116 return (ConfigBean)self.parent(); 117 } catch(Throwable t) {} 118 return null; 119 } 120 121 public NameListMgr getNameListMgr() 122 { 123 return validationDescriptor.domainMgr._nameListMgr; 124 } 125 } | Popular Tags |