KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.jdom.Element;
28 import org.jdom.output.XMLOutputter;
29
30
31 /**
32  * Convenience Implementation of ISnippet containing methods shared by
33  * subclasses
34  */

35 abstract public class AbstractSnippet implements ISnippet {
36
37     /**
38      * inner Store of this method name
39      */

40     protected String JavaDoc innerName;
41     
42     /**
43      * inner Store of the Access Modifier
44      */

45     protected String JavaDoc innerAccess;
46     
47         
48     /**
49      * Creates new AbstractSnippet
50      * Needed due to implicit call to constructor
51      */

52     public AbstractSnippet() {
53     }
54
55     /**
56      * Methods implementing this should override the toString() method of object
57      * @return returnString containing the info (in string form) contained in
58      * the abstract class
59      */

60     public String JavaDoc toString() {
61         
62         StringBuffer JavaDoc stringDescription = new StringBuffer JavaDoc();
63         
64         stringDescription.append(innerAccess);
65         stringDescription.append(" ");
66         stringDescription.append(innerName);
67         
68         return stringDescription.toString();
69   
70         
71     }
72     
73    /**
74      * Get an XML Representation of this Class (as String of XML)
75      * @param jDomDescription , Element , to be converted to Xml String
76      * @return String with the XML description
77      */

78     protected String JavaDoc toXml(Element jDomDescription) {
79         
80         //Use XML Outputter (from Jdom) to format (true = nice format)
81
XMLOutputter fmt = new XMLOutputter(" ", true);
82         
83         //Do the conversion to XML as string
84
String JavaDoc xmlAsString = fmt.outputString(jDomDescription);
85
86         return xmlAsString;
87         
88     }
89     
90 }
91
92
Popular Tags