1 26 27 package org.objectweb.jonas_lib.deployment.xml; 28 29 import java.util.Iterator ; 30 import java.util.LinkedList ; 31 32 36 public class JLinkedList extends LinkedList { 37 38 39 42 private String tag = null; 43 44 45 49 public JLinkedList(String tag) { 50 super(); 51 this.tag = tag; 52 } 53 54 55 60 public String toXML() { 61 return toXML(0); 62 } 63 64 69 public String toString() { 70 return toXML(); 71 } 72 73 74 79 private String indent(int indent) { 80 String txt = ""; 81 for (int i = 0; i < indent; i++) { 82 txt += " "; 83 } 84 return txt; 85 } 86 87 88 93 public String toXML(int indent) { 94 StringBuffer sb = new StringBuffer (); 95 if (this.size() > 0) { 97 for (Iterator i = this.iterator(); i.hasNext();) { 98 Object o = i.next(); 99 if (o instanceof Element) { 101 sb.append(((Element) o).toXML(indent)); 102 } else { 103 sb.append(indent(indent)); 104 sb.append("<"); 105 sb.append(tag); 106 sb.append(">"); 107 sb.append(o); 108 sb.append("</"); 109 sb.append(tag); 110 sb.append(">\n"); 111 } 112 } 113 } 114 return sb.toString(); 115 } 116 117 118 119 120 } 121 | Popular Tags |