Source Code Cross Referenced for MethodSetElement.java in  » Code-Analyzer » JBlanket » csdl » jblanket » report » element » 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 » JBlanket » csdl.jblanket.report.element 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package csdl.jblanket.report.element;
002:
003:        import java.io.PrintWriter;
004:        import java.util.Iterator;
005:        import java.util.Set;
006:        import java.util.TreeSet;
007:
008:        /**
009:         * Provides a wrapper for the 'MethodSet' element in the aggregate XML file.  An instance of a
010:         * MethodSetElement represents elements in a MethodSet.
011:         * <p>
012:         * An example of a 'MethodSet' as a MethodSetElement with no methods:
013:         * <pre>
014:         *   &lt;MethodSet class="String" package="java.lang" tested="0" untested="0" oneline="0" 
015:         *              constructor="0" excludedindividual="0" timestamp=""/&gt;
016:         * </pre>
017:         * <p>
018:         * An example of a 'MethodSet' as a MethodSetElement with methods:
019:         * <pre>
020:         *   &lt;MethodSet class="String" package="java.lang" tested="1" untested="0" oneline="0" 
021:         *             constructor="0" timestamp=""&gt;
022:         *     &lt;tested&gt;
023:         *       &lt;Method name="indexOf" package="java.lang.String"&gt;
024:         *         &lt;Parameter type="java.lang.String"/&gt;
025:         *         &lt;Parameter type="int"/&gt;
026:         *       &lt;/Method&gt;
027:         *     &lt;/tested&gt;
028:         *     &lt;untested/&gt;
029:         *     &lt;oneline/&gt;
030:         *     &lt;constructor/&gt;
031:         *     &lt;ecludedindividual/&gt;
032:         *   &lt;/MethodSet&gt;
033:         * </pre>
034:         * <p>
035:         * Note that the <code>excluded individual methods</code> take priority over all the other
036:         * categories of methods.  I.e., if a one-line method was individually excluded by the application,
037:         * then it is considered to be an individually excluded methods instead of a one-line method.
038:         * 
039:         * @author Joy M. Agustin
040:         * @version $Id: MethodSetElement.java,v 1.2 2004/11/07 08:53:26 timshadel Exp $
041:         */
042:        public class MethodSetElement implements  Comparable {
043:
044:            /** Name of the class */
045:            private String className;
046:            /** Name of the package className belongs to */
047:            private String packageName;
048:
049:            /** Timestamp */
050:            private String timeStamp;
051:
052:            /** Set of all methods tested */
053:            private Set testedMethodSet;
054:            /** Set of all methods untested */
055:            private Set untestedMethodSet;
056:            /** Set of all methods untestable */
057:            private Set untestableMethodSet;
058:            /** Set of all one-line methods */
059:            private Set onelineMethodSet;
060:            /** Set of all constructors */
061:            private Set constructorMethodSet;
062:            /** Set of all individually excluded methods */
063:            private Set excludedIndividualMethodSet;
064:
065:            /**
066:             * Constructs a new MethodSetElement object.
067:             * 
068:             * @param className the name of the class.
069:             * @param packageName the name of the package <code>className</code> belongs to.
070:             */
071:            public MethodSetElement(String packageName, String className) {
072:
073:                this .packageName = packageName;
074:                this .className = className;
075:
076:                this .testedMethodSet = new TreeSet();
077:                this .untestedMethodSet = new TreeSet();
078:                this .untestableMethodSet = new TreeSet();
079:                this .onelineMethodSet = new TreeSet();
080:                this .constructorMethodSet = new TreeSet();
081:                this .excludedIndividualMethodSet = new TreeSet();
082:            }
083:
084:            /**
085:             * Returns the name of the package of this MethodSetElement object.
086:             * 
087:             * @return the name of the package of this MethodSetElement object.
088:             */
089:            public String getPackageName() {
090:                return this .packageName;
091:            }
092:
093:            /**
094:             * Returns the name of the class of this MethodSetElement object.
095:             * 
096:             * @return the name of the class of this MethodSetElement object.
097:             */
098:            public String getClassName() {
099:                return this .className;
100:            }
101:
102:            /**
103:             * Returns the number of tested methods.
104:             * 
105:             * @return the number of tested methods.
106:             */
107:            public int getTestedSize() {
108:                return this .testedMethodSet.size();
109:            }
110:
111:            /**
112:             * Returns the number of untested methods.
113:             * 
114:             * @return the number of untested methods.
115:             */
116:            public int getUntestedSize() {
117:                return this .untestedMethodSet.size();
118:            }
119:
120:            /**
121:             * Returns the number of untested methods.
122:             * 
123:             * @return the number of untested methods.
124:             */
125:            public int getUntestableSize() {
126:                return this .untestableMethodSet.size();
127:            }
128:
129:            /**
130:             * Returns the number of one-line methods.
131:             * 
132:             * @return the number of one-line methods.
133:             */
134:            public int getOnelineSize() {
135:                return this .onelineMethodSet.size();
136:            }
137:
138:            /**
139:             * Returns the number of constructors.
140:             * 
141:             * @return the number of constructors.
142:             */
143:            public int getConstructorSize() {
144:                return this .constructorMethodSet.size();
145:            }
146:
147:            /**
148:             * Returns the number of individually excluded methods.
149:             * 
150:             * @return the number of individually excluded methods.
151:             */
152:            public int getExcludedIndividualSize() {
153:                return this .excludedIndividualMethodSet.size();
154:            }
155:
156:            /**
157:             * Adds the timeStamp from the file this MethodSetElement came from.
158:             * 
159:             * @param timeStamp the timeStamp from the file this MethodSetElement came from.
160:             */
161:            public void setTimeStamp(String timeStamp) {
162:                this .timeStamp = timeStamp;
163:            }
164:
165:            /**
166:             * Adds a method to the set of tested methods.
167:             * 
168:             * @param method the MethodElement representation of a tested method.
169:             */
170:            public void addTestMethod(MethodElement method) {
171:
172:                // need to check if method already added because no control over order of category processing
173:                if (!this .excludedIndividualMethodSet.contains(method)) {
174:                    this .testedMethodSet.add(method);
175:                }
176:            }
177:
178:            /**
179:             * Adds a method to the set of untested methods.
180:             * 
181:             * @param method the MethodElement representation of an untested method.
182:             */
183:            public void addUntestMethod(MethodElement method) {
184:
185:                // need to check if method already added because no control over order of category processing
186:                if (!this .excludedIndividualMethodSet.contains(method)) {
187:                    this .untestedMethodSet.add(method);
188:                }
189:            }
190:
191:            /**
192:             * Adds a method to the set of untested methods.
193:             * 
194:             * @param method the MethodElement representation of an untested method.
195:             */
196:            public void addUntestableMethod(MethodElement method) {
197:
198:                // need to check if method already added because no control over order of category processing
199:                if (!this .excludedIndividualMethodSet.contains(method)) {
200:                    this .untestableMethodSet.add(method);
201:                }
202:            }
203:
204:            /**
205:             * Adds a method to the set of one-line methods.
206:             * 
207:             * @param method the MethodElement representation of a one-line method.
208:             */
209:            public void addOneLineMethod(MethodElement method) {
210:
211:                // need to check if method already added because no control over order of category processing
212:                if (!this .excludedIndividualMethodSet.contains(method)) {
213:                    this .onelineMethodSet.add(method);
214:                }
215:            }
216:
217:            /**
218:             * Adds a method to the set of constructors.
219:             * 
220:             * @param method the MethodElement representation of a constructor.
221:             */
222:            public void addConstructorMethod(MethodElement method) {
223:
224:                // need to check if method already added because no control over order of category processing
225:                if (!this .excludedIndividualMethodSet.contains(method)) {
226:                    this .constructorMethodSet.add(method);
227:                }
228:            }
229:
230:            /**
231:             * Adds a method to the set of constructors.
232:             * 
233:             * @param method the MethodElement representation of a constructor.
234:             */
235:            public void addExcludedIndividualMethod(MethodElement method) {
236:                this .excludedIndividualMethodSet.add(method);
237:
238:                // remove collisions with other *MethodSets
239:                this .testedMethodSet.remove(method);
240:                this .untestedMethodSet.remove(method);
241:                this .onelineMethodSet.remove(method);
242:                this .constructorMethodSet.remove(method);
243:            }
244:
245:            /**
246:             * Returns a String representation of this MethodSetElement as found in an aggregate XML file.
247:             * 
248:             * @return a String representation of this MethodSetElement.
249:             */
250:            public String toString() {
251:                StringBuffer buffer = new StringBuffer();
252:                buffer.append("  <MethodSet name=\"" + this .className + "\"");
253:                buffer.append(" package=\"" + this .packageName + "\"");
254:                buffer
255:                        .append(" tested=\"" + this .testedMethodSet.size()
256:                                + "\"");
257:                buffer.append(" untested=\"" + this .untestedMethodSet.size()
258:                        + "\"");
259:                buffer.append(" untestable=\""
260:                        + this .untestableMethodSet.size() + "\"");
261:                buffer.append(" oneline=\"" + this .onelineMethodSet.size()
262:                        + "\"");
263:                buffer.append(" constructor=\""
264:                        + this .constructorMethodSet.size() + "\"");
265:                buffer.append(" excludedindividual=\""
266:                        + this .excludedIndividualMethodSet.size() + "\"");
267:                buffer.append(" timestamp=\"" + this .timeStamp + "\" >\n");
268:
269:                if (this .testedMethodSet.size() > 0) {
270:                    buffer.append("    <tested>\n");
271:                    for (Iterator i = this .testedMethodSet.iterator(); i
272:                            .hasNext();) {
273:                        buffer.append("" + i.next() + "\n");
274:                    }
275:                    buffer.append("    </tested>\n");
276:                } else {
277:                    buffer.append("    <tested/>\n");
278:                }
279:
280:                if (this .untestedMethodSet.size() > 0) {
281:                    buffer.append("    <untested>\n");
282:                    for (Iterator i = this .untestedMethodSet.iterator(); i
283:                            .hasNext();) {
284:                        buffer.append("" + i.next() + "\n");
285:                    }
286:                    buffer.append("    </untested>\n");
287:                } else {
288:                    buffer.append("    <untested/>\n");
289:                }
290:
291:                if (this .untestedMethodSet.size() > 0) {
292:                    buffer.append("    <untestable>\n");
293:                    for (Iterator i = this .untestableMethodSet.iterator(); i
294:                            .hasNext();) {
295:                        buffer.append("" + i.next() + "\n");
296:                    }
297:                    buffer.append("    </untestable>\n");
298:                } else {
299:                    buffer.append("    <untestable/>\n");
300:                }
301:
302:                if (this .onelineMethodSet.size() > 0) {
303:                    buffer.append("    <oneline>\n");
304:                    for (Iterator i = this .onelineMethodSet.iterator(); i
305:                            .hasNext();) {
306:                        buffer.append("" + i.next() + "\n");
307:                    }
308:                    buffer.append("    </oneline>\n");
309:                } else {
310:                    buffer.append("    <oneline/>\n");
311:                }
312:
313:                if (this .constructorMethodSet.size() > 0) {
314:                    buffer.append("    <constructor>\n");
315:                    for (Iterator i = this .constructorMethodSet.iterator(); i
316:                            .hasNext();) {
317:                        buffer.append("" + i.next() + "\n");
318:                    }
319:                    buffer.append("    </constructor>\n");
320:                } else {
321:                    buffer.append("    <constructor/>\n");
322:                }
323:
324:                if (this .excludedIndividualMethodSet.size() > 0) {
325:                    buffer.append("    <excludedindividual>\n");
326:                    for (Iterator i = this .excludedIndividualMethodSet
327:                            .iterator(); i.hasNext();) {
328:                        buffer.append("" + i.next() + "\n");
329:                    }
330:                    buffer.append("    </excludedindividual>\n");
331:                } else {
332:                    buffer.append("    <excludedindividual/>\n");
333:                }
334:
335:                buffer.append("  </MethodSet>");
336:
337:                return buffer.toString();
338:            }
339:
340:            /**
341:             * Writes this MethodSetElement to writer.
342:             * 
343:             * @param writer points to an output file.
344:             */
345:            public void write(PrintWriter writer) {
346:
347:                writer.write("  <MethodSet name=\"" + this .className + "\"");
348:                writer.write(" package=\"" + this .packageName + "\"");
349:                writer.write(" tested=\"" + this .testedMethodSet.size() + "\"");
350:                writer.write(" untested=\"" + this .untestedMethodSet.size()
351:                        + "\"");
352:                writer.write(" untestable=\"" + this .untestableMethodSet.size()
353:                        + "\"");
354:                writer.write(" oneline=\"" + this .onelineMethodSet.size()
355:                        + "\"");
356:                writer.write(" constructor=\""
357:                        + this .constructorMethodSet.size() + "\"");
358:                writer.write(" excludedindividual=\""
359:                        + this .excludedIndividualMethodSet.size() + "\"");
360:                writer.write(" timestamp=\"" + this .timeStamp + "\" >\n");
361:
362:                if (this .testedMethodSet.size() > 0) {
363:                    writer.write("    <tested>\n");
364:                    for (Iterator i = this .testedMethodSet.iterator(); i
365:                            .hasNext();) {
366:                        writer.write("" + i.next() + "\n");
367:                    }
368:                    writer.write("    </tested>\n");
369:                } else {
370:                    writer.write("    <tested/>\n");
371:                }
372:
373:                if (this .untestedMethodSet.size() > 0) {
374:                    writer.write("    <untested>\n");
375:                    for (Iterator i = this .untestedMethodSet.iterator(); i
376:                            .hasNext();) {
377:                        writer.write("" + i.next() + "\n");
378:                    }
379:                    writer.write("    </untested>\n");
380:                } else {
381:                    writer.write("    <untested/>\n");
382:                }
383:
384:                if (this .untestableMethodSet.size() > 0) {
385:                    writer.write("    <untestable>\n");
386:                    for (Iterator i = this .untestableMethodSet.iterator(); i
387:                            .hasNext();) {
388:                        writer.write("" + i.next() + "\n");
389:                    }
390:                    writer.write("    </untestable>\n");
391:                } else {
392:                    writer.write("    <untestable/>\n");
393:                }
394:
395:                if (this .onelineMethodSet.size() > 0) {
396:                    writer.write("    <oneline>\n");
397:                    for (Iterator i = this .onelineMethodSet.iterator(); i
398:                            .hasNext();) {
399:                        writer.write("" + i.next() + "\n");
400:                    }
401:                    writer.write("    </oneline>\n");
402:                } else {
403:                    writer.write("    <oneline/>\n");
404:                }
405:
406:                if (this .constructorMethodSet.size() > 0) {
407:                    writer.write("    <constructor>\n");
408:                    for (Iterator i = this .constructorMethodSet.iterator(); i
409:                            .hasNext();) {
410:                        writer.write("" + i.next() + "\n");
411:                    }
412:                    writer.write("    </constructor>\n");
413:                } else {
414:                    writer.write("    <constructor/>\n");
415:                }
416:
417:                if (this .excludedIndividualMethodSet.size() > 0) {
418:                    writer.write("    <excludedindividual>\n");
419:                    for (Iterator i = this .excludedIndividualMethodSet
420:                            .iterator(); i.hasNext();) {
421:                        writer.write("" + i.next() + "\n");
422:                    }
423:                    writer.write("    </excludedindividual>\n");
424:                } else {
425:                    writer.write("    <excludedindividual/>\n");
426:                }
427:
428:                writer.write("  </MethodSet>");
429:            }
430:
431:            /**
432:             * Compares this MethodSetElement object to <code>obj</code>.
433:             * 
434:             * @param obj the MethodSetElement object to compare to.
435:             * @return negative integer if this MethodSetElement object comes before <code>obj</code>, zero 
436:             *          if this MethodSetElement object is equal to <code>obj</code>, or positive integer if 
437:             *          <code>obj</code> comes before this MethodSetElement object.
438:             */
439:            public int compareTo(Object obj) {
440:
441:                if (this .packageName.compareTo(((MethodSetElement) obj)
442:                        .getPackageName()) != 0) {
443:                    return this .packageName.compareTo(((MethodSetElement) obj)
444:                            .getPackageName());
445:                } else {
446:                    return this .className.compareTo(((MethodSetElement) obj)
447:                            .getClassName());
448:                }
449:            }
450:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.