com.ats.tools.OperatingSystem Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ats-automated-testing Show documentation
Show all versions of ats-automated-testing Show documentation
Code generator library to create and execute GUI automated tests
The newest version!
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package com.ats.tools;
import java.util.Base64;
public class OperatingSystem {
private static String OS = System.getProperty("os.name").toUpperCase();
private static final String WINDOWS = "WINDOWS";
private static final String LINUX = "LINUX";
private static final String MACOS = "MACOS";
private static final String MICROSOFT = "MICROSOFT";
private static final String WINDOWS_ICON = "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QArgDOAOl0s3seAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH5wUdCB4FBz4bQAAAAzJJREFUSMetlcuLXEUUxn9Vt+7tx8y03T3PTEZHiQMiuhECbhVXEVf+Df4D7iWLbAVBEFy6ceE+OyUEXIkQER1Ek7iI42RemaSn0337UXWOi3u7b/dMJiahD9w+XYe69dX3fafqmk++DixsHF0eern6eKDvSdBqEMUrBFG8jLIShKlc/Bd8yGto21l+gHDtj5NLv5hPr+9fPumG69uHg5WuF4JAUM1ztrjkeXLsx/VivmhWiy2sVc1ubORDO/RydftwsNILyqxiKHC/o+t94TP7eKDvd72M0RXQPI9/x2MmqsXIAvUIXnYGk1e9Qur1A4doJUjxoqgWIPkzGWslw+tzEVu1iMVaxGuLCZuLCfPzjqEIH311h39sBYAg1FymbbFTZ2DOGl4qwau1iHdWS7zSjPltt8OVtxusL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FaAPNFU21IhLTawJRiGcQQuPceR4wjpLTcQSkt0WjMDyrrQ9Nvsr21uqnvducHWA+J1CNaCZMRu3tcenCLc2eWpmhp5Ak4l4zpByB4T0rQsIKxl0u4opy4t0+zWkXSmJDMjCjApUUPNJKoIYlCB3FaWKPhOh2OlGsjFfYdjHO+fz5GU3mwbDaH+/R2+13mKguFE83Q7CFCUzQsTJxakWGhV5cFNrduMTdXwWTUa2XS0hEgFoBYIZ5ieBWlCUgVNCI0y106YVFDmI6e5qWVLQh7oMAX51q8/Nx5glyRBiREooHkhrUJHB7IlIstE9pep/vbKgRhGVhmOCWk9RMkzZMkzVN0fQnhIGoA25XVb9j4ax1JSJYbkFo08MPZnFQW8X+v0dm9zNz5ixgJkivyzNHu9eKgnz7bZ+Wry/R6PRaPn8gRUBxA5Po0NZ9njE+pP/UuLqnQ+vIDujd+gk4bw2FmGI47XcdOe5NrP17low/fZ+nUEq+8/gZypZzAVswnDHtz+R9d3apPbyQz1Guzd+ManT9+ILbWoH4cp8DJ/ZtcfP4Jnn72Ao889iTlSqNo94SX4EkJhvli9E5owKxJ7f4XqZ19AcUIvgsyLqR/8vF7D9HLIhIExQMWp3IlM1g4NrJTNSYsIwGrgsHNbQhexDiynA7SgYXRfTCkl81YhyqcrXcr7Ox2mKuU4cBvhbzZzmQ5HT05mwIQIYacDIrFWTF1zYtdGtzavj1z/g9N4BLSxpFseSmN74TBIpxe5ZMAxFrKxsYmi8eqh+7kRGH5P4VsGEj0B5i1AAAAAElFTkSuQmCC";
public static String getType(String value) {
final String os = value.toUpperCase();
if(os.contains(WINDOWS) || os.contains(MICROSOFT) ) {
return WINDOWS;
}else if(os.contains(LINUX)) {
return LINUX;
}else if(os.contains(MACOS)) {
return MACOS;
}
return "";
}
public static byte[] getIcon(String value) {
switch(value) {
case WINDOWS:
return Base64.getDecoder().decode(WINDOWS_ICON);
case LINUX:
return Base64.getDecoder().decode(LINUX_ICON);
case MACOS:
return Base64.getDecoder().decode(MACOS_ICON);
default:
return Utils.getWhitePixel();
}
}
public static boolean isLinux(String value) {
return value != null && value.toUpperCase().contains(LINUX);
}
public static boolean isLinux() {
return isUnix();
}
public static boolean isWindows() {
return OS.contains("WIN");
}
public static boolean isMac() {
return OS.contains("MAC");
}
public static boolean isUnix() {
return (OS.contains("NIX") || OS.contains("NUX") || OS.contains("AIX"));
}
public static boolean isSolaris() {
return OS.contains("SUNOS");
}
public static String getOS(){
if (isWindows()) {
return "win";
} else if (isMac()) {
return "osx";
} else if (isUnix()) {
return "uni";
} else if (isSolaris()) {
return "sol";
} else {
return "err";
}
}
public static String getOSName(){
if (isWindows()) {
return "windows";
} else if (isMac()) {
return "macos";
} else if (isUnix()) {
return "linux";
} else if (isSolaris()) {
return "solaris";
} else {
return "err";
}
}
public static String getArchiveExtension(){
if (isWindows()) {
return "zip";
} else {
return "tgz";
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy