Source Code Cross Referenced for Level.java in  » Development » SLF4J » org » apache » log4j » 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 » Development » SLF4J » org.apache.log4j 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999-2005 The Apache Software Foundation.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        // Contributors:  Kitching Simon <Simon.Kitching@orange.ch>
018:        //                Nicholas Wolff
019:        package org.apache.log4j;
020:
021:        import java.io.IOException;
022:        import java.io.ObjectInputStream;
023:        import java.io.ObjectOutputStream;
024:        import java.io.ObjectStreamException;
025:        import java.io.Serializable;
026:
027:        /**
028:         Defines the minimum set of levels recognized by the system, that is
029:         <code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
030:         <code>WARN</code>, <code>INFO</code, <code>DEBUG</code> and
031:         <code>ALL</code>.
032:
033:         <p>The <code>Level</code> class may be subclassed to define a larger
034:         level set.
035:
036:         @author Ceki G&uuml;lc&uuml;
037:
038:         */
039:        public class Level extends Priority implements  Serializable {
040:
041:            /**
042:             * TRACE level integer value.
043:             * @since 1.2.12
044:             */
045:            public static final int TRACE_INT = 5000;
046:
047:            /**
048:               The <code>OFF</code> has the highest possible rank and is
049:               intended to turn off logging.  */
050:            final static public Level OFF = new Level(OFF_INT, "OFF", 0);
051:
052:            /**
053:               The <code>FATAL</code> level designates very severe error
054:               events that will presumably lead the application to abort.
055:             */
056:            final static public Level FATAL = new Level(FATAL_INT, "FATAL", 0);
057:
058:            /**
059:               The <code>ERROR</code> level designates error events that
060:               might still allow the application to continue running.  */
061:            final static public Level ERROR = new Level(ERROR_INT, "ERROR", 3);
062:
063:            /**
064:               The <code>WARN</code> level designates potentially harmful situations.
065:             */
066:            final static public Level WARN = new Level(WARN_INT, "WARN", 4);
067:
068:            /**
069:               The <code>INFO</code> level designates informational messages
070:               that highlight the progress of the application at coarse-grained
071:               level.  */
072:            final static public Level INFO = new Level(INFO_INT, "INFO", 6);
073:
074:            /**
075:               The <code>DEBUG</code> Level designates fine-grained
076:               informational events that are most useful to debug an
077:               application.  */
078:            final static public Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
079:
080:            /**
081:             * The <code>TRACE</code> Level designates finer-grained
082:             * informational events than the <code>DEBUG</code level.
083:             *  @since 1.2.12
084:             */
085:            public static final Level TRACE = new Level(TRACE_INT, "TRACE", 7);
086:
087:            /**
088:               The <code>ALL</code> has the lowest possible rank and is intended to
089:               turn on all logging.  */
090:            final static public Level ALL = new Level(ALL_INT, "ALL", 7);
091:
092:            /**
093:             * Serialization version id.
094:             */
095:            static final long serialVersionUID = 3491141966387921974L;
096:
097:            /**
098:               Instantiate a Level object.
099:             */
100:            protected Level(int level, String levelStr, int syslogEquivalent) {
101:                super (level, levelStr, syslogEquivalent);
102:            }
103:
104:            /**
105:               Convert the string passed as argument to a level. If the
106:               conversion fails, then this method returns {@link #DEBUG}. 
107:             */
108:            public static Level toLevel(String sArg) {
109:                return (Level) toLevel(sArg, Level.DEBUG);
110:            }
111:
112:            /**
113:              Convert an integer passed as argument to a level. If the
114:              conversion fails, then this method returns {@link #DEBUG}.
115:
116:             */
117:            public static Level toLevel(int val) {
118:                return (Level) toLevel(val, Level.DEBUG);
119:            }
120:
121:            /**
122:              Convert an integer passed as argument to a level. If the
123:              conversion fails, then this method returns the specified default.
124:             */
125:            public static Level toLevel(int val, Level defaultLevel) {
126:                switch (val) {
127:                case ALL_INT:
128:                    return ALL;
129:                case DEBUG_INT:
130:                    return Level.DEBUG;
131:                case INFO_INT:
132:                    return Level.INFO;
133:                case WARN_INT:
134:                    return Level.WARN;
135:                case ERROR_INT:
136:                    return Level.ERROR;
137:                case FATAL_INT:
138:                    return Level.FATAL;
139:                case OFF_INT:
140:                    return OFF;
141:                case TRACE_INT:
142:                    return Level.TRACE;
143:                default:
144:                    return defaultLevel;
145:                }
146:            }
147:
148:            /**
149:               Convert the string passed as argument to a level. If the
150:               conversion fails, then this method returns the value of
151:               <code>defaultLevel</code>.  
152:             */
153:            public static Level toLevel(String sArg, Level defaultLevel) {
154:                if (sArg == null)
155:                    return defaultLevel;
156:
157:                String s = sArg.toUpperCase();
158:
159:                if (s.equals("ALL"))
160:                    return Level.ALL;
161:                if (s.equals("DEBUG"))
162:                    return Level.DEBUG;
163:                if (s.equals("INFO"))
164:                    return Level.INFO;
165:                if (s.equals("WARN"))
166:                    return Level.WARN;
167:                if (s.equals("ERROR"))
168:                    return Level.ERROR;
169:                if (s.equals("FATAL"))
170:                    return Level.FATAL;
171:                if (s.equals("OFF"))
172:                    return Level.OFF;
173:                if (s.equals("TRACE"))
174:                    return Level.TRACE;
175:                return defaultLevel;
176:            }
177:
178:            /**
179:             * Custom deserialization of Level.
180:             * @param s serialization stream.
181:             * @throws IOException if IO exception.
182:             * @throws ClassNotFoundException if class not found.
183:             */
184:            private void readObject(final ObjectInputStream s)
185:                    throws IOException, ClassNotFoundException {
186:                s.defaultReadObject();
187:                level = s.readInt();
188:                syslogEquivalent = s.readInt();
189:                levelStr = s.readUTF();
190:                if (levelStr == null) {
191:                    levelStr = "";
192:                }
193:            }
194:
195:            /**
196:             * Serialize level.
197:             * @param s serialization stream.
198:             * @throws IOException if exception during serialization.
199:             */
200:            private void writeObject(final ObjectOutputStream s)
201:                    throws IOException {
202:                s.defaultWriteObject();
203:                s.writeInt(level);
204:                s.writeInt(syslogEquivalent);
205:                s.writeUTF(levelStr);
206:            }
207:
208:            /**
209:             * Resolved deserialized level to one of the stock instances.
210:             * May be overriden in classes derived from Level.
211:             * @return resolved object.
212:             * @throws ObjectStreamException if exception during resolution.
213:             */
214:            private Object readResolve() throws ObjectStreamException {
215:                //
216:                //  if the deserizalized object is exactly an instance of Level
217:                //
218:                if (getClass() == Level.class) {
219:                    return toLevel(level);
220:                }
221:                //
222:                //   extension of Level can't substitute stock item
223:                //
224:                return this;
225:            }
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.