Source Code Cross Referenced for PostConstraintValidatorForVarNameAndType.java in  » Workflow-Engines » JFolder » org » jfolder » common » function » v1 » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » JFolder » org.jfolder.common.function.v1 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JFolder, Copyright 2001-2006 Gary Steinmetz
003:         *
004:         * Distributable under LGPL license.
005:         * See terms of license at gnu.org.
006:         */
007:
008:        package org.jfolder.common.function.v1;
009:
010:        //base classes
011:        import java.util.ArrayList;
012:        import java.util.HashMap;
013:
014:        //project specific classes
015:        import org.jfolder.common.SelfArgumentlessConstructor;
016:        import org.jfolder.common.StandardDataTypes;
017:        import org.jfolder.common.UnexpectedSystemException;
018:        import org.jfolder.common.function.BaseCommonFunctionCompatibilityTag;
019:        import org.jfolder.common.function.WebPageTagInstanceViewContext;
020:        import org.jfolder.common.tagging.AppraiseConceptTagContext;
021:        import org.jfolder.common.tagging.ConceptTagCharacteristic;
022:        import org.jfolder.common.tagging.ConceptTagConstraint;
023:        import org.jfolder.common.tagging.ConceptTagConstraintHolder;
024:        import org.jfolder.common.tagging.ConceptTagConstraintOrTemplate;
025:        import org.jfolder.common.tagging.ConceptTagFlagsHelper;
026:        import org.jfolder.common.tagging.ConceptTagHelper;
027:        import org.jfolder.common.tagging.DetermineClassConceptTagContext;
028:        import org.jfolder.common.tagging.DetermineValueAndClassConceptTagContext;
029:        import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
030:        import org.jfolder.common.tagging.DynamicConceptTagValidator;
031:        import org.jfolder.common.tagging.InitializeConceptTagContext;
032:        import org.jfolder.common.tagging.PostValidatorForConceptTagConstraint;
033:        import org.jfolder.common.tagging.SelectionCriteriaForReturnableConceptTag;
034:        import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
035:        import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
036:        import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
037:        import org.jfolder.common.utils.misc.CommonExpressions;
038:
039:        //other classes
040:
041:        public class PostConstraintValidatorForVarNameAndType implements 
042:                PostValidatorForConceptTagConstraint {
043:            //
044:
045:            //
046:            private String name = null;
047:            private String type = null;
048:            private String value = null;
049:            //
050:            private boolean assignToParent = false;
051:            //
052:            private String sphereHandle = null;
053:            private int sphereIndex = 0;
054:
055:            //
056:            private PostConstraintValidatorForVarNameAndType(String inName,
057:                    String inType, String inValue, boolean inAssignToParent,
058:                    String inSphereHandle, int inSphereIndex) {
059:                //
060:                this .name = inName;
061:                this .type = inType;
062:                this .value = inValue;
063:                //
064:                this .assignToParent = inAssignToParent;
065:                //
066:                this .sphereHandle = inSphereHandle;
067:                this .sphereIndex = inSphereIndex;
068:            }
069:
070:            //
071:            public final static PostConstraintValidatorForVarNameAndType newInstance(
072:                    String inName, String inType, String inValue,
073:                    boolean inAssignToParent, String inSphereHandle,
074:                    int inSphereIndex) {
075:                //
076:                PostConstraintValidatorForVarNameAndType outValue = new PostConstraintValidatorForVarNameAndType(
077:                        inName, inType, inValue, inAssignToParent,
078:                        inSphereHandle, inSphereIndex);
079:
080:                return outValue;
081:            }
082:
083:            //
084:            public void postValidate(InitializeConceptTagContext inIctc,
085:                    ConceptTagConstraint inCtcon) {
086:                //
087:                ConceptTagConstraintHolder parCtconh = inCtcon
088:                        .getParentConstraintHolder();
089:                //
090:                //
091:                //
092:                ConceptTagConstraint nameCtcon = null;
093:                ConceptTagCharacteristic nameCtchar = null;
094:                //
095:                if (this .name != null) {
096:                    nameCtcon = parCtconh.getConstraint(this .name);
097:                    nameCtchar = nameCtcon.getCharacteristic();
098:                }
099:                //
100:                //
101:                //
102:                ConceptTagConstraint typeCtcon = parCtconh
103:                        .getConstraint(this .type);
104:                ConceptTagCharacteristic typeCtchar = typeCtcon
105:                        .getCharacteristic();
106:                //
107:                //
108:                //
109:                ConceptTagConstraint valueCtcon = null;
110:                ConceptTagCharacteristic valueCtchar = null;
111:                //
112:                if (this .value != null) {
113:                    valueCtcon = parCtconh.getConstraint(this .value);
114:                    valueCtchar = valueCtcon.getCharacteristic();
115:                }
116:                //
117:                //
118:                //
119:                String declaredName = null;
120:                if (nameCtchar != null && nameCtchar.getValueLength() > 0
121:                        && nameCtchar.isStatic(0, inIctc)) {
122:                    //
123:
124:                    declaredName = nameCtchar.getValueAsString(0, inIctc);
125:
126:                    if (!ConceptTagFlagsHelper
127:                            .isVariableNameValid(declaredName)) {
128:                        nameCtcon
129:                                .registerError("Cannot declare local variable '"
130:                                        + declaredName
131:                                        + "' because variables must start with a letter,"
132:                                        + " and each other character must be a letter, digit,"
133:                                        + " or underscore");
134:                    } else if (ConceptTagFlagsHelper.isGlobalVariablePresent(
135:                            inIctc, declaredName)) {
136:                        //
137:                        nameCtcon
138:                                .registerError("Cannot declare local variable '"
139:                                        + declaredName
140:                                        + "' because it is already declared"
141:                                        + " as a global variable");
142:                    } else if (ConceptTagFlagsHelper.isLocalVariablePresent(
143:                            inIctc, declaredName)) {
144:                        //
145:                        nameCtcon
146:                                .registerError("Cannot declare local variable '"
147:                                        + declaredName
148:                                        + "' because it is already declared"
149:                                        + " as a local variable");
150:                    } else {
151:                        //do nothing
152:                    }
153:                }
154:                //
155:                Class typeClass = null;
156:                if (typeCtchar.getValueLength() > 0
157:                        && typeCtchar.isStatic(0, inIctc)) {
158:
159:                    String declaredType = typeCtchar
160:                            .getValueAsString(0, inIctc);
161:
162:                    HashMap dntc = StandardDataTypes.getDisplayNameToClass();
163:                    if (dntc.containsKey(declaredType)) {
164:                        typeClass = ((Class) dntc.get(declaredType));
165:
166:                        //
167:                        initializeValueCtcon(typeClass, declaredType,
168:                                typeCtcon, valueCtcon);
169:
170:                    } else {
171:                        typeCtcon.registerError("Unknown data type '"
172:                                + declaredType + "'");
173:                    }
174:                }
175:                //
176:                if (nameCtchar != null
177:                        && !nameCtchar.getParentMessageHolder()
178:                                .isErrorPresent()
179:                        && !typeCtchar.getParentMessageHolder()
180:                                .isErrorPresent()) {
181:                    //
182:                    if (this .assignToParent) {
183:                        ConceptTagFlagsHelper
184:                                .createLocalAndParentOfLocalVariable(inIctc,
185:                                        typeClass, declaredName, null);
186:                        if (ConceptTagFlagsHelper
187:                                .isStudioUsabilityPresent(inIctc)) {
188:                            ConceptTagFlagsHelper
189:                                    .declareVariableSphere(this .sphereHandle,
190:                                            this .sphereIndex, inIctc);
191:                        }
192:                    } else {
193:                        ConceptTagFlagsHelper.createLocalVariable(inIctc,
194:                                typeClass, declaredName, null);
195:                    }
196:                }
197:                //
198:            }
199:
200:            //
201:            public final static void initializeValueCtcon(Class inType,
202:                    String inDeclaredType, ConceptTagConstraint inTypeCtcon,
203:                    ConceptTagConstraint inValueCtcon) {
204:                //
205:                //
206:                //
207:                if (inValueCtcon != null) {
208:                    inValueCtcon.setMinimumLength(1);
209:                    inValueCtcon.setMaximumLength(1);
210:                }
211:                //
212:                //
213:                //
214:                if (inType.equals(StandardDataTypes.getStringClass())) {
215:                    //
216:                    if (inValueCtcon != null) {
217:                        StaticConceptTagConstraintContext valueSctcc = StaticConceptTagConstraintContext
218:                                .newInstance(inValueCtcon);
219:                        //
220:                        valueSctcc.setMultiLine(true);
221:                        valueSctcc.addDefaultValue("(Text Here)");
222:                        //
223:                        //
224:                        DynamicConceptTagConstraintContext valueDctcc = DynamicConceptTagConstraintContext
225:                                .newInstance(inValueCtcon);
226:                        DynamicConceptTagValidator valueDctv = valueDctcc
227:                                .getValidator();
228:                        valueDctv.allowReturnOfOnlyString();
229:                    }
230:                } else if (inType.equals(StandardDataTypes.getBooleanClass())) {
231:                    //
232:                    if (inValueCtcon != null) {
233:                        ConceptTagHelper.formatBooleanCtcon(inValueCtcon,
234:                                new Boolean(true));
235:                    }
236:                } else if (inType.equals(StandardDataTypes.getDecimalClass())) {
237:                    //
238:                    if (inValueCtcon != null) {
239:                        StaticConceptTagConstraintContext valueSctcc = StaticConceptTagConstraintContext
240:                                .newInstance(inValueCtcon);
241:                        //
242:                        valueSctcc.setMultiLine(false);
243:                        valueSctcc.addDefaultValue(0 + "");
244:                        valueSctcc.setRegularExpression(
245:                                CommonExpressions.DECIMAL,
246:                                "Value must be a decimal number");
247:                        //
248:                        //
249:                        DynamicConceptTagConstraintContext valueDctcc = DynamicConceptTagConstraintContext
250:                                .newInstance(inValueCtcon);
251:                        DynamicConceptTagValidator valueDctv = valueDctcc
252:                                .getValidator();
253:                        valueDctv.allowReturnOfOnlyDecimal();
254:                    }
255:                } else if (inType.equals(StandardDataTypes.getListClass())) {
256:                    //
257:                    if (inValueCtcon != null) {
258:                        //
259:                        DynamicConceptTagConstraintContext valueDctcc = DynamicConceptTagConstraintContext
260:                                .newInstance(inValueCtcon);
261:                        DynamicConceptTagValidator valueDctv = valueDctcc
262:                                .getValidator();
263:                        valueDctv.allowReturnOfOnlyList();
264:                    }
265:                } else if (inType.equals(StandardDataTypes.getMapClass())) {
266:                    //
267:                    if (inValueCtcon != null) {
268:                        //
269:                        DynamicConceptTagConstraintContext valueDctcc = DynamicConceptTagConstraintContext
270:                                .newInstance(inValueCtcon);
271:                        DynamicConceptTagValidator valueDctv = valueDctcc
272:                                .getValidator();
273:                        valueDctv.allowReturnOfOnlyMap();
274:                    }
275:                } else if (inType.equals(StandardDataTypes.getBinaryClass())) {
276:                    //
277:                    if (inValueCtcon != null) {
278:                        //
279:                        DynamicConceptTagConstraintContext valueDctcc = DynamicConceptTagConstraintContext
280:                                .newInstance(inValueCtcon);
281:                        DynamicConceptTagValidator valueDctv = valueDctcc
282:                                .getValidator();
283:                        valueDctv.allowReturnOfOnlyBinary();
284:                    }
285:                } else if (inType.equals(StandardDataTypes.getTimestampClass())) {
286:                    //
287:                    if (inValueCtcon != null) {
288:                        //
289:                        DynamicConceptTagConstraintContext valueDctcc = DynamicConceptTagConstraintContext
290:                                .newInstance(inValueCtcon);
291:                        DynamicConceptTagValidator valueDctv = valueDctcc
292:                                .getValidator();
293:                        valueDctv.allowReturnOfOnlyTimestamp();
294:                    }
295:                } else {
296:                    if (inTypeCtcon != null) {
297:                        inTypeCtcon.registerError("Unknown data type '"
298:                                + inDeclaredType + "'");
299:                    }
300:                }
301:                //
302:                //
303:                //
304:                if (inValueCtcon != null
305:                        && inValueCtcon.isDynamicContextPresent()) {
306:                    //
307:                    DynamicConceptTagConstraintContext valueDctcc = inValueCtcon
308:                            .getDynamicConstraintContext();
309:                    valueDctcc.getValidator().filterDirectChildOfRootAndHtml();
310:                }
311:            }
312:
313:            public final static void initializeNameAndTypeCtcon(
314:                    ConceptTagConstraintOrTemplate inNameCtcot,
315:                    ConceptTagConstraintOrTemplate inTypeCtcot,
316:                    String inNameHandle, String inTypeHandle,
317:                    String inValueHandle, boolean inAssignToParent,
318:                    String inSphereHandle, int inSphereIndex) {
319:                //
320:                //
321:                //
322:                //
323:                //
324:                if (inNameCtcot != null) {
325:                    inNameCtcot.setMinimumLength(1);
326:                    inNameCtcot.setMaximumLength(1);
327:                    //
328:                    StaticConceptTagConstraintContext nameSctcc = StaticConceptTagConstraintContext
329:                            .newInstance(inNameCtcot);
330:                    nameSctcc.addDefaultValue("LocalVariable1");
331:                    nameSctcc.setMinimumStringLength(1);
332:                }
333:                //
334:                //
335:                //
336:                //
337:                //
338:                ConceptTagHelper.formatConcreteVariableType(inTypeCtcot, true);
339:                //inTypeCtcot.setMinimumLength(1);
340:                //inTypeCtcot.setMaximumLength(1);
341:                ////
342:                //StaticConceptTagConstraintContext typeSctcc =
343:                //    StaticConceptTagConstraintContext.newInstance(inTypeCtcot);
344:                //typeSctcc.setEntrySetExclusive(true);
345:                //typeSctcc.setEntrySetRefreshOnChange(true);
346:                ////
347:                ////HashMap ctdn = StandardDataTypes.getClassToDisplayName();
348:                //ArrayList variableTypes =
349:                //    StandardDataTypes.getAllConcreteVariableTypes();
350:                //for (int i = 0; i < variableTypes.size(); i++) {
351:                //    String nextType = ((String)variableTypes.get(i));
352:                //    if (i == 0) {
353:                //        typeSctcc.addDefaultValue(nextType);
354:                //    }
355:                //    typeSctcc.registerEntry(nextType, nextType);
356:                //}
357:                //addendSctcc.setRegularExpression(CommonExpressions.DECIMAL);
358:                inTypeCtcot
359:                        .registerPostValidator(PostConstraintValidatorForVarNameAndType
360:                                .newInstance(inNameHandle, inTypeHandle,
361:                                        inValueHandle, inAssignToParent,
362:                                        inSphereHandle, inSphereIndex));
363:            }
364:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.