KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > firstpartners > nounit > snippet > SnippetProject


1 package net.firstpartners.nounit.snippet;
2
3 /**
4  * Title: NoUnit - Identify Classes that are not being unit Tested
5  *
6  * Copyright (C) 2001 Paul Browne , FirstPartners.net
7  *
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * @author Paul Browne
24  * @version 0.7
25  */

26
27 import java.util.Iterator JavaDoc;
28
29 import net.firstpartners.nounit.snippet.xml.IXmlConstants;
30 import net.firstpartners.nounit.snippet.xml.IXmlJdomSource;
31 import net.firstpartners.nounit.snippet.xml.IXmlSource;
32
33 import org.jdom.Element;
34
35 /**
36  * Holds Information about a Java Project (i.e. Multiple Packages)
37  */

38 public class SnippetProject extends AbstractSnippet
39 implements IXmlSource, IXmlJdomSource, IXmlConstants {
40     
41     /**
42      * inner store of the classes within this package
43      */

44     private Snippets innerPackages;
45     
46     /**
47      * Creates new SnippetProject
48      * @param packages , Snippets (Collection) of Classes
49      */

50     public SnippetProject(Snippets packages) {
51
52         this.innerPackages = packages;
53     }
54     
55     
56     /**
57      * over-ride Object.toString() to provide more information about this class
58      * @return stringDescription of Class
59      */

60     public String JavaDoc toString(){
61         
62         //Local Variables
63
StringBuffer JavaDoc stringDescription = new StringBuffer JavaDoc();
64         
65         //Build up return string
66
stringDescription.append("Project: ");
67         stringDescription.append("\n");
68         
69         //Loop to get method paramters
70
Iterator JavaDoc packageValues = this.innerPackages.getIterator();
71         
72         while (packageValues.hasNext()){
73             
74             stringDescription.append("\n");
75             stringDescription.append(packageValues.next());
76             stringDescription.append("\n");
77             
78         }
79         
80         //return value
81

82         return stringDescription.toString();
83     }
84     
85     /**
86      * Get an XML Representation of this Class (as String of XML)
87      * @return String with the XML description
88      */

89     public String JavaDoc toXml() {
90         
91         return super.toXml(getNodes());
92         
93     }
94     
95     
96     /**
97      * Get an XML Representation of this Class (as Jdom nodes)
98      * @return projectRoot with the XML description
99      */

100     public Element getNodes(){
101         
102         //Local Variables
103
Element projectRoot = new Element(ELEMENT_PROJECT);
104         
105         //Add Class Info
106
projectRoot = innerPackages.addNodesTo(projectRoot);
107         
108         //Return Class Element
109
return projectRoot;
110         
111     }
112     
113 }
114
Popular Tags