1 16 17 package org.apache.log4j.or.sax; 18 19 import org.apache.log4j.or.ObjectRenderer; 20 21 import org.xml.sax.Attributes ; 22 23 28 public class AttributesRenderer implements ObjectRenderer { 29 30 public 31 AttributesRenderer() { 32 } 33 34 35 38 public 39 String doRender(Object o) { 40 if(o instanceof Attributes ) { 41 StringBuffer sbuf = new StringBuffer (); 42 Attributes a = (Attributes ) o; 43 int len = a.getLength(); 44 boolean first = true; 45 for(int i = 0; i < len; i++) { 46 if(first) { 47 first = false; 48 } else { 49 sbuf.append(", "); 50 } 51 sbuf.append(a.getQName(i)); 52 sbuf.append('='); 53 sbuf.append(a.getValue(i)); 54 } 55 return sbuf.toString(); 56 } else { 57 return o.toString(); 58 } 59 } 60 } 61 62 | Popular Tags |