KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > extractor > common > Debug


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.extractor.common;
24
25
26 public class Debug {
27     private static final String JavaDoc RCSRevision = "$Revision: 1.4 $";
28     private static final String JavaDoc RCSName = "$Name: $";
29
30
31     static final String JavaDoc NEWLINE = System.getProperty("line.separator");
32
33     public static void assertTrue (boolean predicate , String JavaDoc message) {
34         if ( !predicate ) {
35             throw new AssertionException (message) ;
36         }
37     }
38
39 // public static void assert (String functionName, boolean predicate, String message)
40
// {
41
// if ( !predicate )
42
// {
43
// throw new AssertionException ("Function Name : " + functionName + " -- " + message) ;
44
// }
45
// }
46

47     public static void nyi (String JavaDoc message)
48     {
49         throw new DebugException("not yet implemented : " + message);
50     }
51
52 // public static void disable(String date)
53
// {
54
// throw new DebugException ("The following code is disabled in " + date) ;
55
// }
56

57 // public static void showResultSet (ResultSet resultSet )
58
// {
59
// StringBuffer retVal = new StringBuffer();
60
// char[] spaces =
61
// (new String(" ")).toCharArray();
62
//
63
// try {
64
// ResultSetMetaData metaData = resultSet.getMetaData();
65
//
66
// System.err.println ( "< ============== SQL Query result ============ >" );
67
// if (null != resultSet) {
68
// int numberOfColumns = metaData.getColumnCount();
69
// retVal.append("RowNo | " );
70
// for (int i = 1; i <= numberOfColumns; i++) {
71
// if (i > 1) {
72
// retVal.append(",\t" );
73
// }
74
// retVal.append(metaData.getColumnName(i));
75
// }
76
// System.err.println (retVal) ;
77
// System.err.println ("--------------------------------------------" ) ;
78
//
79
// long rowNo = 0;
80
// String rowNoString = null;
81
//
82
// while (resultSet.next()) {
83
// retVal = new StringBuffer();
84
//
85
// rowNo ++ ;
86
// rowNoString = Long.toString(rowNo);
87
// retVal.append(rowNoString);
88
// if (rowNoString.length()< 5) {
89
// retVal.append(spaces, 0, 5 - rowNoString.length());
90
// }
91
// retVal.append(" | ");
92
//
93
// for (int i = 1; i <= numberOfColumns; i++) {
94
// if (i > 1) {
95
// retVal.append(",\t" );
96
// }
97
// retVal.append(resultSet.getString(i));
98
// }
99
// System.err.println (retVal) ;
100
// }
101
// }
102
// else
103
// {
104
//
105
// }
106
// System.err.println ( "</ ============= SQL Query result ============ >" );
107
//
108
// }
109
// catch (SQLException ex) {
110
// System.err.print( ex.getMessage() ) ;
111
// }
112
// }
113

114     /**
115      * compare two file
116      * @return 0 : if the two file is identical.
117      * index of the first different byte
118      */

119 // public static long compareFile (String fileName1,String fileName2 ) throws IOException {
120
// FileInputStream f1 = new FileInputStream(fileName1);
121
// FileInputStream f2 = new FileInputStream(fileName2);
122
//
123
// int c1 , c2 ;
124
// boolean isEqual = true;
125
// long counter = 0 ;
126
// do {
127
// counter ++ ;
128
// c1 = f1.read();
129
// c2 = f2.read();
130
// if (c1 != c2) {
131
// isEqual = false;
132
// break;
133
// }
134
// } while (c1 != -1 && c2 != -1);
135
//
136
// f1.close();
137
// f2.close();
138
//
139
// if (isEqual) {
140
// return 0;
141
// }
142
// else {
143
// return counter;
144
// }
145
// }
146

147 // static public String pprint(Map map) {
148
//
149
// StringBuffer retVal = new StringBuffer();
150
// retVal.append(NEWLINE);
151
// retVal.append("<================ ");
152
// retVal.append(map.toString());
153
// retVal.append(" ================>");
154
// retVal.append(NEWLINE);
155
// Object keyList[] = map.keySet().toArray();
156
// Object key = null;
157
// Object value = null;
158
//
159
// for (int i = 0; i < keyList.length; i++) {
160
// key = keyList[i];
161
// retVal.append(Integer.toString(i));
162
// retVal.append("\t");
163
//
164
// retVal.append(key.toString());
165
// retVal.append("\t\t");
166
//
167
// value = map.get(key);
168
// retVal.append(value.toString());
169
// retVal.append(NEWLINE);
170
// }
171
//
172
// retVal.append("<================ ");
173
// retVal.append(map.toString());
174
// retVal.append(" ================>");
175
//
176
// return retVal.toString();
177
// }
178

179 }
180
Popular Tags