Source Code Cross Referenced for ConceptTagSetHolder.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.HashMap;
013:        import java.util.HashSet;
014:        import java.util.Iterator;
015:
016:        //project specific classes
017:        import org.jfolder.common.SelfArgumentlessConstructor;
018:        import org.jfolder.common.UnexpectedSystemException;
019:        import org.jfolder.common.utils.misc.MiscHelper;
020:
021:        //other classes
022:
023:        public class ConceptTagSetHolder {
024:
025:            //
026:            private HashMap ctClassToName = null;
027:            private HashMap ctClassToNs = null;
028:            private HashMap ctNameAndNsToClass = null;
029:            //
030:            private HashSet ctSetHolderNamespaces = null;
031:            private String ctSetHolderOriginalNamespace = null;
032:            //
033:            //private HashMap ctUnconstrainedOnly = null;
034:            //private HashMap ctStudioOnly = null;
035:            private HashMap ctProperties = null;
036:            //
037:            private HashMap ctTitle = null;
038:            private HashMap ctShortDescription = null;
039:            //
040:            private ConceptTagMenuBranch ctmb = null;
041:            //
042:            private HashMap ctClassToCt = null;
043:
044:            public ConceptTagSetHolder(String inCtNamespace) {
045:
046:                //
047:                this .ctClassToName = new HashMap();
048:                this .ctClassToNs = new HashMap();
049:                this .ctNameAndNsToClass = new HashMap();
050:                //
051:                this .ctSetHolderNamespaces = new HashSet();
052:                this .ctSetHolderNamespaces.add(inCtNamespace);
053:                this .ctSetHolderOriginalNamespace = inCtNamespace;
054:                //
055:                //this.ctUnconstrainedOnly = new HashMap();
056:                //this.ctStudioOnly = new HashMap();
057:                this .ctProperties = new HashMap();
058:                //
059:                this .ctTitle = new HashMap();
060:                this .ctShortDescription = new HashMap();
061:                //
062:                this .ctmb = new ConceptTagMenuBranch(this );
063:                //
064:                this .ctClassToCt = new HashMap();
065:            }
066:
067:            //
068:            public String getCtOriginalNamespace() {
069:                return this .ctSetHolderOriginalNamespace;
070:            }
071:
072:            protected HashSet getCtNamespaces() {
073:                return new HashSet(this .ctSetHolderNamespaces);
074:            }
075:
076:            public void addSetHolder(ConceptTagSetHolder inCtsh) {
077:
078:                //HashSet retainSet = this.getCtNamespaces();
079:                //retainSet.retainAll(inCtsh.getCtNamespaces());
080:                ////
081:                //if (retainSet.size() > 0) {
082:                //}
083:
084:                this .ctSetHolderNamespaces.addAll(inCtsh.getCtNamespaces());
085:
086:                ArrayList namespaces = inCtsh.getRegisteredNameSpaces();
087:                for (int i = 0; i < namespaces.size(); i++) {
088:
089:                    String nextNs = (String) namespaces.get(i);
090:                    ArrayList names = inCtsh.getRegisteredNames(nextNs);
091:                    for (int j = 0; j < names.size(); j++) {
092:
093:                        String nextName = (String) names.get(j);
094:
095:                        String nextClass = inCtsh.getConceptTagClassAsString(
096:                                nextNs, nextName);
097:                        ConceptTagProperties nextProps = inCtsh
098:                                .getConceptTagProperties(nextClass);
099:
100:                        //checks here
101:                        if (isConceptTagSetClassPresent(nextNs, nextName)
102:                                || isConceptTagSetNamePresent(nextClass)
103:                                || isConceptTagSetNamespacePresent(nextClass)) {
104:                            //
105:                            throw new UnexpectedSystemException("Set Holder '"
106:                                    + getCtOriginalNamespace()
107:                                    + "', already contains either class '"
108:                                    + nextClass + "' or (namespace, name) ('"
109:                                    + nextNs + "', '" + nextName
110:                                    + "') that is found in Set Holder '"
111:                                    + inCtsh.getCtOriginalNamespace() + "'");
112:                        }
113:
114:                        //
115:                        registerConceptTag(nextNs, nextName, nextClass,
116:                                nextProps);
117:                    }
118:                }
119:            }
120:
121:            public final ConceptTagMenuBranch getMenuBranch() {
122:                return this .ctmb;
123:            }
124:
125:            public final void registerConceptTag(String inNs, String inName,
126:                    String inClass, ConceptTagProperties inCtprops) {
127:
128:                try {
129:                    //see if class exists
130:                    Class.forName(inClass);
131:
132:                    //load values
133:                    HashMap ctNameToClass = null;
134:                    if (this .ctNameAndNsToClass.containsKey(inNs)) {
135:                        ctNameToClass = (HashMap) this .ctNameAndNsToClass
136:                                .get(inNs);
137:                    } else {
138:                        ctNameToClass = new HashMap();
139:                        this .ctNameAndNsToClass.put(inNs, ctNameToClass);
140:                    }
141:
142:                    ctNameToClass.put(inName, inClass);
143:                    this .ctClassToName.put(inClass, inName);
144:                    this .ctClassToNs.put(inClass, inNs);
145:                    //
146:                    this .ctProperties.put(inClass, inCtprops);
147:                    //this.ctUnconstrainedOnly.put(inClass, inUnconstrainedOnly);
148:                    //this.ctStudioOnly.put(inClass, inStudioOnly);
149:                    this .ctmb.initialize(inNs, inName, inCtprops.getMenuPath());
150:                } catch (ClassNotFoundException cnfe) {
151:                    throw new UnexpectedSystemException(
152:                            ("Class (" + inClass + ") for concept tag (" + inNs
153:                                    + ":" + inName + ") could not be found"),
154:                            cnfe);
155:                }
156:            }
157:
158:            public ArrayList getRegisteredNameSpaces() {
159:
160:                ArrayList outValue = new ArrayList();
161:
162:                Iterator iter = this .ctNameAndNsToClass.keySet().iterator();
163:                while (iter.hasNext()) {
164:                    outValue.add(iter.next());
165:                }
166:
167:                return outValue;
168:            }
169:
170:            public ArrayList getRegisteredNames(String inNs) {
171:
172:                ArrayList outValue = new ArrayList();
173:
174:                HashMap ctNameToClass = (HashMap) this .ctNameAndNsToClass
175:                        .get(inNs);
176:                Iterator iter = ctNameToClass.keySet().iterator();
177:                while (iter.hasNext()) {
178:                    outValue.add(iter.next());
179:                }
180:
181:                return outValue;
182:            }
183:
184:            public final boolean isConceptTagSetNamePresent(String inClass) {
185:                return this .ctClassToName.containsKey(inClass);
186:            }
187:
188:            public final boolean isConceptTagSetNamespacePresent(String inClass) {
189:                return this .ctClassToNs.containsKey(inClass);
190:            }
191:
192:            public final boolean isConceptTagSetClassPresent(String inNs,
193:                    String inName) {
194:
195:                boolean outValue = false;
196:
197:                //MiscHelper.println("ConTagSetHol ctNameAndNsToClass = "
198:                //    + this.ctNameAndNsToClass);
199:                if (this .ctNameAndNsToClass.containsKey(inNs)) {
200:                    HashMap ctNameToClass = (HashMap) this .ctNameAndNsToClass
201:                            .get(inNs);
202:                    //MiscHelper.println("ConTagSetHol ctNameToClass = "
203:                    //    + ctNameToClass);
204:                    outValue = ctNameToClass.containsKey(inName);
205:                    //String ctClassText = (String)ctNameToClass.get(inName);
206:                    //if (ctClassText != null) {
207:                    //    outValue = true;
208:                    //}
209:                }
210:
211:                return outValue;
212:            }
213:
214:            public final String getConceptTagClassAsString(String inNs,
215:                    String inName) {
216:
217:                String outValue = null;
218:
219:                HashMap ctNameToClass = null;
220:                if (this .ctNameAndNsToClass.containsKey(inNs)) {
221:                    ctNameToClass = (HashMap) this .ctNameAndNsToClass.get(inNs);
222:                } else {
223:                    throw new UnexpectedSystemException(
224:                            "No concept tags in namespace " + inNs);
225:                }
226:                //MiscHelper.println("ctNameAndNamespaceToClass = "
227:                //    + this.ctNameAndNamespaceToClass);
228:                //MiscHelper.println("ctNameToClass = " + ctNameToClass);
229:
230:                if (ctNameToClass.containsKey(inName)) {
231:                    outValue = (String) ctNameToClass.get(inName);
232:                } else {
233:                    throw new UnexpectedSystemException("No concept tag ("
234:                            + inName + ") in namespace (" + inNs + ")");
235:                }
236:
237:                return outValue;
238:            }
239:
240:            public final Class getConceptTagClass(String inNs, String inName) {
241:
242:                try {
243:                    Class outValue = null;
244:
245:                    String ctClassText = getConceptTagClassAsString(inNs,
246:                            inName);
247:
248:                    outValue = Class.forName(ctClassText);
249:
250:                    return outValue;
251:                } catch (ClassNotFoundException cnfe) {
252:                    throw new UnexpectedSystemException(
253:                            "Class for concept tag (" + inNs + ":" + inName
254:                                    + ") could not be found", cnfe);
255:                }
256:            }
257:
258:            public final String getConceptTagNamespace(String inClass) {
259:
260:                String outValue = null;
261:
262:                //String ctClassName = inClass.getName();
263:
264:                if (this .ctClassToNs.containsKey(inClass)) {
265:                    outValue = (String) this .ctClassToNs.get(inClass);
266:                } else {
267:                    throw new UnexpectedSystemException(
268:                            "Namespace for concept tag (" + inClass
269:                                    + ") could not be found");
270:                }
271:
272:                //if (outValue == null) {
273:                //    throw new UnexpectedSystemException("");
274:                //}
275:
276:                return outValue;
277:            }
278:
279:            public final String getConceptTagName(String inClass) {
280:
281:                String outValue = null;
282:
283:                //String ctClassName = inClass.getName();
284:
285:                if (this .ctClassToName.containsKey(inClass)) {
286:                    outValue = (String) this .ctClassToName.get(inClass);
287:                } else {
288:                    throw new UnexpectedSystemException(
289:                            "Name for concept tag (" + inClass
290:                                    + ") could not be found");
291:                }
292:
293:                //if (outValue == null) {
294:                //    throw new UnexpectedSystemException("");
295:                //}
296:
297:                return outValue;
298:            }
299:
300:            public final ConceptTagProperties getConceptTagProperties(
301:                    String inClass) {
302:
303:                ConceptTagProperties outValue = null;
304:
305:                //String ctClassName = inClass.getName();
306:
307:                if (this .ctProperties.containsKey(inClass)) {
308:                    outValue = (ConceptTagProperties) this .ctProperties
309:                            .get(inClass);
310:                } else {
311:                    throw new UnexpectedSystemException(
312:                            "Properties for concept tag (" + inClass
313:                                    + ") could not be found");
314:                }
315:
316:                //if (outValue == null) {
317:                //    throw new UnexpectedSystemException("");
318:                //}
319:
320:                return outValue;
321:            }
322:
323:            //public final boolean isUnconstrainedOnly(String inClass) {
324:            //    
325:            //    boolean outValue = false;
326:            //    
327:            //    Object o = this.ctUnconstrainedOnly.get(inClass);
328:            //    outValue = ((Boolean)o).booleanValue();
329:            //    
330:            //    return outValue;
331:            //}
332:
333:            //public final boolean isStudioOnly(String inClass) {
334:            //    
335:            //    boolean outValue = false;
336:            //    
337:            //    Object o = this.ctStudioOnly.get(inClass);
338:            //    outValue = ((Boolean)o).booleanValue();
339:            //    
340:            //    return outValue;
341:            //}
342:
343:            public String getTypeTitle(String inClass) {
344:
345:                String outValue = null;
346:
347:                if (this .ctTitle.containsKey(inClass)) {
348:                    outValue = (String) this .ctTitle.get(inClass);
349:                } else {
350:                    Class ctClass = MiscHelper.getClassByName(inClass);
351:                    ConceptTag conceptTag = getConceptTagFromClass(ctClass);
352:                    StudioConceptTagTypeInfoContext scttic = StudioConceptTagTypeInfoContext
353:                            .newInstance();
354:                    conceptTag.appraise(scttic);
355:                    outValue = scttic.getTypeTitle();
356:                    this .ctTitle.put(inClass, outValue);
357:                }
358:
359:                return outValue;
360:            }
361:
362:            public String getTypeShortDescription(String inClass) {
363:
364:                String outValue = null;
365:
366:                if (this .ctShortDescription.containsKey(inClass)) {
367:                    outValue = (String) this .ctShortDescription.get(inClass);
368:                } else {
369:                    Class ctClass = MiscHelper.getClassByName(inClass);
370:                    ConceptTag conceptTag = getConceptTagFromClass(ctClass);
371:                    StudioConceptTagTypeInfoContext scttic = StudioConceptTagTypeInfoContext
372:                            .newInstance();
373:                    conceptTag.appraise(scttic);
374:                    outValue = scttic.getTypeDescription();
375:                    this .ctShortDescription.put(inClass, outValue);
376:                }
377:
378:                return outValue;
379:            }
380:
381:            public final ConceptTag getConceptTagFromClass(Class inClass) {
382:
383:                ConceptTag outValue = null;
384:
385:                if (SelfArgumentlessConstructor.class.isAssignableFrom(inClass)) {
386:                    if (this .ctClassToCt.containsKey(inClass)) {
387:                        Object o = this .ctClassToCt.get(inClass);
388:                        SelfArgumentlessConstructor sac = ((SelfArgumentlessConstructor) o);
389:                        outValue = ((ConceptTag) sac.createUninitializedSelf());
390:                    } else {
391:                        outValue = ((ConceptTag) MiscHelper
392:                                .newInstance(inClass));
393:                        this .ctClassToCt.put(inClass, outValue);
394:                    }
395:                } else {
396:                    outValue = ((ConceptTag) MiscHelper.newInstance(inClass));
397:                }
398:
399:                return outValue;
400:            }
401:
402:            public final SelectionCriteriaForConceptTag getSelectionCriteria(
403:                    Class inClass) {
404:                //
405:                SelectionCriteriaForConceptTag outValue = null;
406:
407:                ConceptTag ct = getConceptTagFromClass(inClass);
408:                outValue = SelectionCriteriaForConceptTag.newInstance(ct);
409:
410:                return outValue;
411:            }
412:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.