1 23 24 package org.objectweb.joram.client.jms.admin; 25 26 29 public class XmlSerializer { 30 31 32 37 public static String indent(int indent) { 38 String txt = ""; 39 for (int i = 0; i < indent; i++) { 40 txt += " "; 41 } 42 return txt; 43 } 44 45 52 public static String xmlElement(String value, String xmlTag, int indent) { 53 if (value == null) { 54 return ""; 55 } 56 57 59 StringBuffer sb = new StringBuffer (); 60 sb.append(indent(indent)); 61 sb.append("<"); 62 sb.append(xmlTag); 63 sb.append(">"); 64 sb.append(value); 65 sb.append("</"); 66 sb.append(xmlTag); 67 sb.append(">\n"); 68 return sb.toString(); 69 } 70 71 77 public static String xmlAttribute(String value, String xmlTag) { 78 if (value == null) { 79 return ""; 80 } 81 82 84 StringBuffer sb = new StringBuffer (); 85 sb.append(" "); 86 sb.append(xmlTag); 87 sb.append("=\""); 88 sb.append(value); 89 sb.append("\""); 90 return sb.toString(); 91 } 92 93 } 94 | Popular Tags |