/**
 * Copyright (c) Alessandro Perucchi, 2014
 * alessandro[at]perucchi[dot]org
 * All Rights Reserved
 * Eclipse Public License (EPLv1)
 * http://oshi.codeplex.com/license
 */
package oshi.software.os.linux.proc;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

import oshi.software.os.OperatingSystemVersion;

/**
 * Contains operating system version information. The information includes major
 * and minor version numbers, a build number, a platform identifier, and
 * descriptive text about the operating system.
 *
 * @author alessandro[at]perucchi[dot]org
 */
public class OSVersionInfoEx implements OperatingSystemVersion {

	private String _version = null;
	private String _codeName = null;
	private String version = null;

	public OSVersionInfoEx() {
		Scanner in = null;
		try {
			in = new Scanner(new FileReader("/etc/os-release"));
		} catch (FileNotFoundException e) {
			return;
		}
		in.useDelimiter("\n");
		while (in.hasNext()) {
			String[] splittedLine = in.next().split("=");
			if (splittedLine[0].equals("VERSION_ID")) {
				setVersion(splittedLine[1]);
			}
			if (splittedLine[0].equals("VERSION")) {
				// Check basically if the code is between parenthesis or after
				// the coma-space

				// Basically, until now, that seems to be the standard to use
				// parenthesis for the codename.
				String[] split = splittedLine[1].split("[()]");
				if (split.length <= 1)
					// We are probably with Ubuntu, so need to get that part
					// correctly.
					split = splittedLine[1].split(", ");

				if (split.length > 1)
					setCodeName(split[1]);
				else
					setCodeName(splittedLine[1]);
			}
		}
		in.close();
	}

	/**
	 * @return the _codeName
	 */
	public String getCodeName() {
		return _codeName;
	}

	/**
	 * @return the _version
	 */
	public String getVersion() {
		return _version;
	}

	/**
	 * @param _codeName
	 *            the _codeName to set
	 */
	public void setCodeName(String _codeName) {
		this._codeName = _codeName;
	}

	/**
	 * @param _version
	 *            the _version to set
	 */
	public void setVersion(String _version) {
		this._version = _version;
	}

	@Override
	public String toString() {
		if (version == null) {
			version = getVersion() + " (" + getCodeName() + ")";
		}
		return version;
	}

}

@@ -1091,85 +1091,313 @@
 %09%09%09%09
-setVersion(splittedLine%5B1%5D);%0A%09%09%09%7D%0A%09%09%09if (splittedLine%5B0%5D.equals(%22VERSION%22)) %7B
+// remove beginning and ending '%22' characters, etc from%0A%09%09%09%09// VERSION_ID=%2214.04%22%0A%09%09%09%09setVersion(splittedLine%5B1%5D.replaceAll(%22%5E%5C%22%7C%5C%22$%22, %22%22));%0A%09%09%09%7D%0A%09%09%09if (splittedLine%5B0%5D.equals(%22VERSION%22)) %7B%0A%09%09%09%09// remove beginning and ending '%22' characters%0A%09%09%09%09splittedLine%5B1%5D = splittedLine%5B1%5D.replaceAll(%22%5E%5C%22%7C%5C%22$%22, %22%22);%0A
 %0A%09%09%09

Remove beginning and ending '"' characters on Linux /etc/os-release entries, etc from VERSION_ID="14.04"