1 package org.apache.lucene.util;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import org.apache.lucene.LucenePackage;
23 * Some useful constants.
26 public final class Constants {
27 private Constants() {} // can't construct
29 /** The value of <tt>System.getProperty("java.version")<tt>. **/
30 public static final String JAVA_VERSION = System.getProperty("java.version");
31 /** True iff this is Java version 1.1. */
32 public static final boolean JAVA_1_1 = JAVA_VERSION.startsWith("1.1.");
33 /** True iff this is Java version 1.2. */
34 public static final boolean JAVA_1_2 = JAVA_VERSION.startsWith("1.2.");
35 /** True iff this is Java version 1.3. */
36 public static final boolean JAVA_1_3 = JAVA_VERSION.startsWith("1.3.");
38 /** The value of <tt>System.getProperty("os.name")<tt>. **/
39 public static final String OS_NAME = System.getProperty("os.name");
40 /** True iff running on Linux. */
41 public static final boolean LINUX = OS_NAME.startsWith("Linux");
42 /** True iff running on Windows. */
43 public static final boolean WINDOWS = OS_NAME.startsWith("Windows");
44 /** True iff running on SunOS. */
45 public static final boolean SUN_OS = OS_NAME.startsWith("SunOS");
46 /** True iff running on Mac OS X */
47 public static final boolean MAC_OS_X = OS_NAME.startsWith("Mac OS X");
49 public static final String OS_ARCH = System.getProperty("os.arch");
50 public static final String OS_VERSION = System.getProperty("os.version");
51 public static final String JAVA_VENDOR = System.getProperty("java.vendor");
53 // NOTE: this logic may not be correct; if you know of a
54 // more reliable approach please raise it on java-dev!
55 public static final boolean JRE_IS_64BIT;
57 String x = System.getProperty("sun.arch.data.model");
59 JRE_IS_64BIT = x.indexOf("64") != -1;
61 if (OS_ARCH != null && OS_ARCH.indexOf("64") != -1) {
69 // this method prevents inlining the final version constant in compiled classes,
70 // see: http://www.javaworld.com/community/node/3400
71 private static String ident(final String s) {
75 // NOTE: we track per-segment version as a String with the "X.Y" format, e.g.
76 // "4.0", "3.1", "3.0". Therefore when we change this constant, we should keep
78 public static final String LUCENE_MAIN_VERSION = ident("3.4");
80 public static final String LUCENE_VERSION;
82 Package pkg = LucenePackage.get();
83 String v = (pkg == null) ? null : pkg.getImplementationVersion();
85 v = LUCENE_MAIN_VERSION + "-SNAPSHOT";
86 } else if (!v.startsWith(LUCENE_MAIN_VERSION)) {
87 v = LUCENE_MAIN_VERSION + "-SNAPSHOT " + v;
89 LUCENE_VERSION = ident(v);