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

/projects/netbeans-7.3/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/debugger/remote/Platform.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 168 lines | 74 code | 17 blank | 77 comment | 20 complexity | 08211c43f65eec3717b9af8afcea72d3 MD5 | raw file
  1. /*
  2. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  3. *
  4. * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
  5. *
  6. * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
  7. * Other names may be trademarks of their respective owners.
  8. *
  9. * The contents of this file are subject to the terms of either the GNU
  10. * General Public License Version 2 only ("GPL") or the Common
  11. * Development and Distribution License("CDDL") (collectively, the
  12. * "License"). You may not use this file except in compliance with the
  13. * License. You can obtain a copy of the License at
  14. * http://www.netbeans.org/cddl-gplv2.html
  15. * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
  16. * specific language governing permissions and limitations under the
  17. * License. When distributing the software, include this License Header
  18. * Notice in each file and include the License file at
  19. * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
  20. * particular file as subject to the "Classpath" exception as provided
  21. * by Oracle in the GPL Version 2 section of the License file that
  22. * accompanied this code. If applicable, add the following below the
  23. * License Header, with the fields enclosed by brackets [] replaced by
  24. * your own identifying information:
  25. * "Portions Copyrighted [year] [name of copyright owner]"
  26. *
  27. * Contributor(s):
  28. *
  29. * The Original Software is NetBeans. The Initial Developer of the Original
  30. * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
  31. * Microsystems, Inc. All Rights Reserved.
  32. *
  33. * If you wish your version of this file to be governed by only the CDDL
  34. * or only the GPL Version 2, indicate your decision by adding
  35. * "[Contributor] elects to include this software in this distribution
  36. * under the [CDDL or GPL Version 2] license." If you do not indicate a
  37. * single choice of license, a recipient has the option to distribute
  38. * your version of this file under either the CDDL, the GPL Version 2 or
  39. * to extend the choice of license to its licensees as provided above.
  40. * However, if you add GPL Version 2 code and therefore, elected the GPL
  41. * Version 2 license, then the option applies only if the new code is
  42. * made subject to such option by the copyright holder.
  43. */
  44. package org.netbeans.modules.cnd.debugger.common2.debugger.remote;
  45. public enum Platform {
  46. // name() variant() variant64 isLinux isSolaris
  47. Linux_x86 ("intel-Linux", "amd64-Linux", true, false), // NOI18N
  48. Solaris_x86 ("intel-S2", "amd64-S2", false, true ), // NOI18N
  49. Solaris_Sparc ("sparc-S2", "sparcv9-S2", false, true ), // NOI18N
  50. MacOSX_x86 ("intel-MacOSX","", false, false), // NOI18N
  51. Windows_x86 ("intel-Windows","", false, false), // NOI18N
  52. Unknown ("", "", false, false); // NOI18N
  53. private String variant;
  54. private String variant64;
  55. private boolean isLinux;
  56. private boolean isSolaris;
  57. private Platform (String variant, String variant64,
  58. boolean isLinux, boolean isSolaris) {
  59. this.variant = variant;
  60. this.variant64 = variant64;
  61. this.isLinux = isLinux;
  62. this.isSolaris = isSolaris;
  63. }
  64. public static Platform byName(String name) {
  65. if (name == null)
  66. return Unknown;
  67. try {
  68. return valueOf(Platform.class, name);
  69. } catch (IllegalArgumentException x) {
  70. return Unknown;
  71. }
  72. }
  73. /*8
  74. * Return the Platform corresponding to the machine we're running on
  75. */
  76. public static Platform local() {
  77. String os_name = System.getProperty("os.name", ""); // NOI18N
  78. String os_arch = System.getProperty("os.arch", ""); // NOI18N
  79. String platform_arch = "";
  80. if (os_arch.equals("sparc")) // NOI18N
  81. platform_arch = "Sparc"; // NOI18N
  82. else if (os_arch.equals("sparcv9")) // NOI18N
  83. platform_arch = "Sparc"; // NOI18N
  84. else if (os_arch.equals("x86")) // NOI18N
  85. platform_arch = "x86"; // NOI18N
  86. else if (os_arch.equals("i386")) // NOI18N
  87. platform_arch = "x86"; // NOI18N
  88. else if (os_arch.equals("x86_64")) // NOI18N
  89. platform_arch = "x86"; // NOI18N
  90. else if (os_arch.equals("amd64")) // NOI18N
  91. platform_arch = "x86"; // NOI18N
  92. else
  93. assert false :
  94. String.format("Unrecognized os.arch '%s'", os_arch);// NOI18N
  95. String platform_os = "";
  96. if (os_name.equals("SunOS")) // NOI18N
  97. platform_os="Solaris"; // NOI18N
  98. else if (os_name.equals("Linux")) // NOI18N
  99. platform_os="Linux"; // NOI18N
  100. else if (os_name.equals("Mac OS X")) // NOI18N
  101. platform_os="MacOSX"; // NOI18N
  102. else if (os_name.startsWith("Windows")) // NOI18N
  103. platform_os="Windows"; // NOI18N
  104. else
  105. assert false :
  106. String.format("Unrecognized os.name '%s'", os_name);// NOI18N
  107. return Platform.byName(platform_os + "_" + platform_arch); // NOI18N
  108. }
  109. /*
  110. * only apply to local
  111. */
  112. // public boolean is64() {
  113. // String uname = null;
  114. // try {
  115. // Runtime rt = Runtime.getRuntime();
  116. // String[] args = new String[2];
  117. // args[0] = "/bin/uname"; // NOI18N
  118. // args[1] = "-m"; // NOI18N
  119. //
  120. // Process proc = rt.exec(args);
  121. // InputStream procIn = proc.getInputStream();
  122. // BufferedReader br = new BufferedReader(new InputStreamReader(procIn));
  123. // uname = br.readLine();
  124. // br.close();
  125. // } catch (Exception e) {
  126. // ErrorManager.getDefault().annotate(e, "Failed to /bin/uname -m "); // NOI18N
  127. // ErrorManager.getDefault().notify(e);
  128. // return false;
  129. // }
  130. // if (uname == null)
  131. // return false;
  132. //
  133. // int found = uname.indexOf("64"); // NOI18N
  134. // if (found == -1)
  135. // return false;
  136. // else
  137. // return true;
  138. // }
  139. public boolean isSolaris() {
  140. return isSolaris;
  141. }
  142. public boolean isLinux() {
  143. return isLinux;
  144. }
  145. public String variant() {
  146. return variant;
  147. }
  148. public String variant64() {
  149. return variant64;
  150. }
  151. }