1 package org.apache.ojb.broker.util; 2 3 17 18 import org.apache.commons.lang.SystemUtils; 19 20 import java.util.Properties ; 21 import java.util.Enumeration ; 22 23 29 public class XmlHelper 30 { 31 32 33 public static final String XML_EOL = SystemUtils.LINE_SEPARATOR; 34 35 43 public static String getSerializedAttributes(final String prefix, 44 final Properties attributeProperties) 45 { 46 final StringBuffer buf = new StringBuffer (); 47 appendSerializedAttributes(buf, prefix, attributeProperties); 48 return buf.toString(); 49 } 50 51 59 public static void appendSerializedAttributes(final StringBuffer buf, 60 final String prefix, 61 final Properties attributeProperties) 62 { 63 if (attributeProperties != null) 64 { 65 final Enumeration keys = attributeProperties.keys(); 66 while (keys.hasMoreElements()) 67 { 68 final String key = (String ) keys.nextElement(); 69 final String value = attributeProperties.getProperty( key ); 70 if (prefix != null) 71 { 72 buf.append(prefix); 73 } 74 buf.append("<attribute attribute-name=\"").append(key); 75 buf.append("\" attribute-value=\"" ).append(value); 76 buf.append("\"/>"); 77 buf.append(XML_EOL); 78 } 79 } 80 } 81 82 } 83 | Popular Tags |