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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
package com.healthmarketscience.jackcess.scsu;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/*
* This sample software accompanies Unicode Technical Report #6 and
* distributed as is by Unicode, Inc., subject to the following:
*
* Copyright � 1996-1997 Unicode, Inc.. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software
* without fee is hereby granted provided that this copyright notice
* appears in all copies.
*
* UNICODE, INC. MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
* SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
* UNICODE, INC., SHALL NOT BE LIABLE FOR ANY ERRORS OR OMISSIONS, AND
* SHALL NOT BE LIABLE FOR ANY DAMAGES, INCLUDING CONSEQUENTIAL AND
* INCIDENTAL DAMAGES, SUFFERED BY YOU AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*
* @author Asmus Freytag
*
* @version 001 Dec 25 1996
* @version 002 Jun 25 1997
* @version 003 Jul 25 1997
* @version 004 Aug 25 1997
*
* Unicode and the Unicode logo are trademarks of Unicode, Inc.,
* and are registered in some jurisdictions.
**/
/**
* A number of helpful output routines for debugging. Output can be
* centrally enabled or disabled by calling Debug.set(true/false);
* All methods are statics;
*/
public class Debug
{
private static final Log LOG = LogFactory.getLog(Debug.class);
// debugging helper
public static void out(char [] chars)
{
out(chars, 0);
}
public static void out(char [] chars, int iStart)
{
if (!LOG.isDebugEnabled()) return;
StringBuffer msg = new StringBuffer();
for (int i = iStart; i < chars.length; i++)
{
if (chars[i] >= 0 && chars[i] <= 26)
{
msg.append("^"+(char)(chars[i]+0x40));
}
else if (chars[i] <= 255)
{
msg.append(chars[i]);
}
else
{
msg.append("\\u"+Integer.toString(chars[i],16));
}
}
LOG.debug(msg.toString());
}
public static void out(byte [] bytes)
{
out(bytes, 0);
}
public static void out(byte [] bytes, int iStart)
{
if (!LOG.isDebugEnabled()) return;
StringBuffer msg = new StringBuffer();
for (int i = iStart; i < bytes.length; i++)
{
msg.append(bytes[i]+",");
}
LOG.debug(msg.toString());
}
public static void out(String str)
{
if (!LOG.isDebugEnabled()) return;
LOG.debug(str);
}
public static void out(String msg, int iData)
{
if (!LOG.isDebugEnabled()) return;
LOG.debug(msg + iData);
}
public static void out(String msg, char ch)
{
if (!LOG.isDebugEnabled()) return;
LOG.debug(msg + "[U+"+Integer.toString(ch,16)+"]" + ch);
}
public static void out(String msg, byte bData)
{
if (!LOG.isDebugEnabled()) return;
LOG.debug(msg + bData);
}
public static void out(String msg, String str)
{
if (!LOG.isDebugEnabled()) return;
LOG.debug(msg + str);
}
public static void out(String msg, char [] data)
{
if (!LOG.isDebugEnabled()) return;
LOG.debug(msg);
out(data);
}
public static void out(String msg, byte [] data)
{
if (!LOG.isDebugEnabled()) return;
LOG.debug(msg);
out(data);
}
public static void out(String msg, char [] data, int iStart)
{
if (!LOG.isDebugEnabled()) return;
LOG.debug(msg +"("+iStart+"): ");
out(data, iStart);
}
public static void out(String msg, byte [] data, int iStart)
{
if (!LOG.isDebugEnabled()) return;
LOG.debug(msg+"("+iStart+"): ");
out(data, iStart);
}
}
|