PageRenderTime 24ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/lucene/src/java/org/apache/lucene/util/Constants.java

https://github.com/simplegeo/lucene-solr
Java | 86 lines | 44 code | 11 blank | 31 comment | 14 complexity | 3e0f2e765db0b5375293f224ddadd1ab MD5 | raw file
  1. package org.apache.lucene.util;
  2. /**
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. import org.apache.lucene.LucenePackage;
  19. /**
  20. * Some useful constants.
  21. **/
  22. public final class Constants {
  23. private Constants() {} // can't construct
  24. /** The value of <tt>System.getProperty("java.version")<tt>. **/
  25. public static final String JAVA_VERSION = System.getProperty("java.version");
  26. /** True iff this is Java version 1.1. */
  27. public static final boolean JAVA_1_1 = JAVA_VERSION.startsWith("1.1.");
  28. /** True iff this is Java version 1.2. */
  29. public static final boolean JAVA_1_2 = JAVA_VERSION.startsWith("1.2.");
  30. /** True iff this is Java version 1.3. */
  31. public static final boolean JAVA_1_3 = JAVA_VERSION.startsWith("1.3.");
  32. /** The value of <tt>System.getProperty("os.name")<tt>. **/
  33. public static final String OS_NAME = System.getProperty("os.name");
  34. /** True iff running on Linux. */
  35. public static final boolean LINUX = OS_NAME.startsWith("Linux");
  36. /** True iff running on Windows. */
  37. public static final boolean WINDOWS = OS_NAME.startsWith("Windows");
  38. /** True iff running on SunOS. */
  39. public static final boolean SUN_OS = OS_NAME.startsWith("SunOS");
  40. public static final String OS_ARCH = System.getProperty("os.arch");
  41. public static final String OS_VERSION = System.getProperty("os.version");
  42. public static final String JAVA_VENDOR = System.getProperty("java.vendor");
  43. // NOTE: this logic may not be correct; if you know of a
  44. // more reliable approach please raise it on java-dev!
  45. public static final boolean JRE_IS_64BIT;
  46. static {
  47. String x = System.getProperty("sun.arch.data.model");
  48. if (x != null) {
  49. JRE_IS_64BIT = x.indexOf("64") != -1;
  50. } else {
  51. if (OS_ARCH != null && OS_ARCH.indexOf("64") != -1) {
  52. JRE_IS_64BIT = true;
  53. } else {
  54. JRE_IS_64BIT = false;
  55. }
  56. }
  57. }
  58. // this method prevents inlining the final version constant in compiled classes,
  59. // see: http://www.javaworld.com/community/node/3400
  60. private static String ident(final String s) {
  61. return s.toString();
  62. }
  63. public static final String LUCENE_MAIN_VERSION = ident("4.0");
  64. public static final String LUCENE_VERSION;
  65. static {
  66. Package pkg = LucenePackage.get();
  67. String v = (pkg == null) ? null : pkg.getImplementationVersion();
  68. if (v == null) {
  69. v = LUCENE_MAIN_VERSION + "-dev";
  70. } else if (!v.startsWith(LUCENE_MAIN_VERSION)) {
  71. v = LUCENE_MAIN_VERSION + "-dev " + v;
  72. }
  73. LUCENE_VERSION = ident(v);
  74. }
  75. }