1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.core.util;
17
18 import org.apache.commons.lang.StringUtils;
19
20 import java.util.HashMap;
21 import java.util.Map;
22
23
24
25
26
27
28
29 public class AttributeSet extends HashMap<String,String> {
30
31 private static final long serialVersionUID = -5960854367616060667L;
32
33 public AttributeSet() {
34 super();
35 }
36
37
38
39
40 public AttributeSet( String key, String value ) {
41 this();
42 put( key, value );
43 }
44
45
46
47
48
49
50 public AttributeSet( int initialSize ) {
51 super( initialSize );
52 }
53
54 public AttributeSet( Map<String,String> map ) {
55 super();
56 if ( map != null ) {
57 putAll( map );
58 }
59 }
60
61 public String formattedDump( int indent ) {
62 int maxKeyLen = 1;
63 for ( String key : this.keySet() ) {
64 if ( key.length() > maxKeyLen ) {
65 maxKeyLen = key.length();
66 }
67 }
68 StringBuffer sb = new StringBuffer();
69 String indentStr = StringUtils.repeat( " ", indent );
70 for ( String key : this.keySet() ) {
71 sb.append( indentStr );
72 sb.append( StringUtils.rightPad( key, maxKeyLen, ' ' ));
73 sb.append( " --> " );
74 sb.append( get( key ) );
75 sb.append( '\n' );
76 }
77 return sb.toString();
78 }
79 }