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 Project (i.e. Multiple Packages)
037: */
038: public class SnippetProject extends AbstractSnippet implements
039: IXmlSource, IXmlJdomSource, IXmlConstants {
040:
041: /**
042: * inner store of the classes within this package
043: */
044: private Snippets innerPackages;
045:
046: /**
047: * Creates new SnippetProject
048: * @param packages , Snippets (Collection) of Classes
049: */
050: public SnippetProject(Snippets packages) {
051:
052: this .innerPackages = packages;
053: }
054:
055: /**
056: * over-ride Object.toString() to provide more information about this class
057: * @return stringDescription of Class
058: */
059: public String toString() {
060:
061: //Local Variables
062: StringBuffer stringDescription = new StringBuffer();
063:
064: //Build up return string
065: stringDescription.append("Project: ");
066: stringDescription.append("\n");
067:
068: //Loop to get method paramters
069: Iterator packageValues = this .innerPackages.getIterator();
070:
071: while (packageValues.hasNext()) {
072:
073: stringDescription.append("\n");
074: stringDescription.append(packageValues.next());
075: stringDescription.append("\n");
076:
077: }
078:
079: //return value
080:
081: return stringDescription.toString();
082: }
083:
084: /**
085: * Get an XML Representation of this Class (as String of XML)
086: * @return String with the XML description
087: */
088: public String toXml() {
089:
090: return super .toXml(getNodes());
091:
092: }
093:
094: /**
095: * Get an XML Representation of this Class (as Jdom nodes)
096: * @return projectRoot with the XML description
097: */
098: public Element getNodes() {
099:
100: //Local Variables
101: Element projectRoot = new Element(ELEMENT_PROJECT);
102:
103: //Add Class Info
104: projectRoot = innerPackages.addNodesTo(projectRoot);
105:
106: //Return Class Element
107: return projectRoot;
108:
109: }
110:
111: }
|