Source Code Cross Referenced for InspectorEntry.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.HashMap;
027:        import java.util.Iterator;
028:        import java.util.LinkedList;
029:        import java.util.List;
030:        import java.util.Map;
031:
032:        import org.apache.tools.ant.BuildException;
033:        import org.apache.tools.ant.taskdefs.Property;
034:
035:        import com.pavelvlasov.ant.ObjectEntry;
036:        import com.pavelvlasov.ant.Param;
037:        import com.pavelvlasov.config.ConfigurationException;
038:        import com.pavelvlasov.config.Parameterizable;
039:
040:        /**
041:         * Defines inspector
042:         * @ant.element name="inspector" display-name="In-line inspector definition"
043:         * @author Pavel Vlasov	
044:         * @version $Revision: 1.8 $
045:         */
046:        public class InspectorEntry extends ObjectEntry implements 
047:                InspectorDescriptor {
048:            private String fixSample;
049:            private String message;
050:            private String name;
051:            private Integer order;
052:            private String rationale;
053:            private String resources;
054:            private Integer severity;
055:            private String violationSample;
056:            private Boolean isEnabled;
057:            private Boolean isWaivable;
058:            private String description;
059:            private String category;
060:            private List waiveCases = new LinkedList();
061:
062:            public void addConfiguredWaiveCase(WaiveCaseEntry entry) {
063:                waiveCases.add(entry.getText());
064:            }
065:
066:            public Boolean isEnabled() {
067:                return isEnabled;
068:            }
069:
070:            public Boolean isWaivable() {
071:                return isWaivable;
072:            }
073:
074:            public String getName() {
075:                return name;
076:            }
077:
078:            public Integer getSeverity() {
079:                return severity;
080:            }
081:
082:            public Integer getOrder() {
083:                return order;
084:            }
085:
086:            public String getRationale() {
087:                return rationale;
088:            }
089:
090:            public String getViolationSample() {
091:                return violationSample;
092:            }
093:
094:            public String getFixSample() {
095:                return fixSample;
096:            }
097:
098:            public String getResources() {
099:                return resources;
100:            }
101:
102:            public String getMessage() {
103:                return message;
104:            }
105:
106:            private List filterEntries = new LinkedList();
107:
108:            /**
109:             * Inspector to include to filtering
110:             * @ant.non-required
111:             * @param entry
112:             * @return
113:             */
114:            public FilterEntry createFilterInclude() {
115:                FilterEntry fe = new FilterEntry();
116:                filterEntries.add(fe);
117:                return fe;
118:            }
119:
120:            /**
121:             * Inspector to exclude from filtering. 
122:             * @ant.non-required
123:             * @param entry
124:             * @return
125:             */
126:            public FilterEntry createFilterExclude() {
127:                FilterEntry fe = new FilterEntry();
128:                filterEntries.add(fe);
129:                fe.exclude = true;
130:                return fe;
131:            }
132:
133:            public Inspector getInspector() throws ConfigurationException {
134:                if (getClassName() == null) {
135:                    return null;
136:                } else {
137:                    Inspector ret = (Inspector) getObject(null);
138:                    if (!super .getParameters().isEmpty()) {
139:                        if (ret instanceof  Parameterizable) {
140:                            Iterator it = getParameters().iterator();
141:                            while (it.hasNext()) {
142:                                ParameterEntry pe = (ParameterEntry) it.next();
143:                                if (!((Parameterizable) ret).setParameter(pe
144:                                        .getName(), pe.getValue())) {
145:                                    throw new ConfigurationException(ret
146:                                            .getClass().getName()
147:                                            + " does not support parameter "
148:                                            + pe.getName());
149:                                }
150:                            }
151:                        } else {
152:                            throw new ConfigurationException(ret.getClass()
153:                                    .getName()
154:                                    + " does not implement "
155:                                    + Parameterizable.class.getName());
156:                        }
157:                    }
158:                    return ret;
159:                }
160:            }
161:
162:            protected void validateClass(Class clazz) throws BuildException {
163:                super .validateClass(clazz);
164:                if (!Inspector.class.isAssignableFrom(clazz)) {
165:                    throw new BuildException(clazz.getName()
166:                            + " doesn't implement " + Inspector.class);
167:                }
168:            }
169:
170:            /**
171:             * @ant:non-required
172:             * @param fixSample The fixSample to set.
173:             */
174:            public void setFixSample(String fixSample) {
175:                this .fixSample = fixSample;
176:            }
177:
178:            /**
179:             * @ant:non-required
180:             * @param message The message to set.
181:             */
182:            public void setMessage(String message) {
183:                this .message = message;
184:            }
185:
186:            /**
187:             * @ant:non-required
188:             * @param name The name to set.
189:             */
190:            public void setName(String name) {
191:                this .name = name;
192:            }
193:
194:            /**
195:             * @ant:non-required
196:             * @param order The order to set.
197:             */
198:            public void setOrder(int order) {
199:                this .order = new Integer(order);
200:            }
201:
202:            /**
203:             * @ant:non-required
204:             * @param rationale The rationale to set.
205:             */
206:            public void setRationale(String rationale) {
207:                this .rationale = rationale;
208:            }
209:
210:            /**
211:             * @ant:non-required
212:             * @param resources The resources to set.
213:             */
214:            public void setResources(String resources) {
215:                this .resources = resources;
216:            }
217:
218:            /**
219:             * @ant:non-required
220:             * @param severity The severity to set.
221:             */
222:            public void setSeverity(int severity) {
223:                this .severity = new Integer(severity);
224:            }
225:
226:            /**
227:             * @ant:non-required
228:             * @param violationSample The violationSample to set.
229:             */
230:            public void setViolationSample(String violationSample) {
231:                this .violationSample = violationSample;
232:            }
233:
234:            /**
235:             * @ant:non-required
236:             * @param isEnabled The isEnabled to set.
237:             */
238:            public void setEnabled(boolean isEnabled) {
239:                this .isEnabled = isEnabled ? Boolean.TRUE : Boolean.FALSE;
240:            }
241:
242:            /**
243:             * @ant:non-required
244:             * @param isWaivable The isWaivable to set.
245:             */
246:            public void setWaivable(boolean isWaivable) {
247:                this .isWaivable = isWaivable ? Boolean.TRUE : Boolean.FALSE;
248:            }
249:
250:            /**
251:             * @return Returns the description.
252:             */
253:            public String getDescription() {
254:                return description;
255:            }
256:
257:            /**
258:             * @return Returns the description.
259:             */
260:            public String getCategory() {
261:                return category;
262:            }
263:
264:            /**
265:             * @ant:non-required
266:             * @param description The description to set.
267:             */
268:            public void setDescription(String description) {
269:                this .description = description;
270:            }
271:
272:            /**
273:             * @ant:non-required
274:             * @param category The category to set.
275:             */
276:            public void setCategory(String category) {
277:                this .category = category;
278:            }
279:
280:            /**
281:             * Convert entries from Param to ParameterEntry
282:             * @ant:ignore
283:             */
284:            public Collection getParameters() {
285:                List ret = new LinkedList();
286:                Iterator it = super .getParameters().iterator();
287:                while (it.hasNext()) {
288:                    Param p = (Param) it.next();
289:                    ret.add(new ParameterEntry(p.getName(), p.getObject(null)));
290:                }
291:                return ret;
292:            }
293:
294:            private Map messages = new HashMap();
295:
296:            /**
297:             * Keyed message.
298:             * @param message
299:             * @ant.non-required
300:             */
301:            public void addConfiguredMessage(Property message) {
302:                messages.put(message.getName(), message);
303:            }
304:
305:            public String getMessage(String key) {
306:                Property property = (Property) messages.get(key);
307:                return property == null ? null : property.getValue();
308:            }
309:
310:            public Collection getWaiveCases() {
311:                return waiveCases;
312:            }
313:
314:            public String getWaivedInspectorName(String inspectorKey) {
315:                // TODO Auto-generated method stub
316:                return null;
317:            }
318:
319:            public String getWaiveReason(String inspectorKey) {
320:                // TODO Auto-generated method stub
321:                return null;
322:            }
323:
324:            public Collection getWaivedInspectorNames() {
325:                // TODO Auto-generated method stub
326:                return null;
327:            }
328:
329:            public Collection getFilteredInspectorDesriptors(
330:                    InspectorSet inspectorSet, Collection chain) {
331:                if (chain == null) {
332:                    chain = new LinkedList();
333:                }
334:
335:                Iterator it = filterEntries.iterator();
336:                while (it.hasNext()) {
337:                    FilterEntry fe = (FilterEntry) it.next();
338:                    if (fe.exclude) {
339:                        if (fe.name == null) {
340:                            Iterator dit = chain.iterator();
341:                            while (dit.hasNext()) {
342:                                if (fe.category
343:                                        .equals(((InspectorDescriptor) dit
344:                                                .next()).getCategory())) {
345:                                    dit.remove();
346:                                }
347:                            }
348:                        } else {
349:                            if ("*".equals(fe.name)) {
350:                                chain.clear();
351:                            } else {
352:                                Iterator dit = chain.iterator();
353:                                while (dit.hasNext()) {
354:                                    if (fe.name
355:                                            .equals(((InspectorDescriptor) dit
356:                                                    .next()).getName())) {
357:                                        dit.remove();
358:                                    }
359:                                }
360:                            }
361:                        }
362:                    } else {
363:                        if (fe.name == null) {
364:                            Iterator dit = inspectorSet.getDescriptors()
365:                                    .iterator();
366:                            while (dit.hasNext()) {
367:                                InspectorDescriptor inspectorDescriptor = (InspectorDescriptor) dit
368:                                        .next();
369:                                if (fe.category.equals(inspectorDescriptor
370:                                        .getCategory())) {
371:                                    chain.add(inspectorDescriptor);
372:                                }
373:                            }
374:                        } else {
375:                            if ("*".equals(fe.name)) {
376:                                chain.addAll(inspectorSet.getDescriptors());
377:                            } else {
378:                                Iterator dit = inspectorSet.getDescriptors()
379:                                        .iterator();
380:                                while (dit.hasNext()) {
381:                                    InspectorDescriptor inspectorDescriptor = (InspectorDescriptor) dit
382:                                            .next();
383:                                    if (fe.name.equals(inspectorDescriptor
384:                                            .getName())) {
385:                                        chain.add(inspectorDescriptor);
386:                                    }
387:                                }
388:                            }
389:                        }
390:                    }
391:                }
392:
393:                return chain;
394:            }
395:
396:            public Collection getAfterInspectorNames() {
397:                return null;
398:            }
399:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.