1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.slf4j.profiler;
26
27 public class SpacePadder {
28 public static final String LINE_SEP = System.getProperty("line.separator");
29
30 final static String[] SPACES = { " ", " ", " ", " ",
31
32 " ",
33 " " };
34
35 @Deprecated
36 final static public void leftPad(StringBuffer buf, String s, int desiredLength) {
37 int actualLen = 0;
38 if (s != null) {
39 actualLen = s.length();
40 }
41 if (actualLen < desiredLength) {
42 spacePad(buf, desiredLength - actualLen);
43 }
44 if (s != null) {
45 buf.append(s);
46 }
47 }
48
49 final static public void leftPad(StringBuilder buf, String s, int desiredLength) {
50 int actualLen = 0;
51 if (s != null) {
52 actualLen = s.length();
53 }
54 if (actualLen < desiredLength) {
55 spacePad(buf, desiredLength - actualLen);
56 }
57 if (s != null) {
58 buf.append(s);
59 }
60 }
61
62 @Deprecated
63 final static public void rightPad(StringBuffer buf, String s, int desiredLength) {
64 int actualLen = 0;
65 if (s != null) {
66 actualLen = s.length();
67 }
68 if (s != null) {
69 buf.append(s);
70 }
71 if (actualLen < desiredLength) {
72 spacePad(buf, desiredLength - actualLen);
73 }
74 }
75
76 final static public void rightPad(StringBuilder buf, String s, int desiredLength) {
77 int actualLen = 0;
78 if (s != null) {
79 actualLen = s.length();
80 }
81 if (s != null) {
82 buf.append(s);
83 }
84 if (actualLen < desiredLength) {
85 spacePad(buf, desiredLength - actualLen);
86 }
87 }
88
89
90
91
92
93
94
95 @Deprecated
96 final static public void spacePad(StringBuffer sbuf, int length) {
97 while (length >= 32) {
98 sbuf.append(SPACES[5]);
99 length -= 32;
100 }
101
102 for (int i = 4; i >= 0; i--) {
103 if ((length & (1 << i)) != 0) {
104 sbuf.append(SPACES[i]);
105 }
106 }
107 }
108
109
110
111
112
113
114
115 final static public void spacePad(StringBuilder sbuf, int length) {
116 while (length >= 32) {
117 sbuf.append(SPACES[5]);
118 length -= 32;
119 }
120
121 for (int i = 4; i >= 0; i--) {
122 if ((length & (1 << i)) != 0) {
123 sbuf.append(SPACES[i]);
124 }
125 }
126 }
127 }