01: package org.jacorb.idl;
02:
03: /*
04: * JacORB - a free Java ORB
05: *
06: * Copyright (C) 1997-2004 Gerald Brose.
07: *
08: * This library is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU Library General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.
12: *
13: * This library is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * Library General Public License for more details.
17: *
18: * You should have received a copy of the GNU Library General Public
19: * License along with this library; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: */
22:
23: public final class Environment {
24: /**
25: * <code>JAVA14</code> denotes whether we are using JDK 1.4 or above.
26: */
27: static boolean JAVA14 = false;
28:
29: /**
30: * <code>JAVA15</code> denotes whether we are using JDK 1.5 or above.
31: */
32: static boolean JAVA15 = false;
33:
34: static {
35: String javaVer = System.getProperty("java.version");
36: int javaVersionAsInt = 0;
37: try {
38: javaVersionAsInt = Integer.parseInt("" + javaVer.charAt(0))
39: * 10 + Integer.parseInt("" + javaVer.charAt(2));
40: } catch (Exception javaVersionFormatChanged) {
41: // I don't think this exception can/would ever occur but for
42: // the sake of robustness...
43: javaVersionFormatChanged.printStackTrace();
44: }
45: JAVA14 = javaVersionAsInt >= 14;
46: JAVA15 = javaVersionAsInt >= 15;
47: }
48:
49: /**
50: * <code>intToPriority</code> returns the priority level for a given integer.
51: * It is a copy of the method in util/LogKitLoggerFactory copied to ensure
52: * that the idl compiler can be standalone.
53: *
54: * @param priority an <code>int</code> value
55: * @return an <code>org.apache.log.Priority</code> value
56: */
57: public static org.apache.log.Priority intToPriority(int priority) {
58: switch (priority) {
59: case 4:
60: return org.apache.log.Priority.DEBUG;
61: case 3:
62: return org.apache.log.Priority.INFO;
63: case 2:
64: return org.apache.log.Priority.WARN;
65: case 1:
66: return org.apache.log.Priority.ERROR;
67: case 0:
68: default:
69: return org.apache.log.Priority.FATAL_ERROR;
70: }
71: }
72: }
|