KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > serverbeans > validation > ValidationContext


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

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 // Logging
33
import com.sun.enterprise.util.LocalStringManagerImpl;
34
35
36 public class ValidationContext {
37     public Result result;
38     public Object JavaDoc value;
39     public Object JavaDoc classObject;
40     public String JavaDoc beanName;
41     public ConfigContext context;
42     public String JavaDoc name;
43     public String JavaDoc choice;
44     public LocalStringManagerImpl smh;
45     public String JavaDoc primaryKeyName;
46     public ValidationDescriptor validationDescriptor;
47     //-------------- prepared in GenericValidator
48
public String JavaDoc attrName;
49     public Object JavaDoc attrValue;
50     
51     
52
53
54     public ValidationContext(Result result, Object JavaDoc value, Object JavaDoc classObject, String JavaDoc beanName, ConfigContext context, String JavaDoc name, String JavaDoc choice, String JavaDoc 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 JavaDoc name) {
69         attrName = name;
70     }
71     
72     public String JavaDoc 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 JavaDoc)) || (value instanceof String JavaDoc[]))) );
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 JavaDoc t) {}
118         return null;
119     }
120         
121     public NameListMgr getNameListMgr()
122     {
123         return validationDescriptor.domainMgr._nameListMgr;
124     }
125 }
Popular Tags