Source Code Cross Referenced for Debug.java in  » Groupware » LibreSource » org » esupportail » cas » server » util » log » 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 » Groupware » LibreSource » org.esupportail.cas.server.util.log 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.esupportail.cas.server.util.log;
002:
003:        import org.dom4j.Element;
004:        import org.esupportail.cas.server.util.MisconfiguredHandlerException;
005:
006:        /**
007:         * This class implements a basic object owning debugging features.
008:         *
009:         * @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
010:         */
011:        public abstract class Debug {
012:            /**
013:             * A debugging flag.
014:             */
015:            private boolean debug;
016:
017:            /**
018:             * Tell if the handler is in debugging mode or not.
019:             *
020:             * @return true when the handler is in debugging mode, false otherwise.
021:             */
022:            public final boolean isDebug() {
023:                return debug;
024:            }
025:
026:            /**
027:             * Set deubgging mode.
028:             *
029:             * @param d a boolean
030:             */
031:            public final void setDebug(final boolean d) {
032:                this .debug = d;
033:            }
034:
035:            /** 
036:             * Debugging. 
037:             * @param str a string 
038:             */
039:            protected final void trace(final String str) {
040:                if (debug) {
041:                    Log.debug(str);
042:                }
043:            }
044:
045:            /** 
046:             * Debugging. 
047:             * @param obj an object 
048:             */
049:            protected final void trace(final Object obj) {
050:                trace(obj.toString());
051:            }
052:
053:            /** 
054:             * Debugging (at the beginning of the execution of a method). 
055:             */
056:            protected final void traceBegin() {
057:                if (debug) {
058:                    Log.traceBegin();
059:                }
060:            }
061:
062:            /** 
063:             * Debugging (at the end of the execution of a method). 
064:             * @param str a string 
065:             */
066:            protected final void traceEnd(final String str) {
067:                if (debug) {
068:                    Log.traceEnd(str);
069:                }
070:            }
071:
072:            /** 
073:             * Debugging (at the end of the execution of a method). 
074:             * @param obj an object 
075:             */
076:            protected final void traceEnd(final Object obj) {
077:                traceEnd(obj.toString());
078:            }
079:
080:            /** Debugging (at the end of the execution of a method). */
081:            protected final void traceEnd() {
082:                traceEnd("");
083:            }
084:
085:            /** 
086:             * Debugging (throwing an exception).
087:             * 
088:             * @param e the exception to throw
089:             * @throws Exception Exception
090:             */
091:            protected final void traceThrow(final Exception e) throws Exception {
092:                traceEnd("THROWS " + e.getClass().getName() + ": "
093:                        + e.getMessage());
094:                throw e;
095:            }
096:
097:            /**
098:             * Constructor.
099:             *
100:             * @param d true to set debugging mode, false otherwise.
101:             */
102:            protected Debug(final boolean d) {
103:                super ();
104:                debug = d;
105:                traceBegin();
106:                trace("debug = " + debug);
107:                traceEnd();
108:            }
109:
110:            /**
111:             * A convenient method to get debugging mode with a default value.
112:             *
113:             * @param element an XML element having a debug attribute ("on", "off" or "default")
114:             * @param defaultValue the value to return when str equals to "default"
115:             *
116:             * @return a boolean.
117:             */
118:            public static boolean elementDebugValue(final Element element,
119:                    final boolean defaultValue) {
120:                String str = element.attributeValue("debug", "default");
121:                if (str.equals("on")) {
122:                    return true;
123:                } else if (str.equals("off")) {
124:                    return false;
125:                } else {
126:                    return defaultValue;
127:                }
128:            }
129:
130:            /**
131:             * Check that a class is present
132:             * 
133:             * @param classname the name of the class
134:             * @return the corresponding class
135:             * @throws Exception Exception
136:             */
137:            protected final Class checkClass(final String classname)
138:                    throws Exception {
139:                traceBegin();
140:                trace("Checking if class \"" + classname + "\" is available...");
141:                try {
142:                    traceEnd("ok");
143:                    return Class.forName(classname);
144:                } catch (ClassNotFoundException e) {
145:                    trace("Class not found.");
146:                    traceThrow(new MisconfiguredHandlerException("Class \""
147:                            + classname + "\" is needed by \""
148:                            + getClass().getName() + "\" handlers."));
149:                    // never reached
150:                    return null;
151:                }
152:            }
153:
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.