1 2 3 package net.firstpartners.nounit.snippet; 4 5 28 29 import java.util.Iterator ; 30 31 import net.firstpartners.nounit.snippet.xml.IXmlConstants; 32 import net.firstpartners.nounit.snippet.xml.IXmlJdomSource; 33 import net.firstpartners.nounit.snippet.xml.IXmlSource; 34 35 import org.jdom.Element; 36 37 40 41 public class SnippetClass 42 extends AbstractSnippet 43 implements IXmlSource , IXmlJdomSource , IXmlConstants { 44 45 46 49 private String innerSuperClass; 50 51 54 private Snippets innerMethods; 55 56 63 public SnippetClass(String name, 64 String accessModifier, 65 String superClass, 66 Snippets methods) { 67 68 super.innerName=name; 69 super.innerAccess=accessModifier; 70 this.innerSuperClass = superClass; 71 this.innerMethods = methods; 72 } 73 74 75 79 public String toString(){ 80 81 StringBuffer stringDescription = new StringBuffer (); 83 84 stringDescription.append(super.toString()); 86 87 stringDescription.append("\n"); 88 stringDescription.append("{"); 89 90 Iterator methodValues = innerMethods.getIterator(); 92 93 while (methodValues.hasNext()){ 94 95 stringDescription.append("\n"); 96 stringDescription.append(methodValues.next()); 97 98 } 99 100 102 stringDescription.append("}"); 103 104 stringDescription.append("\nextends "); 106 stringDescription.append(innerSuperClass); 107 108 110 return stringDescription.toString(); 111 } 112 113 117 public String toXml() { 118 119 return super.toXml(getNodes()); 120 121 } 122 123 124 128 public Element getNodes(){ 129 130 Element extendsTag = new Element(ELEMENT_CLASS_EXTENDS); 132 Element classRoot = new Element(ELEMENT_CLASS); 133 134 classRoot.setAttribute(ATTRIBUTE_NAME,super.innerName); 136 classRoot.setAttribute(ATTRIBUTE_ACCESS,super.innerAccess); 137 138 extendsTag.setAttribute(ATTRIBUTE_NAME,this.innerSuperClass); 140 classRoot.addContent(extendsTag); 141 142 classRoot = innerMethods.addNodesTo(classRoot); 144 145 return classRoot; 147 148 149 } 150 151 152 } 153 | Popular Tags |