1 package com.tonbeller.tbutils.res; 2 3 import java.util.ArrayList ; 4 import java.util.Collections ; 5 import java.util.Iterator ; 6 import java.util.List ; 7 8 9 10 public class StringDumper implements Dumper { 11 12 private static final String SEP = "===================================\n"; 13 StringBuffer sb = new StringBuffer (); 14 15 public StringDumper() { 16 } 17 18 22 protected boolean accept(String name) { 23 return true; 24 } 25 26 public void dump(ResourceProvider p) { 27 if (p == null) 28 return; 29 sb.append(SEP); 30 sb.append(p.getClass().getName()).append(": ").append(p.getName()).append("\n"); 31 sb.append(SEP); 32 List keys = new ArrayList (); 33 keys.addAll(p.keySet()); 34 Collections.sort(keys); 35 for (Iterator it = keys.iterator(); it.hasNext();) { 36 String key = (String ) it.next(); 37 if (!accept(key)) 38 continue; 39 String val = p.getString(key); 40 sb.append(key).append(" = ").append(val).append("\n"); 41 } 42 } 43 44 public String toString() { 45 return sb.toString(); 46 } 47 48 } 49 | Popular Tags |