Source Code Cross Referenced for ConceptTagConstraintHolder.java in  » Workflow-Engines » JFolder » org » jfolder » common » tagging » 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.tagging 
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.tagging;
009:
010:        //base classes
011:        import java.util.ArrayList;
012:        import java.util.Arrays;
013:        import java.util.HashMap;
014:        import java.util.List;
015:
016:        //project specific classes
017:        import org.jfolder.common.UnexpectedSystemException;
018:        import org.jfolder.common.utils.misc.MiscHelper;
019:        import org.jfolder.common.web.template.CreationResultParameterContext;
020:
021:        //other classes
022:
023:        public class ConceptTagConstraintHolder extends
024:                ConceptTagConstraintType {
025:
026:            private final static String COLON = ":";
027:
028:            //
029:            private InitializeConceptTagContext ictc = null;
030:            //private String handleCon = null;
031:            private boolean beenInitialized = false;
032:            //
033:            private HashMap ctconMap = null;
034:            private ArrayList ctconArray = null;
035:            //
036:            private ConceptTagConstraintHolder attrsCtconh = null;
037:            private ConceptTagConstraintHolder styleCtconh = null;
038:            //
039:            private ConceptTagConstraint undefinedCtcon = null;
040:            //private ConceptTagConstraintHolder undefinedCtconh = null;
041:            //
042:            private ConceptTagCharacteristicHolder ctcharh = null;
043:            //
044:            private ConceptTagConstraint parentCtcon = null;
045:            private ConceptTagConstraintHolder parentCtconh = null;
046:            //
047:            private CreationResultParameterContext initCrpc = null;
048:            private String initCrpcId[] = null;
049:
050:            private ConceptTagConstraintHolder(
051:                    //ConceptTagFlags inCtf,
052:                    ConceptTagPreferences inCtp,
053:                    ConceptTagCharacteristicHolder inCtcharh, boolean inStyles,
054:                    boolean inAttrs, ConceptTagConstraint inParentCtcon,
055:                    ConceptTagConstraintHolder inParentCtconh) {
056:
057:                super (inCtp);
058:                //
059:                this .ctcharh = inCtcharh;
060:                //
061:                this .parentCtcon = inParentCtcon;
062:                this .parentCtconh = inParentCtconh;
063:                //
064:                this .ctconMap = new HashMap();
065:                this .ctconArray = new ArrayList();
066:                //
067:                //this.ictc = inIctc;
068:                //this.handleCon = getPreferences().getHandleConjunction();
069:                this .beenInitialized = false;
070:                //
071:                String us = getPreferences().getUnconstrainedSymbol();
072:                //
073:                //
074:                if (inStyles) {
075:                    //
076:                    this .attrsCtconh = null;
077:                    this .styleCtconh = null;
078:                    this .undefinedCtcon = null;
079:                    //
080:                    this .setTitle("Styles");
081:                    this .setShortDescription("Styles");
082:                } else if (inAttrs) {
083:                    //
084:                    this .attrsCtconh = null;
085:                    this .styleCtconh = null;
086:                    this .undefinedCtcon = null;
087:                    //
088:                    this .setTitle("Attributes");
089:                    this .setShortDescription("Attributes");
090:                } else {
091:                    //
092:                    this .setTitle("Compound");
093:                    this .setShortDescription("Compound");
094:                    //this.setIcon("/jfolder/images/compound.gif");
095:                    //
096:                    this .attrsCtconh = new ConceptTagConstraintHolder(
097:                            getPreferences(), this .ctcharh.getAttributes(),
098:                            false, true, null, this );
099:                    this .styleCtconh = new ConceptTagConstraintHolder(
100:                            getPreferences(), this .ctcharh.getStyles(), true,
101:                            false, null, this );
102:                    //
103:                    this .undefinedCtcon = ConceptTagConstraint.newInstance(us,
104:                            this );
105:                    //
106:                    this .undefinedCtcon.setMinimumLength(0);
107:                    this .undefinedCtcon.setMaximumLength(0);
108:                    this .undefinedCtcon.setLengthUnbounded(false);
109:                    //
110:                    this .undefinedCtcon.setTitle("General Content");
111:                    this .undefinedCtcon.setShortDescription("General Content");
112:                    this .undefinedCtcon.setLongDescription("General Content");
113:                }
114:                //
115:                //this.ctcharh.setFlags(getFlags());
116:            }
117:
118:            protected final static ConceptTagConstraintHolder newInstance(
119:                    ConceptTagPreferences inCtp,
120:                    ConceptTagCharacteristicHolder inCtcharh,
121:                    ConceptTagConstraint inParentCtcon) {
122:
123:                return new ConceptTagConstraintHolder(inCtp, inCtcharh, false,
124:                        false, inParentCtcon, null);
125:            }
126:
127:            //
128:            public final static ConceptTagConstraintHolder newInstance(
129:                    InitializeConceptTagContext inIctc) {
130:
131:                return inIctc.getConstraintHolder();
132:            }
133:
134:            //
135:            //
136:            public boolean isParentErrorPresent() {
137:                return this .ctcharh.getParentMessageHolder().isErrorPresent();
138:            }
139:
140:            //
141:            public boolean isParentConstraintPresent() {
142:                return (this .parentCtcon != null);
143:            }
144:
145:            public ConceptTagConstraint getParentConstraint() {
146:                return this .parentCtcon;
147:            }
148:
149:            public ConceptTagConstraintHolder getParentConstraintHolder() {
150:                return this .parentCtconh;
151:            }
152:
153:            //public boolean isParentSubErrorPresent() {
154:            //    boolean outValue = false;
155:            //    for (int i = 0; i < getConstraintCount(); i++) {
156:            //        ConceptTagConstraint ctcon = getConstraint(i);
157:            //        outValue |= isSubErrorPresent(ctcon.getName());
158:            //    }
159:            //    if (this.attrsCtconh != null) {
160:            //        outValue |= this.attrsCtconh.isParentSubErrorPresent();
161:            //    }
162:            //    if (this.styleCtconh != null) {
163:            //        outValue |= this.styleCtconh.isParentSubErrorPresent();
164:            //    }
165:            //    if (this.undefinedCtcon != null) {
166:            //        outValue |= this.undefinedCtcon.isParentSubErrorPresent();
167:            //    }
168:            //    outValue |= isParentErrorPresent();
169:            //    return outValue;
170:            //}
171:            //public boolean isErrorPresent(String inName) {
172:            //    return this.ctcharh.getMessageHolder(inName).isErrorPresent();
173:            //}
174:            //public boolean isSubErrorPresent(String inName) {
175:            //    boolean outValue = false;
176:            //    
177:            //    ConceptTagConstraint ctcon = getConstraint(inName);
178:            //    outValue |= ctcon.isParentSubErrorPresent();
179:            //    //outValue |= isErrorPresent(inName);
180:            //    
181:            //    return outValue;
182:            //}
183:            //
184:            public void registerError(String inMessage) {
185:                MiscHelper.println("NI-Ctconh-regError " + inMessage);
186:            }
187:
188:            public void registerError(String inName, String inMessage) {
189:                MiscHelper.println("NI-Ctconh-regError " + inMessage + ", "
190:                        + inName);
191:            }
192:
193:            //
194:            public String getTitle() {
195:                String outValue = null;
196:                if (this .ctcharh.isConceptTagPresent()) {
197:                    ConceptTag ct = this .ctcharh.getConceptTag();
198:                    StudioConceptTagInstanceInfoContext sctiic = StudioConceptTagInstanceInfoContext
199:                            .newInstance();
200:                    ct.appraise(sctiic);
201:                    outValue = sctiic.getInstanceTitle();
202:                } else {
203:                    outValue = super .getTitle();
204:                }
205:                return outValue;
206:            }
207:
208:            public String getShortDescription() {
209:                String outValue = null;
210:                if (this .ctcharh.isConceptTagPresent()) {
211:                    ConceptTag ct = this .ctcharh.getConceptTag();
212:                    StudioConceptTagInstanceInfoContext sctiic = StudioConceptTagInstanceInfoContext
213:                            .newInstance();
214:                    ct.appraise(sctiic);
215:                    outValue = sctiic.getShortenedInstanceDescription(20);
216:                } else {
217:                    outValue = super .getShortDescription();
218:                }
219:                return outValue;
220:            }
221:
222:            public String getLongDescription() {
223:                String outValue = null;
224:                if (this .ctcharh.isConceptTagPresent()) {
225:                    ConceptTag ct = this .ctcharh.getConceptTag();
226:                    StudioConceptTagInstanceInfoContext sctiic = StudioConceptTagInstanceInfoContext
227:                            .newInstance();
228:                    ct.appraise(sctiic);
229:                    outValue = sctiic.getInstanceDescription();
230:                } else {
231:                    outValue = super .getLongDescription();
232:                }
233:                return outValue;
234:            }
235:
236:            public String getIcon() {
237:                String outValue = null;
238:                if (this .ctcharh.isConceptTagPresent()) {
239:                    ConceptTag ct = this .ctcharh.getConceptTag();
240:                    StudioConceptTagInstanceInfoContext sctiic = StudioConceptTagInstanceInfoContext
241:                            .newInstance();
242:                    ct.appraise(sctiic);
243:                    outValue = sctiic.getInstanceIcon();
244:                } else {
245:                    outValue = super .getIcon();
246:                }
247:                return outValue;
248:            }
249:
250:            //
251:            public ConceptTagCharacteristicHolder getCharacteristicHolder() {
252:                return this .ctcharh;
253:            }
254:
255:            protected InitializeConceptTagContext getInitializeContext() {
256:                return this .ictc;
257:            }
258:
259:            protected void validate(InitializeConceptTagContext inIctc) {
260:
261:                preValidationFlagPreparation(inIctc);
262:                //
263:
264:                if (!this .ctcharh.isInitialized()) {
265:                    //MiscHelper.println("Ctconh defaultInitialize");
266:                    //MiscHelper.println("Ctconh defInit attrs = " + getAttributes());
267:                    //MiscHelper.println("Ctconh defInit styles = " + getStyles());
268:                    //(new Exception()).printStackTrace();
269:                    defaultInitialize(inIctc);
270:                    this .ctcharh.setInitialized(true);
271:                }
272:
273:                //
274:                //clear errors and other messages
275:                this .ctcharh.getParentMessageHolder().reset();
276:                //for (int i = 0; i < getConstraintCount(); i++) {
277:                //    ConceptTagConstraint nextCtcon = getConstraint(i);
278:                //    this.ctcharh.getMessageHolder(nextCtcon.getName()).reset();
279:                //}
280:                //
281:
282:                if (this .attrsCtconh != null) {
283:                    this .attrsCtconh.validate(inIctc);
284:                }
285:                if (this .styleCtconh != null) {
286:                    this .styleCtconh.validate(inIctc);
287:                }
288:                for (int i = 0; i < getConstraintCount(); i++) {
289:                    ConceptTagConstraint nextCtcon = getConstraint(i);
290:                    nextCtcon.validate(inIctc);
291:                }
292:                if (this .undefinedCtcon != null) {
293:                    this .undefinedCtcon.validate(inIctc);
294:                }
295:
296:                //assign error to characteristics not assigned to constraints
297:                //TO DO: implement
298:                for (int i = 0; i < this .ctcharh.getCharacteristicCount(); i++) {
299:                    ConceptTagCharacteristic nextCtchar = this .ctcharh
300:                            .getCharacteristic(i);
301:                    if (!isConstraintPresent(nextCtchar.getConstraintName())) {
302:                        MiscHelper
303:                                .println("ConTagConsHolder @@@@@Unknown Ctchar = "
304:                                        + nextCtchar.getConstraintName());
305:                    }
306:                }
307:
308:                //
309:                //
310:                postValidationFlagPreparation(inIctc);
311:            }
312:
313:            protected void defaultInitialize(InitializeConceptTagContext inIctc) {
314:                //if (this.attrsCtconh != null) {
315:                //    this.attrsCtconh.defaultInitialize(inIctc);
316:                //}
317:                //if (this.styleCtconh != null) {
318:                //    this.styleCtconh.defaultInitialize(inIctc);
319:                //}
320:                for (int i = 0; i < getConstraintCount(); i++) {
321:                    ConceptTagConstraint nextCtcon = getConstraint(i);
322:                    nextCtcon.defaultInitialize(inIctc);
323:                }
324:                if (this .undefinedCtcon != null) {
325:                    this .undefinedCtcon.defaultInitialize(inIctc);
326:                }
327:            }
328:
329:            //public void addValue(String inCode, Object inValue) {
330:            //    ConceptTagCharacteristic finalTc = getParentCharacteristic(inCode);
331:            //    int finalTcIndex = Integer.parseInt(inCode.substring(
332:            //        inCode.lastIndexOf(this.handleCon) + 1));
333:            //    finalTc.addValue(finalTcIndex, inValue);
334:            //}
335:
336:            //public void addValue(String inCode, int inIndex, Object inValue) {
337:            //    ConceptTagCharacteristic finalTc = getParentCharacteristic(inCode);
338:            //    finalTc.addValue(inIndex, inValue);
339:            //}
340:
341:            //public void removeValue(String inCode) {
342:            //    ConceptTagCharacteristic finalTc = getParentCharacteristic(inCode);
343:            //    int finalTcIndex = Integer.parseInt(inCode.substring(
344:            //        inCode.lastIndexOf(this.handleCon) + 1));
345:            //    finalTc.removeValue(finalTcIndex);
346:            //}
347:
348:            //public void removeValue(String inCode, int inIndex) {
349:            //    ConceptTagCharacteristic finalTc = getParentCharacteristic(inCode);
350:            //    finalTc.removeValue(inIndex);
351:            //}
352:
353:            protected boolean isInitialized() {
354:                return this .beenInitialized;
355:            }
356:
357:            public ConceptTagConstraintHolder getAttributes() {
358:
359:                ConceptTagConstraintHolder outValue = null;
360:
361:                //if (this.attrsCtconh != null) {
362:                outValue = this .attrsCtconh;
363:                //}
364:                //else {
365:                //    throw new UnexpectedSystemException("Attributes Not Preset");
366:                //}
367:
368:                return outValue;
369:            }
370:
371:            public ConceptTagConstraintHolder getStyles() {
372:
373:                ConceptTagConstraintHolder outValue = null;
374:
375:                //if (this.styleCtconh != null) {
376:                outValue = this .styleCtconh;
377:                //}
378:                //else {
379:                //    throw new UnexpectedSystemException("Styles Not Preset");
380:                //}
381:
382:                return outValue;
383:            }
384:
385:            protected void registerConstraint(ConceptTagConstraint inCtcon) {
386:                this .registerConstraint(inCtcon.getName(), inCtcon);
387:            }
388:
389:            private void registerConstraint(String inName,
390:                    ConceptTagConstraint inCtcon) {
391:
392:                String attrName = getPreferences().getAttributeConstraintName();
393:                String styleName = getPreferences().getStyleConstraintName();
394:                String undefName = getPreferences().getUnconstrainedSymbol();
395:
396:                if (inName.equals(undefName) && (this .undefinedCtcon == null)
397:                        && (this .styleCtconh != null)
398:                        && (this .attrsCtconh != null)) {
399:                    //ignore, it's already been registered in constructor
400:
401:                    //these conditions are only true for the first time registry
402:                    //of the undefined constraint for a non-attrs and non-style ctconh
403:                } else if (inName.equals(attrName)) {
404:                    throw new UnexpectedSystemException("'" + attrName
405:                            + "' is a reserved constraint");
406:                } else if (inName.equals(styleName)) {
407:                    throw new UnexpectedSystemException("'" + styleName
408:                            + "' is a reserved constraint");
409:                } else if (inName.equals(undefName)) {
410:                    throw new UnexpectedSystemException("'" + undefName
411:                            + "' is a reserved constraint");
412:                } else if (!(this .ctconMap.containsKey(inName))) {
413:                    this .ctconMap.put(inName, inCtcon);
414:                    this .ctconArray.add(inName);
415:                } else {
416:                    throw new UnexpectedSystemException("Constraint '" + inName
417:                            + "' already registered");
418:                }
419:            }
420:
421:            //
422:            protected void removeConstraint(String inName) {
423:                if (this .ctconMap.containsKey(inName)) {
424:                    this .ctconMap.remove(inName);
425:                    this .ctconArray.remove(inName);
426:                } else {
427:                    throw new UnexpectedSystemException("'" + inName
428:                            + "' not found");
429:                }
430:            }
431:
432:            //
433:            public boolean isConstraintPresent(String inName) {
434:                return this .ctconMap.containsKey(inName);
435:            }
436:
437:            public ConceptTagConstraint getConstraint(String inName) {
438:
439:                ConceptTagConstraint outValue = null;
440:
441:                if (this .ctconMap.containsKey(inName)) {
442:                    Object o = this .ctconMap.get(inName);
443:                    outValue = ((ConceptTagConstraint) o);
444:                } else {
445:                    ConceptTagCharacteristicHolder localCtcharh = getCharacteristicHolder();
446:                    if (localCtcharh.isConceptTagPresent()) {
447:                        throw new UnexpectedSystemException("'" + inName
448:                                + "' not found for concept tag "
449:                                + localCtcharh.getConceptTag().getClass());
450:                    } else if (isParentConstraintPresent()) {
451:                        ConceptTagConstraint localCtcon = getParentConstraint();
452:                        Class parentClass[] = new Class[1];
453:                        String parentHeir[] = ConceptTagHelper
454:                                .getLocalConstraintHeirarchy(localCtcon
455:                                        .getCharacteristic(), parentClass);
456:                        throw new UnexpectedSystemException("'"
457:                                + inName
458:                                + "' not found for concept tag "
459:                                + parentClass[0]
460:                                + " for heirarchy "
461:                                + MiscHelper.reassembleHandle(new ArrayList(
462:                                        Arrays.asList(parentHeir)), ","));
463:                    } else {
464:                        if (localCtcharh.isAttributesType()) {
465:                            ConceptTagCharacteristicHolder parentCtcharh = localCtcharh
466:                                    .getParentCharacteristicHolder();
467:                            throw new UnexpectedSystemException("'" + inName
468:                                    + "' not found in attrs for concept tag "
469:                                    + parentCtcharh.getConceptTag().getClass());
470:                        } else if (localCtcharh.isStylesType()) {
471:                            ConceptTagCharacteristicHolder parentCtcharh = localCtcharh
472:                                    .getParentCharacteristicHolder();
473:                            throw new UnexpectedSystemException("'" + inName
474:                                    + "' not found in styles for concept tag "
475:                                    + parentCtcharh.getConceptTag().getClass());
476:                        } else {
477:                            throw new UnexpectedSystemException("'" + inName
478:                                    + "' not found, but unknown parent");
479:                        }
480:                    }
481:                }
482:
483:                return outValue;
484:            }
485:
486:            public int getConstraintCount() {
487:                return this .ctconArray.size();
488:            }
489:
490:            public ConceptTagConstraint getConstraint(int inIndex) {
491:
492:                ConceptTagConstraint outValue = null;
493:
494:                String tagName = (String) this .ctconArray.get(inIndex);
495:                outValue = (ConceptTagConstraint) this .ctconMap.get(tagName);
496:
497:                return outValue;
498:            }
499:
500:            //
501:            public ConceptTagConstraint getUndefinedConstraint() {
502:
503:                ConceptTagConstraint outValue = null;
504:
505:                //if (this.undefinedCtcon != null) {
506:                outValue = this .undefinedCtcon;
507:                //}
508:                //else {
509:                //    throw new UnexpectedSystemException(
510:                //        "No Undefined Constraint Present");
511:                //}
512:
513:                return outValue;
514:            }
515:
516:            //
517:            //
518:            //
519:            protected boolean isInitCreationResultPresent() {
520:                return (this .initCrpc != null && this .initCrpcId != null);
521:            }
522:
523:            protected Object getInitCreationResult() {
524:
525:                Object outValue[] = new Object[2];
526:
527:                outValue[0] = this .initCrpc;
528:                outValue[1] = this .initCrpcId;
529:
530:                return outValue;
531:            }
532:
533:            protected void setInitCreationResult(
534:                    CreationResultParameterContext inCrpc, String inCrpcId[]) {
535:
536:                this.initCrpc = inCrpc;
537:                this.initCrpcId = inCrpcId;
538:            }
539:
540:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.