PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/Server-1.2R2/Lucene.Net/Util/Constants.cs

#
C# | 91 lines | 41 code | 14 blank | 36 comment | 5 complexity | 55ae1fe37593cf3ab718a336f21b5307 MD5 | raw file
Possible License(s): MIT
  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. using System;
  18. using LucenePackage = Lucene.Net.LucenePackage;
  19. namespace Lucene.Net.Util
  20. {
  21. /// <summary> Some useful constants.
  22. ///
  23. ///
  24. /// </summary>
  25. /// <version> $Id: Constants.java 828327 2009-10-22 06:47:40Z uschindler $
  26. ///
  27. /// </version>
  28. public sealed class Constants
  29. {
  30. private Constants()
  31. {
  32. } // can't construct
  33. /// <summary>The value of <tt>System.getProperty("java.version")</tt>. *</summary>
  34. public static readonly System.String JAVA_VERSION = SupportClass.AppSettings.Get("java.version", "");
  35. /// <summary>True iff this is Java version 1.1. </summary>
  36. public static readonly bool JAVA_1_1 = JAVA_VERSION.StartsWith("1.1.");
  37. /// <summary>True iff this is Java version 1.2. </summary>
  38. public static readonly bool JAVA_1_2 = JAVA_VERSION.StartsWith("1.2.");
  39. /// <summary>True iff this is Java version 1.3. </summary>
  40. public static readonly bool JAVA_1_3 = JAVA_VERSION.StartsWith("1.3.");
  41. /// <summary>The value of <tt>System.getProperty("os.name")</tt>. *</summary>
  42. public static readonly System.String OS_NAME = "Windows_NT";
  43. /// <summary>True iff running on Linux. </summary>
  44. public static readonly bool LINUX = OS_NAME.StartsWith("Linux");
  45. /// <summary>True iff running on Windows. </summary>
  46. public static readonly bool WINDOWS = OS_NAME.StartsWith("Windows");
  47. /// <summary>True iff running on SunOS. </summary>
  48. public static readonly bool SUN_OS = OS_NAME.StartsWith("SunOS");
  49. public static readonly System.String OS_ARCH = "X86";//System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
  50. public static readonly System.String OS_VERSION = "Microsoft Windows NT 6.1.7600.0";
  51. public static readonly System.String JAVA_VENDOR = SupportClass.AppSettings.Get("java.vendor", "");
  52. // NOTE: this logic may not be correct; if you know of a
  53. // more reliable approach please raise it on java-dev!
  54. public static bool JRE_IS_64BIT;
  55. // this method prevents inlining the final version constant in compiled
  56. // classes,
  57. // see: http://www.javaworld.com/community/node/3400
  58. private static System.String Ident(System.String s)
  59. {
  60. return s.ToString();
  61. }
  62. public static readonly System.String LUCENE_MAIN_VERSION = Ident("2.9.1");
  63. public static System.String LUCENE_VERSION;
  64. static Constants()
  65. {
  66. if (IntPtr.Size == 8)
  67. {
  68. JRE_IS_64BIT = true;// 64 bit machine
  69. }
  70. else if (IntPtr.Size == 4)
  71. {
  72. JRE_IS_64BIT = false;// 32 bit machine
  73. }
  74. LUCENE_VERSION = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
  75. }
  76. }
  77. }