JAL-3949 An attempt at converting to Log4j 2 -- no output achieved!
[jalview.git] / src / jalview / javascript / log4j / Priority.java
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 // Contributors:  Kitching Simon <Simon.Kitching@orange.ch>
19
20 package jalview.javascript.log4j;
21
22 /**
23    <font color="#AA4444">Refrain from using this class directly, use
24    the {@link Level} class instead</font>.
25
26    @author Ceki G&uuml;lc&uuml; */
27 public class Priority {
28
29   transient int level;
30   transient String levelStr;
31   transient int syslogEquivalent;
32
33   public final static int OFF_INT = Integer.MAX_VALUE;
34   public final static int FATAL_INT = 50000;
35   public final static int ERROR_INT = 40000;
36   public final static int WARN_INT  = 30000;
37   public final static int INFO_INT  = 20000;
38   public final static int DEBUG_INT = 10000;
39     //public final static int FINE_INT = DEBUG_INT;
40   public final static int ALL_INT = Integer.MIN_VALUE;
41
42   // too twisted for J2S -- Level class initializer initializes Priority, which
43   // creates a
44   // new Level before Priority is indicated to be a superclass of Level.
45   /**
46    * @deprecated Use {@link Level#FATAL} instead.
47    */
48   @Deprecated
49   final static public Priority FATAL = null;// new Level(FATAL_INT, "FATAL", 0);
50
51   /**
52    * @deprecated Use {@link Level#ERROR} instead.
53    */
54   @Deprecated
55   final static public Priority ERROR = null;// new Level(ERROR_INT, "ERROR", 3);
56
57   /**
58    * @deprecated Use {@link Level#WARN} instead.
59    */
60   @Deprecated
61   final static public Priority WARN = null;// new Level(WARN_INT, "WARN", 4);
62
63   /**
64    * @deprecated Use {@link Level#INFO} instead.
65    */
66   @Deprecated
67   final static public Priority INFO = null;// new Level(INFO_INT, "INFO", 6);
68
69   /**
70    * @deprecated Use {@link Level#DEBUG} instead.
71    */
72   @Deprecated
73   final static public Priority DEBUG = null;// new Level(DEBUG_INT, "DEBUG", 7);
74
75   /**
76     * Default constructor for deserialization.
77     */
78   protected Priority() {
79       level = DEBUG_INT;
80       levelStr = "DEBUG";
81       syslogEquivalent = 7;
82   }
83
84   /**
85      Instantiate a level object.
86    */
87   protected
88   Priority(int level, String levelStr, int syslogEquivalent) {
89     this.level = level;
90     this.levelStr = levelStr;
91     this.syslogEquivalent = syslogEquivalent;
92   }
93
94   /**
95      Two priorities are equal if their level fields are equal.
96      @since 1.2
97    */
98   @Override
99   public
100   boolean equals(Object o) {
101     if(o instanceof Priority) {
102       Priority r = (Priority) o;
103       return (this.level == r.level);
104     } else {
105       return false;
106     }
107   }
108
109   /**
110      Return the syslog equivalent of this priority as an integer.
111    */
112   public
113   final
114   int getSyslogEquivalent() {
115     return syslogEquivalent;
116   }
117
118
119    
120   /**
121      Returns <code>true</code> if this level has a higher or equal
122      level than the level passed as argument, <code>false</code>
123      otherwise.  
124      
125      <p>You should think twice before overriding the default
126      implementation of <code>isGreaterOrEqual</code> method.
127
128   */
129   public
130   boolean isGreaterOrEqual(Priority r) {
131     return level >= r.level;
132   }
133
134   // /**
135   // Return all possible priorities as an array of Level objects in
136   // descending order.
137   //
138   // @deprecated This method will be removed with no replacement.
139   // */
140   // public
141   // static
142   // Priority[] getAllPossiblePriorities() {
143   // return new Priority[] {Priority.FATAL, Priority.ERROR, Level.WARN,
144   // Priority.INFO, Priority.DEBUG};
145   // }
146
147
148   /**
149      Returns the string representation of this priority.
150    */
151   @Override
152   final
153   public
154   String toString() {
155     return levelStr;
156   }
157
158   /**
159      Returns the integer representation of this level.
160    */
161   public
162   final
163   int toInt() {
164     return level;
165   }
166
167   // /**
168   // * @deprecated Please use the {@link Level#toLevel(String)} method instead.
169   // */
170   // public
171   // static
172   // Priority toPriority(String sArg) {
173   // return Level.toLevel(sArg);
174   // }
175
176   // /**
177   // * @deprecated Please use the {@link Level#toLevel(int)} method instead.
178   // */
179   // public
180   // static
181   // Priority toPriority(int val) {
182   // return toPriority(val, Priority.DEBUG);
183   // }
184
185   // /**
186   // * @deprecated Please use the {@link Level#toLevel(int, Level)} method
187   // instead.
188   // */
189   // public
190   // static
191   // Priority toPriority(int val, Priority defaultPriority) {
192   // return Level.toLevel(val, (Level) defaultPriority);
193   // }
194   //
195   // /**
196   // * @deprecated Please use the {@link Level#toLevel(String, Level)} method
197   // instead.
198   // */
199   // public
200   // static
201   // Priority toPriority(String sArg, Priority defaultPriority) {
202   // return Level.toLevel(sArg, (Level) defaultPriority);
203   // }
204 }