1 package net.firstpartners.nounit.snippet; 2 3 26 27 import java.util.Iterator ; 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 38 public class SnippetPackage 39 extends AbstractSnippet 40 implements IXmlSource , IXmlJdomSource , IXmlConstants { 41 42 45 private Snippets innerClasses; 46 47 52 public SnippetPackage(String location, Snippets classes) { 53 54 super.innerName=location; 55 this.innerClasses = classes; 56 } 57 58 59 63 public String toString(){ 64 65 StringBuffer stringDescription = new StringBuffer (); 67 68 stringDescription.append("package location "); 70 stringDescription.append(super.innerName); 71 72 stringDescription.append("\n"); 73 Iterator classValues = this.innerClasses.getIterator(); 75 76 while (classValues.hasNext()){ 77 78 stringDescription.append("\n"); 79 stringDescription.append(classValues.next()); 80 stringDescription.append("\n"); 81 82 } 83 84 86 return stringDescription.toString(); 87 } 88 89 93 public String toXml() { 94 95 return super.toXml(getNodes()); 96 97 } 98 99 100 104 public Element getNodes(){ 105 106 Element packageRoot = new Element(ELEMENT_PACKAGE); 108 109 packageRoot.setAttribute(ATTRIBUTE_PACKAGE_LOCATION,innerName); 111 112 packageRoot = innerClasses.addNodesTo(packageRoot); 114 115 return packageRoot; 117 118 } 119 120 } 121 | Popular Tags |