Source Code Cross Referenced for LogContext.java in  » Graphic-Library » jcommon-components » org » jfree » 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 » Graphic Library » jcommon components » org.jfree.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ========================================================================
002:         * JCommon : a free general purpose class library for the Java(tm) platform
003:         * ========================================================================
004:         *
005:         * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006:         * 
007:         * Project Info:  http://www.jfree.org/jcommon/index.html
008:         *
009:         * This library is free software; you can redistribute it and/or modify it 
010:         * under the terms of the GNU Lesser General Public License as published by 
011:         * the Free Software Foundation; either version 2.1 of the License, or 
012:         * (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful, but 
015:         * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017:         * License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022:         * USA.  
023:         *
024:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025:         * in the United States and other countries.]
026:         * 
027:         * ---------------
028:         * LogContext.java
029:         * ---------------
030:         * (C)opyright 2004, by Thomas Morgner and Contributors.
031:         *
032:         * Original Author:  Thomas Morgner;
033:         * Contributor(s):   David Gilbert (for Object Refinery Limited);
034:         *
035:         * $Id: LogContext.java,v 1.3 2005/10/18 13:24:19 mungady Exp $
036:         *
037:         * Changes 
038:         * -------
039:         * 26-Apr-2004 : Initial version (TM);
040:         *  
041:         */
042:
043:        package org.jfree.util;
044:
045:        /**
046:         * A log context.
047:         *
048:         * @author Thomas Morgner
049:         */
050:        public class LogContext {
051:
052:            /** The prefix string. */
053:            private String contextPrefix;
054:
055:            /**
056:             * Creates a new log context.
057:             * 
058:             * @param contextPrefix  the prefix.
059:             */
060:            public LogContext(final String contextPrefix) {
061:                this .contextPrefix = contextPrefix;
062:            }
063:
064:            /**
065:             * Returns true, if the log level allows debug messages to be
066:             * printed.
067:             *
068:             * @return true, if messages with an log level of DEBUG are allowed.
069:             */
070:            public boolean isDebugEnabled() {
071:                return Log.isDebugEnabled();
072:            }
073:
074:            /**
075:             * Returns true, if the log level allows informational
076:             * messages to be printed.
077:             *
078:             * @return true, if messages with an log level of INFO are allowed.
079:             */
080:            public boolean isInfoEnabled() {
081:                return Log.isInfoEnabled();
082:            }
083:
084:            /**
085:             * Returns true, if the log level allows warning messages to be
086:             * printed.
087:             *
088:             * @return true, if messages with an log level of WARN are allowed.
089:             */
090:            public boolean isWarningEnabled() {
091:                return Log.isWarningEnabled();
092:            }
093:
094:            /**
095:             * Returns true, if the log level allows error messages to be
096:             * printed.
097:             *
098:             * @return true, if messages with an log level of ERROR are allowed.
099:             */
100:            public boolean isErrorEnabled() {
101:                return Log.isErrorEnabled();
102:            }
103:
104:            /**
105:             * A convenience method for logging a 'debug' message.
106:             *
107:             * @param message the message.
108:             */
109:            public void debug(final Object message) {
110:                log(LogTarget.DEBUG, message);
111:            }
112:
113:            /**
114:             * A convenience method for logging a 'debug' message.
115:             *
116:             * @param message the message.
117:             * @param e       the exception.
118:             */
119:            public void debug(final Object message, final Exception e) {
120:                log(LogTarget.DEBUG, message, e);
121:            }
122:
123:            /**
124:             * A convenience method for logging an 'info' message.
125:             *
126:             * @param message the message.
127:             */
128:            public void info(final Object message) {
129:                log(LogTarget.INFO, message);
130:            }
131:
132:            /**
133:             * A convenience method for logging an 'info' message.
134:             *
135:             * @param message the message.
136:             * @param e       the exception.
137:             */
138:            public void info(final Object message, final Exception e) {
139:                log(LogTarget.INFO, message, e);
140:            }
141:
142:            /**
143:             * A convenience method for logging a 'warning' message.
144:             *
145:             * @param message the message.
146:             */
147:            public void warn(final Object message) {
148:                log(LogTarget.WARN, message);
149:            }
150:
151:            /**
152:             * A convenience method for logging a 'warning' message.
153:             *
154:             * @param message the message.
155:             * @param e       the exception.
156:             */
157:            public void warn(final Object message, final Exception e) {
158:                log(LogTarget.WARN, message, e);
159:            }
160:
161:            /**
162:             * A convenience method for logging an 'error' message.
163:             *
164:             * @param message the message.
165:             */
166:            public void error(final Object message) {
167:                log(LogTarget.ERROR, message);
168:            }
169:
170:            /**
171:             * A convenience method for logging an 'error' message.
172:             *
173:             * @param message the message.
174:             * @param e       the exception.
175:             */
176:            public void error(final Object message, final Exception e) {
177:                log(LogTarget.ERROR, message, e);
178:            }
179:
180:            /**
181:             * Logs a message to the main log stream.  All attached log targets will also
182:             * receive this message. If the given log-level is higher than the given debug-level
183:             * in the main config file, no logging will be done.
184:             *
185:             * @param level   log level of the message.
186:             * @param message text to be logged.
187:             */
188:            public void log(final int level, final Object message) {
189:                if (this .contextPrefix != null) {
190:                    Log.getInstance().doLog(
191:                            level,
192:                            new Log.SimpleMessage(this .contextPrefix, ":",
193:                                    message));
194:                } else {
195:                    Log.getInstance().doLog(level, message);
196:                }
197:            }
198:
199:            /**
200:             * Logs a message to the main log stream. All attached logTargets will also
201:             * receive this message. If the given log-level is higher than the given debug-level
202:             * in the main config file, no logging will be done.
203:             * <p/>
204:             * The exception's stacktrace will be appended to the log-stream
205:             *
206:             * @param level   log level of the message.
207:             * @param message text to be logged.
208:             * @param e       the exception, which should be logged.
209:             */
210:            public void log(final int level, final Object message,
211:                    final Exception e) {
212:                if (this .contextPrefix != null) {
213:                    Log.getInstance().doLog(
214:                            level,
215:                            new Log.SimpleMessage(this .contextPrefix, ":",
216:                                    message), e);
217:                } else {
218:                    Log.getInstance().doLog(level, message, e);
219:                }
220:            }
221:
222:            /**
223:             * Tests this object for equality with an arbitrary object.
224:             * 
225:             * @param o  the object to test against (<code>null</code> permitted).
226:             * 
227:             * @return A boolean.
228:             */
229:            public boolean equals(final Object o) {
230:                if (this  == o) {
231:                    return true;
232:                }
233:                if (!(o instanceof  LogContext)) {
234:                    return false;
235:                }
236:
237:                final LogContext logContext = (LogContext) o;
238:
239:                if (this .contextPrefix != null) {
240:                    if (!this .contextPrefix.equals(logContext.contextPrefix)) {
241:                        return false;
242:                    }
243:                } else {
244:                    if (logContext.contextPrefix != null) {
245:                        return false;
246:                    }
247:                }
248:
249:                return true;
250:            }
251:
252:            /**
253:             * Returns a hashcode.
254:             * 
255:             * @return The hashcode.
256:             */
257:            public int hashCode() {
258:                return (this .contextPrefix != null ? this .contextPrefix
259:                        .hashCode() : 0);
260:            }
261:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.