1 26 27 package org.objectweb.jonas_lib.deployment.xml; 28 29 34 public abstract class AbsElement implements Element { 35 36 37 42 public abstract String toXML(int indent); 43 44 45 50 public String toXML() { 51 return toXML(0); 52 } 53 54 59 public String toString() { 60 return toXML(); 61 } 62 63 64 69 protected String indent(int indent) { 70 String txt = ""; 71 for (int i = 0; i < indent; i++) { 72 txt += " "; 73 } 74 return txt; 75 } 76 77 84 protected String xmlElement(String value, String xmlTag, int indent) { 85 if (value == null) { 86 return ""; 87 } 88 89 91 StringBuffer sb = new StringBuffer (); 92 sb.append(indent(indent)); 93 sb.append("<"); 94 sb.append(xmlTag); 95 sb.append(">"); 96 sb.append(value); 97 sb.append("</"); 98 sb.append(xmlTag); 99 sb.append(">\n"); 100 return sb.toString(); 101 } 102 103 109 protected String xmlAttribute(String value, String xmlTag) { 110 if (value == null) { 111 return ""; 112 } 113 114 116 StringBuffer sb = new StringBuffer (); 117 sb.append(" "); 118 sb.append(xmlTag); 119 sb.append("=\""); 120 sb.append(value); 121 sb.append("\""); 122 return sb.toString(); 123 } 124 125 } 126 | Popular Tags |