]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.procore.server.environment/src/org/simantics/db/procore/server/environment/ExecutionEnvironment.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db.procore.server.environment / src / org / simantics / db / procore / server / environment / ExecutionEnvironment.java
1 /*******************************************************************************\r
2  * Copyright (c) 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.db.procore.server.environment;\r
13 \r
14 \r
15 /**\r
16  * @author Tuukka Lehtonen\r
17  */\r
18 public final class ExecutionEnvironment {\r
19 \r
20     public final OSType os;\r
21     public final ARCHType arch;\r
22 \r
23     private ExecutionEnvironment(OSType os, ARCHType arch) {\r
24         this.os = os;\r
25         this.arch = arch;\r
26     }\r
27 \r
28     public static ExecutionEnvironment calculate() {\r
29         return new ExecutionEnvironment(calculateOS(), calculateArch());\r
30     }\r
31 \r
32     public static ARCHType calculateArch() {\r
33         String osArch = System.getProperty("os.arch", "");\r
34         osArch = osArch.toLowerCase();\r
35         if (osArch.equals("i386") || osArch.equals("i586") || osArch.equals("i686") || osArch.equals("x86"))\r
36             return ARCHType.X86;\r
37         if (osArch.startsWith("amd64") || osArch.startsWith("x86_64"))\r
38             return ARCHType.X86_64;\r
39         if (osArch.equals("ppc"))\r
40             return ARCHType.PPC;\r
41         if (osArch.startsWith("ppc"))\r
42             return ARCHType.PPC_64;\r
43         if (osArch.startsWith("sparc"))\r
44             return ARCHType.SPARC;\r
45         return ARCHType.UNKNOWN;\r
46     }\r
47 \r
48     public static OSType calculateOS() {\r
49         String osName = System.getProperty("os.name", "");\r
50         osName = osName.toLowerCase();\r
51         if (osName.startsWith("mac os x"))\r
52             return OSType.APPLE;\r
53         if (osName.startsWith("windows"))\r
54             return OSType.WINDOWS;\r
55         if (osName.startsWith("linux"))\r
56             return OSType.LINUX;\r
57         if (osName.startsWith("sun"))\r
58             return OSType.SUN;\r
59         return OSType.UNKNOWN;\r
60     }\r
61 \r
62 }\r