Source Code Cross Referenced for InspectorDescriptorStack.java in  » Code-Analyzer » hammurapi-3.20.0.3 » org » hammurapi » 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 » Code Analyzer » hammurapi 3.20.0.3 » org.hammurapi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Hammurapi
003:         * Automated Java code review system. 
004:         * Copyright (C) 2004  Hammurapi Group
005:         *
006:         * This program is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU General Public License as published by
008:         * the Free Software Foundation; either version 2 of the License, or
009:         *  (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         *
020:         * URL: http://www.hammurapi.org
021:         * e-Mail: support@hammurapi.biz
022:         */
023:        package org.hammurapi;
024:
025:        import java.util.Collection;
026:        import java.util.Collections;
027:        import java.util.HashSet;
028:        import java.util.Iterator;
029:        import java.util.LinkedList;
030:        import java.util.Set;
031:
032:        import com.pavelvlasov.config.ConfigurationException;
033:        import com.pavelvlasov.config.Parameterizable;
034:
035:        /**
036:         * Contains information from multiple descriptors. Returns first not-null
037:         * value from the stack.
038:         * @author Pavel Vlasov	
039:         * @version $Revision: 1.6 $
040:         */
041:        public class InspectorDescriptorStack implements  InspectorDescriptor {
042:            private LinkedList stack = new LinkedList();
043:
044:            public String getDescription() {
045:                Iterator it = stack.iterator();
046:                while (it.hasNext()) {
047:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
048:                            .next();
049:                    if (descriptor.getDescription() != null) {
050:                        return descriptor.getDescription();
051:                    }
052:                }
053:                return null;
054:            }
055:
056:            public String getCategory() {
057:                Iterator it = stack.iterator();
058:                while (it.hasNext()) {
059:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
060:                            .next();
061:                    if (descriptor.getCategory() != null) {
062:                        return descriptor.getCategory();
063:                    }
064:                }
065:                return "Miscellaneous";
066:            }
067:
068:            public Boolean isEnabled() {
069:                Iterator it = stack.iterator();
070:                while (it.hasNext()) {
071:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
072:                            .next();
073:                    if (descriptor.isEnabled() != null) {
074:                        return descriptor.isEnabled();
075:                    }
076:                }
077:                return null;
078:            }
079:
080:            public String getName() {
081:                Iterator it = stack.iterator();
082:                while (it.hasNext()) {
083:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
084:                            .next();
085:                    if (descriptor.getName() != null) {
086:                        return descriptor.getName();
087:                    }
088:                }
089:                return null;
090:            }
091:
092:            Integer defaultSeverity = new Integer(1);
093:            private Set parameterized = new HashSet();
094:
095:            public Integer getSeverity() {
096:                Iterator it = stack.iterator();
097:                while (it.hasNext()) {
098:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
099:                            .next();
100:                    if (descriptor.getSeverity() != null) {
101:                        return descriptor.getSeverity();
102:                    }
103:                }
104:                return defaultSeverity;
105:            }
106:
107:            public Integer getOrder() {
108:                Iterator it = stack.iterator();
109:                while (it.hasNext()) {
110:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
111:                            .next();
112:                    if (descriptor.getOrder() != null) {
113:                        return descriptor.getOrder();
114:                    }
115:                }
116:                return null;
117:            }
118:
119:            public String getRationale() {
120:                Iterator it = stack.iterator();
121:                while (it.hasNext()) {
122:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
123:                            .next();
124:                    if (descriptor.getRationale() != null) {
125:                        return descriptor.getRationale();
126:                    }
127:                }
128:                return null;
129:            }
130:
131:            public String getViolationSample() {
132:                Iterator it = stack.iterator();
133:                while (it.hasNext()) {
134:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
135:                            .next();
136:                    if (descriptor.getViolationSample() != null) {
137:                        return descriptor.getViolationSample();
138:                    }
139:                }
140:                return null;
141:            }
142:
143:            public String getFixSample() {
144:                Iterator it = stack.iterator();
145:                while (it.hasNext()) {
146:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
147:                            .next();
148:                    if (descriptor.getFixSample() != null) {
149:                        return descriptor.getFixSample();
150:                    }
151:                }
152:                return null;
153:            }
154:
155:            public String getResources() {
156:                Iterator it = stack.iterator();
157:                while (it.hasNext()) {
158:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
159:                            .next();
160:                    if (descriptor.getResources() != null) {
161:                        return descriptor.getResources();
162:                    }
163:                }
164:                return null;
165:            }
166:
167:            public String getMessage() {
168:                Iterator it = stack.iterator();
169:                while (it.hasNext()) {
170:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
171:                            .next();
172:                    if (descriptor.getMessage() != null) {
173:                        return descriptor.getMessage();
174:                    }
175:                }
176:                return getDescription();
177:            }
178:
179:            /**
180:             * Adds descriptor at the beginning of the stack (will be used first)
181:             * @param descriptor
182:             */
183:            public void addFirst(InspectorDescriptor descriptor) {
184:                stack.addFirst(descriptor);
185:            }
186:
187:            public void addLast(InspectorDescriptor descriptor) {
188:                stack.addLast(descriptor);
189:            }
190:
191:            public Inspector getInspector() throws ConfigurationException {
192:                Iterator it = stack.iterator();
193:                while (it.hasNext()) {
194:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
195:                            .next();
196:                    Inspector inspector = descriptor.getInspector();
197:                    if (inspector != null) {
198:                        if (!getParameters().isEmpty()) {
199:                            if (inspector instanceof  Parameterizable) {
200:                                if (!parameterized.contains(inspector)) {
201:                                    parameterized.add(inspector);
202:                                    Iterator pit = getParameters().iterator();
203:                                    while (pit.hasNext()) {
204:                                        ParameterEntry pe = (ParameterEntry) pit
205:                                                .next();
206:                                        if (!((Parameterizable) inspector)
207:                                                .setParameter(pe.getName(), pe
208:                                                        .getValue())) {
209:                                            throw new ConfigurationException(
210:                                                    inspector.getClass()
211:                                                            .getName()
212:                                                            + " does not support parameter "
213:                                                            + pe.getName());
214:                                        }
215:                                    }
216:                                }
217:                            } else {
218:                                throw new ConfigurationException(inspector
219:                                        .getClass().getName()
220:                                        + " does not implement "
221:                                        + Parameterizable.class.getName());
222:                            }
223:                        }
224:                        return inspector;
225:                    }
226:                }
227:                return null;
228:            }
229:
230:            public Collection getParameters() {
231:                LinkedList ret = new LinkedList();
232:                LinkedList rstack = new LinkedList(stack);
233:                Collections.reverse(rstack);
234:                Iterator it = rstack.iterator();
235:                while (it.hasNext()) {
236:                    Collection params = ((InspectorDescriptor) it.next())
237:                            .getParameters();
238:                    if (params != null) {
239:                        ret.addAll(params);
240:                    }
241:                }
242:                return ret;
243:            }
244:
245:            public String getMessage(String key) {
246:                Iterator it = stack.iterator();
247:                while (it.hasNext()) {
248:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
249:                            .next();
250:                    if (descriptor.getMessage(key) != null) {
251:                        return descriptor.getMessage(key);
252:                    }
253:                }
254:                return null;
255:            }
256:
257:            public Boolean isWaivable() {
258:                Iterator it = stack.iterator();
259:                while (it.hasNext()) {
260:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
261:                            .next();
262:                    if (descriptor.isWaivable() != null) {
263:                        return descriptor.isWaivable();
264:                    }
265:                }
266:                return null;
267:            }
268:
269:            public Collection getWaiveCases() {
270:                LinkedList ret = new LinkedList();
271:                Iterator it = ret.iterator();
272:                while (it.hasNext()) {
273:                    Collection waiveCases = ((InspectorDescriptor) it.next())
274:                            .getWaiveCases();
275:                    if (waiveCases != null) {
276:                        ret.addAll(waiveCases);
277:                    }
278:                }
279:                return ret;
280:            }
281:
282:            public String getWaivedInspectorName(String inspectorKey) {
283:                Iterator it = stack.iterator();
284:                while (it.hasNext()) {
285:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
286:                            .next();
287:                    String ret = descriptor
288:                            .getWaivedInspectorName(inspectorKey);
289:                    if (ret != null) {
290:                        return ret;
291:                    }
292:                }
293:                return null;
294:            }
295:
296:            public String getWaiveReason(String inspectorKey) {
297:                Iterator it = stack.iterator();
298:                while (it.hasNext()) {
299:                    InspectorDescriptor descriptor = (InspectorDescriptor) it
300:                            .next();
301:                    String ret = descriptor.getWaiveReason(inspectorKey);
302:                    if (ret != null) {
303:                        return ret;
304:                    }
305:                }
306:                return null;
307:            }
308:
309:            public Collection getWaivedInspectorNames() {
310:                LinkedList ret = new LinkedList();
311:                Iterator it = ret.iterator();
312:                while (it.hasNext()) {
313:                    Collection win = ((InspectorDescriptor) it.next())
314:                            .getWaivedInspectorNames();
315:                    if (win != null) {
316:                        ret.addAll(win);
317:                    }
318:                }
319:                return ret;
320:            }
321:
322:            public Collection getFilteredInspectorDesriptors(
323:                    InspectorSet inspectorSet, Collection chain) {
324:                Iterator it = stack.iterator();
325:                while (it.hasNext()) {
326:                    chain = ((InspectorDescriptor) it.next())
327:                            .getFilteredInspectorDesriptors(inspectorSet, chain);
328:                }
329:                return chain;
330:            }
331:
332:            public Collection getAfterInspectorNames() {
333:                LinkedList ret = new LinkedList();
334:                Iterator it = ret.iterator();
335:                while (it.hasNext()) {
336:                    Collection ain = ((InspectorDescriptor) it.next())
337:                            .getAfterInspectorNames();
338:                    if (ain != null) {
339:                        ret.addAll(ain);
340:                    }
341:                }
342:                return ret;
343:            }
344:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.