001: package net.firstpartners.nounit.snippet;
002:
003: /**
004: * Title: NoUnit - Identify Classes that are not being unit Tested
005: *
006: * Copyright (C) 2001 Paul Browne , FirstPartners.net
007: *
008: *
009: * This program is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; either version 2
012: * of the License, or (at your option) any later version.
013: *
014: * This program is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
017: * GNU General Public License for more details.
018: *
019: * You should have received a copy of the GNU General Public License
020: * along with this program; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
022: *
023: * @author Paul Browne
024: * @version 0.7
025: */
026:
027: import java.util.Iterator;
028:
029: import net.firstpartners.nounit.snippet.xml.IXmlConstants;
030: import net.firstpartners.nounit.snippet.xml.IXmlJdomSource;
031: import net.firstpartners.nounit.snippet.xml.IXmlSource;
032:
033: import org.jdom.Element;
034:
035: /**
036: * Holds Information about a Java Package
037: */
038: public class SnippetPackage extends AbstractSnippet implements
039: IXmlSource, IXmlJdomSource, IXmlConstants {
040:
041: /**
042: * inner store of the classes within this package
043: */
044: private Snippets innerClasses;
045:
046: /**
047: * Creates new SnippetPackage
048: * @param location of this snippet
049: * @param classes (as Snippets)
050: */
051: public SnippetPackage(String location, Snippets classes) {
052:
053: super .innerName = location;
054: this .innerClasses = classes;
055: }
056:
057: /**
058: * over-ride Object.toString() to provide more information about this class
059: * @return stringDescription of Class
060: */
061: public String toString() {
062:
063: //Local Variables
064: StringBuffer stringDescription = new StringBuffer();
065:
066: //Build up return string
067: stringDescription.append("package location ");
068: stringDescription.append(super .innerName);
069:
070: stringDescription.append("\n");
071: //Loop to get method paramters
072: Iterator classValues = this .innerClasses.getIterator();
073:
074: while (classValues.hasNext()) {
075:
076: stringDescription.append("\n");
077: stringDescription.append(classValues.next());
078: stringDescription.append("\n");
079:
080: }
081:
082: //return value
083:
084: return stringDescription.toString();
085: }
086:
087: /**
088: * Get an XML Representation of this Class (as String of XML)
089: * @return String with the XML description
090: */
091: public String toXml() {
092:
093: return super .toXml(getNodes());
094:
095: }
096:
097: /**
098: * Get an XML Representation of this Class (as Jdom nodes)
099: * @return methodRoot with the XML description
100: */
101: public Element getNodes() {
102:
103: //Local Variables
104: Element packageRoot = new Element(ELEMENT_PACKAGE);
105:
106: //Add Name, access and info
107: packageRoot.setAttribute(ATTRIBUTE_PACKAGE_LOCATION, innerName);
108:
109: //Add Class Info
110: packageRoot = innerClasses.addNodesTo(packageRoot);
111:
112: //Return Class Element
113: return packageRoot;
114:
115: }
116:
117: }
|