Source Code Cross Referenced for Debug.java in  » Testing » KeY » de » uka » ilkd » key » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » KeY » de.uka.ilkd.key.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // This file is part of KeY - Integrated Deductive Software Design
002:        // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003:        //                         Universitaet Koblenz-Landau, Germany
004:        //                         Chalmers University of Technology, Sweden
005:        //
006:        // The KeY system is protected by the GNU General Public License. 
007:        // See LICENSE.TXT for details.
008:        //
009:        //
010:
011:        /** this class offers some methods for assertions, debug output and so
012:         * on */package de.uka.ilkd.key.util;
013:
014:        public final class Debug {
015:
016:            private Debug() {
017:            }
018:
019:            /** has to be set in order to enable assertion */
020:            public static boolean ENABLE_ASSERTION = true;
021:            /** has to be set in order to enable debugging */
022:            public static boolean ENABLE_DEBUG = "on".equals(System
023:                    .getProperty("KeyDebugFlag"));
024:
025:            /** prints given string if in debug mode 
026:             * @param msg the String to be printed
027:             */
028:            public static void out(String msg) {
029:                if (ENABLE_DEBUG) {
030:                    System.out.println("DEBUG:: " + msg);
031:                }
032:            }
033:
034:            /** prints given string and the result of calling the toString method of 
035:             * of the given obj if in debug mode. The advantage of calling the toString
036:             * here and not before is that if debug mode is disabled no string
037:             * computation is done
038:             * @param msg the String to be printed
039:             * @param obj the Object where to call the toString method
040:             */
041:            public static final void out(String msg, Object obj) {
042:                if (ENABLE_DEBUG) {
043:                    System.out.println("DEBUG:: " + msg + " " + obj);
044:                }
045:            }
046:
047:            /** prints given string and the result of calling the toString method of 
048:             * of the given objects if in debug mode. The advantage of calling the toString
049:             * here and not before is that if debug mode is disabled no string
050:             * computation is done
051:             * @param msg the String to be printed
052:             * @param obj1 the first Object where to call the toString method
053:             * @param obj2 the second Object where to call the toString method
054:             */
055:            public static final void out(String msg, Object obj1, Object obj2) {
056:                if (ENABLE_DEBUG) {
057:                    System.out.println("DEBUG:: " + msg + ":(" + obj1 + ", "
058:                            + obj2 + ")");
059:                }
060:            }
061:
062:            /** prints given string and the result of calling the toString method of 
063:             * of the given objects if in debug mode. The advantage of calling the toString
064:             * here and not before is that if debug mode is disabled no string
065:             * computation is done
066:             * @param msg the String to be printed
067:             * @param obj1 the first Object where to call the toString method
068:             * @param obj2 the second Object where to call the toString method
069:             * @param obj3 the third Object where to call the toString method
070:             */
071:            public static final void out(String msg, Object obj1, Object obj2,
072:                    Object obj3) {
073:                if (ENABLE_DEBUG) {
074:                    System.out.println("DEBUG:: " + msg + ":(" + obj1 + ", "
075:                            + obj2 + ", " + obj3 + ")");
076:                }
077:            }
078:
079:            /** prints the given string followed by the int if in debug mode.
080:             * @param msg the String to be printed
081:             * @param id the int printed after msg
082:             */
083:            public static final void out(String msg, long id) {
084:                if (ENABLE_DEBUG) {
085:                    System.out.println("DEBUG:: " + msg + " " + id);
086:                }
087:            }
088:
089:            /** prints the given string followed by the int if in debug mode.
090:             * @param msg the String to be printed
091:             * @param id1 the int printed first after msg
092:             * @param id1 the int printed second after msg
093:             */
094:            public static final void out(String msg, long id1, long id2) {
095:                if (ENABLE_DEBUG) {
096:                    System.out.println("DEBUG:: " + msg + ":(" + id1 + ", "
097:                            + id2 + ")");
098:                }
099:            }
100:
101:            /** prints the given string followed by the boolean if in debug mode.
102:             * @param msg the String to be printed
103:             * @param b the boolean printed after msg
104:             */
105:            public static final void out(String msg, boolean b) {
106:                if (ENABLE_DEBUG) {
107:                    System.out.println("DEBUG:: " + msg + " " + b);
108:                }
109:            }
110:
111:            /** prints given string, if the condition cond is true
112:             * @param msg the String to be printed
113:             * @param cond the boolean deciding if the message is printed or not
114:             */
115:            public static final void outIfEqual(String msg, boolean cond) {
116:                if (ENABLE_DEBUG) {
117:                    if (cond) {
118:                        System.out.println("DEBUG:: " + msg);
119:                    }
120:                }
121:            }
122:
123:            /** prints given string, if calling the equal method of obj1, with obj2 as
124:             * argument results in true
125:             * @param msg the String to be printed
126:             * @param obj1 the Object where to call the equals method
127:             * @param obj2 the Object given to as parameter of the equals method of obj1
128:             */
129:            public static final void outIfEqual(String msg, Object obj1,
130:                    Object obj2) {
131:                if (ENABLE_DEBUG) {
132:                    if ((obj1 == null && obj2 == null)
133:                            || (obj1 != null && obj1.equals(obj2))) {
134:                        System.out.println("DEBUG:: " + msg);
135:                    }
136:                }
137:            }
138:
139:            /** prints the stack trace if in debug mode 
140:             * @author VK
141:             */
142:            public static final void out(Exception e) {
143:                if (ENABLE_DEBUG) {
144:                    e.printStackTrace();
145:                }
146:            }
147:
148:            /**  an assertion failure is thrown if isOK is evaluated to false
149:             * @param isOK boolean the assertion that is checked
150:             */
151:            public static final void assertTrue(boolean isOK) {
152:                if (ENABLE_ASSERTION) {
153:                    if (!isOK) {
154:                        fail();
155:                    }
156:                }
157:            }
158:
159:            public static final void assertFalse(boolean isNotOK) {
160:                assertTrue(!isNotOK);
161:            }
162:
163:            /**  an assertion failure is thrown if isOK is evaluated to false
164:             * the text in message is handed over to this exception
165:             * @param isOK boolean the assertion that is checked
166:             * @param message String describes the failed assertion
167:             */
168:            public static final void assertTrue(boolean isOK, String message) {
169:                if (ENABLE_ASSERTION) {
170:                    if (!isOK) {
171:                        fail(message);
172:                    }
173:                }
174:            }
175:
176:            /**  an assertion failure is thrown if isOK is evaluated to false
177:             * the text in message is handed over to this exception
178:             * @param isOK boolean the assertion that is checked
179:             * @param message String describes the failed assertion
180:             */
181:            public static final void assertTrue(boolean isOK, String message,
182:                    Object parameter) {
183:                if (ENABLE_ASSERTION) {
184:                    if (!isOK) {
185:                        fail(message + ":" + parameter);
186:                    }
187:                }
188:            }
189:
190:            public static final void assertFalse(boolean isNotOK, String message) {
191:                assertTrue(!isNotOK, message);
192:            }
193:
194:            public static final void fail() {
195:                fail("No further information available.");
196:            }
197:
198:            public static final void fail(String message) {
199:                if (ENABLE_ASSERTION) {
200:                    throw new AssertionFailure("\nAssertion failure: "
201:                            + message);
202:                }
203:            }
204:
205:            public static final void fail(String message, Object o) {
206:                if (ENABLE_ASSERTION) {
207:                    throw new AssertionFailure("\nAssertion failure: "
208:                            + message + ":" + o);
209:                }
210:            }
211:
212:            /**
213:             * prints the stack trace of the given exception
214:             */
215:            public static final void printStackTrace(Exception e) {
216:                if (ENABLE_DEBUG) {
217:                    e.printStackTrace(System.out);
218:                }
219:            }
220:
221:            /** 
222:             * Prints a stack trace (without influencing the execution in any way).
223:             * @author VK
224:             */
225:            public static final void printStackTrace() {
226:                try {
227:                    throw new Exception();
228:                } catch (Exception e) {
229:                    System.out
230:                            .println("************* DEBUG::Stacktrace *************");
231:                    e.printStackTrace(System.out);
232:                }
233:            }
234:
235:            public static String stackTrace() {
236:                Throwable t = new Throwable();
237:                java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
238:                t.printStackTrace(new java.io.PrintStream(baos));
239:                return (baos.toString());
240:            }
241:
242:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.