1 package com.healthmarketscience.jackcess.scsu;
2
3 import org.apache.commons.logging.Log;
4 import org.apache.commons.logging.LogFactory;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 public class Debug
43 {
44
45 private static final Log LOG = LogFactory.getLog(Debug.class);
46
47
48 public static void out(char [] chars)
49 {
50 out(chars, 0);
51 }
52
53 public static void out(char [] chars, int iStart)
54 {
55 if (!LOG.isDebugEnabled()) return;
56 StringBuilder msg = new StringBuilder();
57
58 for (int i = iStart; i < chars.length; i++)
59 {
60 if (chars[i] >= 0 && chars[i] <= 26)
61 {
62 msg.append("^"+(char)(chars[i]+0x40));
63 }
64 else if (chars[i] <= 255)
65 {
66 msg.append(chars[i]);
67 }
68 else
69 {
70 msg.append("\\u"+Integer.toString(chars[i],16));
71 }
72 }
73 LOG.debug(msg.toString());
74 }
75
76 public static void out(byte [] bytes)
77 {
78 out(bytes, 0);
79 }
80 public static void out(byte [] bytes, int iStart)
81 {
82 if (!LOG.isDebugEnabled()) return;
83 StringBuilder msg = new StringBuilder();
84
85 for (int i = iStart; i < bytes.length; i++)
86 {
87 msg.append(bytes[i]+",");
88 }
89 LOG.debug(msg.toString());
90 }
91
92 public static void out(String str)
93 {
94 if (!LOG.isDebugEnabled()) return;
95
96 LOG.debug(str);
97 }
98
99 public static void out(String msg, int iData)
100 {
101 if (!LOG.isDebugEnabled()) return;
102
103 LOG.debug(msg + iData);
104 }
105 public static void out(String msg, char ch)
106 {
107 if (!LOG.isDebugEnabled()) return;
108
109 LOG.debug(msg + "[U+"+Integer.toString(ch,16)+"]" + ch);
110 }
111 public static void out(String msg, byte bData)
112 {
113 if (!LOG.isDebugEnabled()) return;
114
115 LOG.debug(msg + bData);
116 }
117 public static void out(String msg, String str)
118 {
119 if (!LOG.isDebugEnabled()) return;
120
121 LOG.debug(msg + str);
122 }
123 public static void out(String msg, char [] data)
124 {
125 if (!LOG.isDebugEnabled()) return;
126
127 LOG.debug(msg);
128 out(data);
129 }
130 public static void out(String msg, byte [] data)
131 {
132 if (!LOG.isDebugEnabled()) return;
133
134 LOG.debug(msg);
135 out(data);
136 }
137 public static void out(String msg, char [] data, int iStart)
138 {
139 if (!LOG.isDebugEnabled()) return;
140
141 LOG.debug(msg +"("+iStart+"): ");
142 out(data, iStart);
143 }
144 public static void out(String msg, byte [] data, int iStart)
145 {
146 if (!LOG.isDebugEnabled()) return;
147
148 LOG.debug(msg+"("+iStart+"): ");
149 out(data, iStart);
150 }
151 }