Source Code Cross Referenced for Debug.java in  » Code-Analyzer » javapathfinder » gov » nasa » jpf » 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 » Code Analyzer » javapathfinder » gov.nasa.jpf.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        // Copyright (C) 2005 United States Government as represented by the
003:        // Administrator of the National Aeronautics and Space Administration
004:        // (NASA).  All Rights Reserved.
005:        // 
006:        // This software is distributed under the NASA Open Source Agreement
007:        // (NOSA), version 1.3.  The NOSA has been approved by the Open Source
008:        // Initiative.  See the file NOSA-1.3-JPF at the top of the distribution
009:        // directory tree for the complete NOSA document.
010:        // 
011:        // THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
012:        // KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
013:        // LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
014:        // SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
015:        // A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
016:        // THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
017:        // DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
018:        //
019:        package gov.nasa.jpf.util;
020:
021:        import java.io.PrintWriter;
022:
023:        /**
024:         * logger used to print debugging messages based on the required debug level and
025:         * message category.
026:         * <2do> - replace this by log4j !
027:         */
028:        public class Debug {
029:            public static final int ERROR = 0;
030:            public static final int WARNING = 1;
031:            public static final int MESSAGE = 2;
032:            public static final int DEBUG = 3;
033:            private static final int LAST_LEVEL = 4;
034:            public static final int DEFAULT = 0;
035:            public static final int RACE = 1;
036:            public static final int LOCK_ORDER = 2;
037:            public static final int DEPEND = 3;
038:            public static final int DISTRIBUTED = 4;
039:            public static final int SEARCH = 5;
040:            public static final int TRACE = 6;
041:            private static final int LAST_KIND = 7;
042:            private static int[] enabled = new int[LAST_KIND];
043:            private static String[] levels = { "error", "warning", "message",
044:                    "debug" };
045:            private static String[] kinds = { "default", "race", "lock-order",
046:                    "depend", "distributed", "search", "trace" };
047:
048:            public static void setDebugLevel(int l) {
049:                if ((l < 0) || (l >= LAST_LEVEL)) {
050:                    throw new IllegalArgumentException("0 <= level < "
051:                            + LAST_LEVEL);
052:                }
053:
054:                enabled[DEFAULT] = l;
055:            }
056:
057:            public static void setDebugLevel(String ls) {
058:                int l = mapLevel(ls);
059:
060:                if (l == -1) {
061:                    throw new IllegalArgumentException(ls
062:                            + " is not a valid level");
063:                }
064:
065:                enabled[DEFAULT] = l;
066:            }
067:
068:            public static void setDebugLevel(int l, int k) {
069:                if ((l < 0) || (l >= LAST_LEVEL)) {
070:                    throw new IllegalArgumentException("0 <= level < "
071:                            + LAST_LEVEL);
072:                }
073:
074:                if ((k < 0) || (k >= LAST_KIND)) {
075:                    throw new IllegalArgumentException("0 <= kind < "
076:                            + LAST_KIND);
077:                }
078:
079:                enabled[k] = l;
080:            }
081:
082:            public static void setDebugLevel(int l, String ks) {
083:                if ((l < 0) || (l >= LAST_LEVEL)) {
084:                    throw new IllegalArgumentException("0 <= level < "
085:                            + LAST_LEVEL);
086:                }
087:
088:                int k = mapKind(ks);
089:
090:                if (k == -1) {
091:                    throw new IllegalArgumentException(ks
092:                            + " is not a valid kind");
093:                }
094:
095:                enabled[k] = l;
096:            }
097:
098:            public static void setDebugLevel(String ls, int k) {
099:                if ((k < 0) || (k >= LAST_KIND)) {
100:                    throw new IllegalArgumentException("0 <= kind < "
101:                            + LAST_KIND);
102:                }
103:
104:                int l = mapLevel(ls);
105:
106:                if (l == -1) {
107:                    throw new IllegalArgumentException(ls
108:                            + " is not a valid level");
109:                }
110:
111:                enabled[k] = l;
112:            }
113:
114:            public static void setDebugLevel(String ls, String ks) {
115:                int l = mapLevel(ls);
116:
117:                if (l == -1) {
118:                    throw new IllegalArgumentException(ls
119:                            + " is not a valid level");
120:                }
121:
122:                int k = mapKind(ks);
123:
124:                if (k == -1) {
125:                    throw new IllegalArgumentException(ks
126:                            + " is not a valid kind");
127:                }
128:
129:                enabled[k] = l;
130:            }
131:
132:            public static int getDebugLevel() {
133:                return enabled[DEFAULT];
134:            }
135:
136:            public static int getDebugLevel(int k) {
137:                return enabled[k];
138:            }
139:
140:            public static int getDebugLevel(String ks) {
141:                int k = mapKind(ks);
142:
143:                if (k == -1) {
144:                    throw new IllegalArgumentException(ks
145:                            + " is not a valid kind");
146:                }
147:
148:                return enabled[k];
149:            }
150:
151:            public static int mapKind(String ks) {
152:                for (int k = 0; k < LAST_KIND; k++) {
153:                    if (ks.equals(kinds[k])) {
154:                        return k;
155:                    }
156:                }
157:
158:                return -1;
159:            }
160:
161:            public static int mapLevel(String ls) {
162:                for (int l = 0; l < LAST_LEVEL; l++) {
163:                    if (ls.equals(levels[l])) {
164:                        return l;
165:                    }
166:                }
167:
168:                return -1;
169:            }
170:
171:            public static void print(int l, Object o) {
172:                if (l <= enabled[DEFAULT]) {
173:                    System.err.print(o);
174:                }
175:            }
176:
177:            public static void print(int l, String s) {
178:                if (l <= enabled[DEFAULT]) {
179:                    System.err.print(s);
180:                }
181:            }
182:
183:            public static void print(int l, int k, Object o) {
184:                if (l <= enabled[k]) {
185:                    System.err.print(o);
186:                }
187:            }
188:
189:            public static void print(int l, int k, String s) {
190:                if (l <= enabled[k]) {
191:                    System.err.print(s);
192:                }
193:            }
194:
195:            public static void print(int l, int k, Printable p) {
196:                if (l <= enabled[k]) {
197:                    PrintWriter pw = new PrintWriter(System.err, true);
198:                    p.printOn(pw);
199:                }
200:            }
201:
202:            public static void print(int l, Printable p) {
203:                print(l, DEFAULT, p);
204:            }
205:
206:            public static void println(int l, int k, Printable p) {
207:                if (l <= enabled[k]) {
208:                    PrintWriter pw = new PrintWriter(System.err, true);
209:                    p.printOn(pw);
210:                    System.err.println();
211:                }
212:            }
213:
214:            public static void println(int l, Printable p) {
215:                println(l, DEFAULT, p);
216:            }
217:
218:            public static void println(int l) {
219:                if (l <= enabled[DEFAULT]) {
220:                    System.err.println();
221:                }
222:            }
223:
224:            public static void println(int l, Object o) {
225:                if (l <= enabled[DEFAULT]) {
226:                    System.err.println(o);
227:                }
228:            }
229:
230:            public static void println(int l, String s) {
231:                if (l <= enabled[DEFAULT]) {
232:                    System.err.println(s);
233:                }
234:            }
235:
236:            public static void println(int l, int k) {
237:                if (l <= enabled[k]) {
238:                    System.err.println();
239:                }
240:            }
241:
242:            public static void println(int l, int k, Object o) {
243:                if (l <= enabled[k]) {
244:                    System.err.println(o);
245:                }
246:            }
247:
248:            public static void println(int l, int k, String s) {
249:                if (l <= enabled[k]) {
250:                    System.err.println(s);
251:                }
252:            }
253:
254:            public static String status() {
255:                StringBuffer sb = new StringBuffer();
256:
257:                for (int k = 1; k < LAST_KIND; k++) {
258:                    int l = enabled[k];
259:
260:                    if (l != ERROR) {
261:                        if (sb.length() != 0) {
262:                            sb.append(",");
263:                        }
264:
265:                        sb.append(kinds[k]);
266:                        sb.append("=");
267:                        sb.append(levels[l]);
268:                    }
269:                }
270:
271:                return sb.toString();
272:            }
273:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.