Source Code Cross Referenced for Priority.java in  » Net » openfire » org » jivesoftware » 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 » Net » openfire » org.jivesoftware.util.log 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) The Apache Software Foundation. All rights reserved.
003:         *
004:         * This software is published under the terms of the Apache Software License
005:         * version 1.1, a copy of which has been included with this distribution in
006:         * the LICENSE file.
007:         */
008:        package org.jivesoftware.util.log;
009:
010:        import java.io.ObjectStreamException;
011:        import java.io.Serializable;
012:
013:        /**
014:         * Class representing and holding constants for priority.
015:         *
016:         * @author <a href="mailto:peter@apache.org">Peter Donald</a>
017:         */
018:        public final class Priority implements  Serializable {
019:
020:            /**
021:             * Developer orientated messages, usually used during development of product.
022:             */
023:            public final static Priority DEBUG = new Priority("DEBUG", 5);
024:
025:            /**
026:             * Useful information messages such as state changes, client connection, user login etc.
027:             */
028:            public final static Priority INFO = new Priority("INFO", 10);
029:
030:            /**
031:             * A problem or conflict has occurred but it may be recoverable, then
032:             * again it could be the start of the system failing.
033:             */
034:            public final static Priority WARN = new Priority("WARN", 15);
035:
036:            /**
037:             * A problem has occurred but it is not fatal. The system will still function.
038:             */
039:            public final static Priority ERROR = new Priority("ERROR", 20);
040:
041:            /**
042:             * Something caused whole system to fail. This indicates that an administrator
043:             * should restart the system and try to fix the problem that caused the failure.
044:             */
045:            public final static Priority FATAL_ERROR = new Priority(
046:                    "FATAL_ERROR", 25);
047:
048:            private final String m_name;
049:            private final int m_priority;
050:
051:            /**
052:             * Retrieve a Priority object for the name parameter.
053:             *
054:             * @param priority the priority name
055:             * @return the Priority for name
056:             */
057:            public static Priority getPriorityForName(final String priority) {
058:                if (Priority.DEBUG.getName().equals(priority))
059:                    return Priority.DEBUG;
060:                else if (Priority.INFO.getName().equals(priority))
061:                    return Priority.INFO;
062:                else if (Priority.WARN.getName().equals(priority))
063:                    return Priority.WARN;
064:                else if (Priority.ERROR.getName().equals(priority))
065:                    return Priority.ERROR;
066:                else if (Priority.FATAL_ERROR.getName().equals(priority))
067:                    return Priority.FATAL_ERROR;
068:                else
069:                    return Priority.DEBUG;
070:            }
071:
072:            /**
073:             * Private Constructor to block instantiation outside class.
074:             *
075:             * @param name     the string name of priority
076:             * @param priority the numerical code of priority
077:             */
078:            private Priority(final String name, final int priority) {
079:                m_name = name;
080:                m_priority = priority;
081:            }
082:
083:            /**
084:             * Overidden string to display Priority in human readable form.
085:             *
086:             * @return the string describing priority
087:             */
088:            public String toString() {
089:                return "Priority[" + getName() + "/" + getValue() + "]";
090:            }
091:
092:            /**
093:             * Get numerical value associated with priority.
094:             *
095:             * @return the numerical value
096:             */
097:            public int getValue() {
098:                return m_priority;
099:            }
100:
101:            /**
102:             * Get name of priority.
103:             *
104:             * @return the priorities name
105:             */
106:            public String getName() {
107:                return m_name;
108:            }
109:
110:            /**
111:             * Test whether this priority is greater than other priority.
112:             *
113:             * @param other the other Priority
114:             */
115:            public boolean isGreater(final Priority other) {
116:                return m_priority > other.getValue();
117:            }
118:
119:            /**
120:             * Test whether this priority is lower than other priority.
121:             *
122:             * @param other the other Priority
123:             */
124:            public boolean isLower(final Priority other) {
125:                return m_priority < other.getValue();
126:            }
127:
128:            /**
129:             * Test whether this priority is lower or equal to other priority.
130:             *
131:             * @param other the other Priority
132:             */
133:            public boolean isLowerOrEqual(final Priority other) {
134:                return m_priority <= other.getValue();
135:            }
136:
137:            /**
138:             * Helper method that replaces deserialized object with correct singleton.
139:             *
140:             * @return the singleton version of object
141:             * @throws ObjectStreamException if an error occurs
142:             */
143:            private Object readResolve() throws ObjectStreamException {
144:                return getPriorityForName(m_name);
145:            }
146:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.