01: package net.firstpartners.nounit.snippet;
02:
03: /**
04: * Title: NoUnit - Identify Classes that are not being unit Tested
05: *
06: * Copyright (C) 2001 Paul Browne , FirstPartners.net
07: *
08: *
09: * 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: * Convenience Implementation of ISnippet containing methods shared by
32: * subclasses
33: */
34: abstract public class AbstractSnippet implements ISnippet {
35:
36: /**
37: * inner Store of this method name
38: */
39: protected String innerName;
40:
41: /**
42: * inner Store of the Access Modifier
43: */
44: protected String innerAccess;
45:
46: /**
47: * Creates new AbstractSnippet
48: * Needed due to implicit call to constructor
49: */
50: public AbstractSnippet() {
51: }
52:
53: /**
54: * Methods implementing this should override the toString() method of object
55: * @return returnString containing the info (in string form) contained in
56: * the abstract class
57: */
58: public String toString() {
59:
60: StringBuffer stringDescription = new StringBuffer();
61:
62: stringDescription.append(innerAccess);
63: stringDescription.append(" ");
64: stringDescription.append(innerName);
65:
66: return stringDescription.toString();
67:
68: }
69:
70: /**
71: * Get an XML Representation of this Class (as String of XML)
72: * @param jDomDescription , Element , to be converted to Xml String
73: * @return String with the XML description
74: */
75: protected String toXml(Element jDomDescription) {
76:
77: //Use XML Outputter (from Jdom) to format (true = nice format)
78: XMLOutputter fmt = new XMLOutputter(" ", true);
79:
80: //Do the conversion to XML as string
81: String xmlAsString = fmt.outputString(jDomDescription);
82:
83: return xmlAsString;
84:
85: }
86:
87: }
|