Source Code Cross Referenced for ConceptTagMessageHolder.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.Collections;
013:        import java.util.HashMap;
014:
015:        //project specific classes
016:        import org.jfolder.common.utils.misc.MiscHelper;
017:
018:        //other classes
019:
020:        public class ConceptTagMessageHolder {
021:
022:            //
023:            public final static int INFORMATION = 1;
024:            public final static int WARNING = 2;
025:            public final static int ERROR = 3;
026:            //
027:            private ArrayList headerMessage = null;
028:            private HashMap indexMessages = null;
029:            private HashMap nameMessages = null;
030:            //
031:            private Boolean cachedErrorPresent = null;
032:            private Boolean cachedWarningPresent = null;
033:
034:            protected ConceptTagMessageHolder() {
035:                reset();
036:            }
037:
038:            public void pr() {
039:                MiscHelper.println("  - headerMessage = " + this .headerMessage);
040:                MiscHelper.println("  - indexMessages = " + this .indexMessages);
041:                MiscHelper.println("  - nameMessages = " + this .nameMessages);
042:                MiscHelper.println("  (REMOVE THIS)");
043:            }
044:
045:            public void reset() {
046:                this .headerMessage = new ArrayList();
047:                this .indexMessages = new HashMap();
048:                this .nameMessages = new HashMap();
049:                //
050:                this .cachedErrorPresent = null;
051:                this .cachedWarningPresent = null;
052:                //MiscHelper.println("CtMessHol - reset not implemented");
053:                //(new Exception()).printStackTrace();
054:            }
055:
056:            //
057:            public boolean isMessagePresent() {
058:                return (this .headerMessage.size() > 0
059:                        && this .indexMessages.size() > 0 && this .nameMessages
060:                        .size() > 0);
061:            }
062:
063:            //
064:            public int getHeaderMessageCount() {
065:                return this .headerMessage.size();
066:            }
067:
068:            //
069:            public void addInformationHeaderMessage(String inMessage) {
070:                addTypeAndMessage(this .headerMessage, INFORMATION, inMessage);
071:            }
072:
073:            public void addWarningHeaderMessage(String inMessage) {
074:                addTypeAndMessage(this .headerMessage, WARNING, inMessage);
075:            }
076:
077:            public void addErrorHeaderMessage(String inMessage) {
078:                addTypeAndMessage(this .headerMessage, ERROR, inMessage);
079:            }
080:
081:            //
082:            public String getHeaderMessage(int inIndex) {
083:                return getMessage(this .headerMessage, inIndex);
084:            }
085:
086:            public boolean isInformationHeaderMessage(int inIndex) {
087:                return isInformation(inIndex, this .headerMessage);
088:            }
089:
090:            public boolean isWarningHeaderMessage(int inIndex) {
091:                return isWarning(inIndex, this .headerMessage);
092:            }
093:
094:            public boolean isErrorHeaderMessage(int inIndex) {
095:                return isError(inIndex, this .headerMessage);
096:            }
097:
098:            //
099:            public ArrayList getAllIndexes() {
100:                return new ArrayList(this .indexMessages.keySet());
101:            }
102:
103:            public int getTotalIndexMessageCount(int inIndex) {
104:                return getIndexArray(inIndex).size();
105:            }
106:
107:            public String getIndexMessage(int inParentIndex, int inIndex) {
108:                return getMessage(getIndexArray(inParentIndex), inIndex);
109:            }
110:
111:            public boolean isInformationIndexMessage(int inParentIndex,
112:                    int inIndex) {
113:                return isInformation(inIndex, getIndexArray(inParentIndex));
114:            }
115:
116:            public boolean isWarningIndexMessage(int inParentIndex, int inIndex) {
117:                return isWarning(inIndex, getIndexArray(inParentIndex));
118:            }
119:
120:            public boolean isErrorIndexMessage(int inParentIndex, int inIndex) {
121:                return isError(inIndex, getIndexArray(inParentIndex));
122:            }
123:
124:            public void addInformationIndexMessage(String inMessage, int inIndex) {
125:                addTypeAndMessage(getIndexArray(inIndex), INFORMATION,
126:                        inMessage);
127:            }
128:
129:            public void addWarningIndexMessage(String inMessage, int inIndex) {
130:                addTypeAndMessage(getIndexArray(inIndex), WARNING, inMessage);
131:            }
132:
133:            public void addErrorIndexMessage(String inMessage, int inIndex) {
134:                addTypeAndMessage(getIndexArray(inIndex), ERROR, inMessage);
135:            }
136:
137:            private ArrayList getIndexArray(int inIndex) {
138:
139:                ArrayList outValue = null;
140:
141:                Integer index = new Integer(inIndex);
142:
143:                if (this .indexMessages.containsKey(index)) {
144:                    outValue = (ArrayList) this .indexMessages.get(index);
145:                } else {
146:                    outValue = new ArrayList();
147:                    this .indexMessages.put(index, outValue);
148:                }
149:
150:                return outValue;
151:            }
152:
153:            //
154:            public ArrayList getAllNames() {
155:                return new ArrayList(this .nameMessages.keySet());
156:            }
157:
158:            public int getTotalNameMessageCount(String inName) {
159:                return getNameArray(inName).size();
160:            }
161:
162:            public String getNameMessage(String inName, int inIndex) {
163:                return getMessage(getNameArray(inName), inIndex);
164:            }
165:
166:            public boolean isInformationNameMessage(String inName, int inIndex) {
167:                return isInformation(inIndex, getNameArray(inName));
168:            }
169:
170:            public boolean isWarningNameMessage(String inName, int inIndex) {
171:                return isWarning(inIndex, getNameArray(inName));
172:            }
173:
174:            public boolean isErrorNameMessage(String inName, int inIndex) {
175:                return isError(inIndex, getNameArray(inName));
176:            }
177:
178:            public void addInformationNameMessage(String inMessage,
179:                    String inName) {
180:                addTypeAndMessage(getNameArray(inName), INFORMATION, inMessage);
181:            }
182:
183:            public void addWarningNameMessage(String inMessage, String inName) {
184:                addTypeAndMessage(getNameArray(inName), WARNING, inMessage);
185:            }
186:
187:            public void addErrorNameMessage(String inMessage, String inName) {
188:                addTypeAndMessage(getNameArray(inName), ERROR, inMessage);
189:            }
190:
191:            private ArrayList getNameArray(String inName) {
192:
193:                ArrayList outValue = null;
194:
195:                if (this .nameMessages.containsKey(inName)) {
196:                    outValue = (ArrayList) this .nameMessages.get(inName);
197:                } else {
198:                    outValue = new ArrayList();
199:                    this .nameMessages.put(inName, outValue);
200:                }
201:
202:                return outValue;
203:            }
204:
205:            //
206:            public boolean isErrorPresent() {
207:                return isErrorOrWarningPresent(true);
208:            }
209:
210:            public boolean isWarningPresent() {
211:                return isErrorOrWarningPresent(false);
212:            }
213:
214:            private boolean isErrorOrWarningPresent(boolean inCheckForErrors) {
215:
216:                boolean outValue = false;
217:
218:                if ((inCheckForErrors && this .cachedErrorPresent == null)
219:                        || (!inCheckForErrors && this .cachedWarningPresent == null)) {
220:                    //
221:                    boolean result = false;
222:
223:                    //
224:                    for (int i = 0; i < getHeaderMessageCount(); i++) {
225:                        if (inCheckForErrors) {
226:                            result |= isErrorHeaderMessage(i);
227:                        } else {
228:                            result |= isWarningHeaderMessage(i);
229:                        }
230:                    }
231:                    //
232:                    ArrayList localNames = getAllNames();
233:                    for (int i = 0; i < localNames.size(); i++) {
234:                        String nextName = (String) localNames.get(i);
235:                        for (int j = 0; j < getTotalNameMessageCount(nextName); j++) {
236:                            if (inCheckForErrors) {
237:                                result |= isErrorNameMessage(nextName, j);
238:                            } else {
239:                                result |= isWarningNameMessage(nextName, j);
240:                            }
241:                        }
242:                    }
243:                    //
244:                    ArrayList localIndexes = getAllIndexes();
245:                    for (int i = 0; i < localIndexes.size(); i++) {
246:                        int nextIndex = ((Integer) localIndexes.get(i))
247:                                .intValue();
248:                        for (int j = 0; j < getTotalIndexMessageCount(nextIndex); j++) {
249:                            if (inCheckForErrors) {
250:                                result |= isErrorIndexMessage(nextIndex, j);
251:                            } else {
252:                                result |= isWarningIndexMessage(nextIndex, j);
253:                            }
254:                        }
255:                    }
256:                    //
257:                    //
258:                    //
259:                    if (inCheckForErrors) {
260:                        this .cachedErrorPresent = new Boolean(result);
261:                    } else {
262:                        this .cachedWarningPresent = new Boolean(result);
263:                    }
264:                }
265:                //
266:                //
267:                //
268:                if (inCheckForErrors) {
269:                    outValue = this .cachedErrorPresent.booleanValue();
270:                } else {
271:                    outValue = this .cachedWarningPresent.booleanValue();
272:                }
273:
274:                return outValue;
275:            }
276:
277:            //
278:            private boolean isInformation(int inIndex, ArrayList inList) {
279:                return (getType(inList, inIndex) == INFORMATION);
280:            }
281:
282:            private boolean isWarning(int inIndex, ArrayList inList) {
283:                return (getType(inList, inIndex) == WARNING);
284:            }
285:
286:            private boolean isError(int inIndex, ArrayList inList) {
287:                return (getType(inList, inIndex) == ERROR);
288:            }
289:
290:            private int getType(ArrayList inList, int inIndex) {
291:
292:                int outValue = 0;
293:
294:                Object o[] = (Object[]) inList.get(inIndex);
295:                outValue = ((Integer) o[0]).intValue();
296:
297:                return outValue;
298:            }
299:
300:            private String getMessage(ArrayList inList, int inIndex) {
301:
302:                String outValue = null;
303:
304:                Object o[] = (Object[]) inList.get(inIndex);
305:                outValue = ((String) o[1]);
306:
307:                return outValue;
308:            }
309:
310:            private void addTypeAndMessage(ArrayList inList, int inType,
311:                    String inMessage) {
312:
313:                Object o[] = new Object[2];
314:
315:                o[0] = new Integer(inType);
316:                o[1] = inMessage;
317:
318:                inList.add(o);
319:            }
320:
321:            public String toString() {
322:
323:                StringBuffer outValue = new StringBuffer();
324:
325:                outValue.append("\n");
326:                outValue.append("  - this.headerMessage = "
327:                        + this .headerMessage);
328:                outValue.append("  - this.indexMessages = "
329:                        + this .indexMessages);
330:                outValue.append("  - this.nameMessages = " + this.nameMessages);
331:
332:                return outValue.toString();
333:            }
334:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.