package org.to2mbn.jmccc.util;

import java.nio.charset.Charset;

public enum Platform {
	WINDOWS, LINUX, OSX, UNKNOWN;

	/**
	 * Returns the file separator of current platform.
	 * <p>
	 * This method refers to <code>System.getProperty("file.separator")</code>
	 * 
	 * @return the file separator of current platform
	 */
	public static String getFileSpearator() {
		return System.getProperty("file.separator");
	}

	/**
	 * Returns the path separator of current platform.
	 * <p>
	 * This method refers to <code>System.getProperty("path.separator")</code>
	 * 
	 * @return the path separator of current platform
	 */
	public static String getPathSpearator() {
		return System.getProperty("path.separator");
	}

	/**
	 * Returns the line separator of current platform.
	 * <p>
	 * This method refers to <code>System.lineSeparator()</code>
	 * 
	 * @return the line separator of current platform
	 */
	public static String getLineSpearator() {
		return System.lineSeparator();
	}

	/**
	 * Returns the default encoding of current platform.
	 * <p>
	 * This method refers to <code>System.getProperty("sun.jnu.encoding")</code>. If this property does not exist, the
	 * method will return <code>Charset.defaultCharset()</code>.
	 * 
	 * @return the default encoding of current platform
	 */
	public static String getEncoding() {
		return System.getProperty("sun.jnu.encoding", Charset.defaultCharset().name());
	}

	/**
	 * Returns true if current platform supports x64.
	 * <p>
	 * This method checks <code>sun.arch.data.model</code> property first.
	 * If the property does not exist, this method will check <code>os.arch</code>.
	 * 
	 * @return true if current platform supports x64
	 */
	public static boolean isX64() {
		String sunArchDataModel = System.getProperty("sun.arch.data.model");
		if (sunArchDataModel != null) {
			return "64".equals(sunArchDataModel);
		}
		return System.getProperty("os.arch").contains("64");
	}

	/**
	 * The current platform, {@link Platform#UNKNOWN} if the current platform cannot be identified.
	 */
	public static final Platform CURRENT = getCurrent();

	private static Platform getCurrent() {
		String osName = System.getProperty("os.name");

		if (osName.equals("Linux")) {
			return LINUX;
		} else if (osName.startsWith("Windows")) {
			return WINDOWS;
		} else if (osName.equals("Mac OS X")) {
			return OSX;
		} else {
			return Platform.UNKNOWN;
		}
	}

}

@@ -2174,16 +2174,30 @@
 s.name%22)
+.toLowerCase()
 ;%0A%0A%09%09if 
@@ -2208,20 +2208,49 @@
 ame.
-equals(%22Linu
+contains(%22linux%22) %7C%7C osName.contains(%22uni
 x%22))
@@ -2293,27 +2293,74 @@
 ame.
-startsWith(%22Windows
+contains(%22osx%22) %7C%7C osName.contains(%22os x%22) %7C%7C osName.contains(%22mac
 %22)) 
@@ -2371,23 +2371,19 @@
 %09return 
-WINDOWS
+OSX
 ;%0A%09%09%7D el
@@ -2400,24 +2400,25 @@
 ame.
-equals(%22Mac OS X
+contains(%22windows
 %22)) 
@@ -2421,35 +2421,39 @@
 %22)) %7B%0A%09%09%09return 
-OSX
+WINDOWS
 ;%0A%09%09%7D else %7B%0A%09%09%09
@@ -2463,17 +2463,8 @@
 urn 
-Platform.
 UNKN

update Platform.getCurrent()