Author: adietish
Date: 2010-09-30 11:28:51 -0400 (Thu, 30 Sep 2010)
New Revision: 25340
Removed:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/ILinuxDistro.java
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/CurrentLinuxDistro.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/LinuxDistroFake.java
Log:
[JBIDE-7208] removed unused classes
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/CurrentLinuxDistro.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/CurrentLinuxDistro.java 2010-09-30
15:16:14 UTC (rev 25339)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/CurrentLinuxDistro.java 2010-09-30
15:28:51 UTC (rev 25340)
@@ -81,7 +81,7 @@
private final String releaseFilePath;
private String name;
- private LinuxDistro(String name, String releaseFilePath) {
+ protected LinuxDistro(String name, String releaseFilePath) {
this.name = name;
this.releaseFilePath = releaseFilePath;
}
@@ -94,7 +94,7 @@
return name;
}
- private String getVersion() {
+ public String getVersion() {
try {
String distroString = getDistroFileContent(releaseFilePath);
Matcher matcher = VERSION_REGEX.matcher(distroString);
@@ -106,7 +106,7 @@
return "";
}
- private String getNameAndVersion() {
+ public String getNameAndVersion() {
return new StringBuilder().append(getName()).append(getVersion()).toString();
}
Deleted:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/ILinuxDistro.java
===================================================================
---
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/ILinuxDistro.java 2010-09-30
15:16:14 UTC (rev 25339)
+++
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/ILinuxDistro.java 2010-09-30
15:28:51 UTC (rev 25340)
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.usage.googleanalytics.eclipse;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public interface ILinuxDistro {
-
- public class CurrentDistro {
-
- public static final ILinuxDistro DEBIAN = new LinuxDistro("Debian",
"/etc/debian_version");
- public static final ILinuxDistro FEDORA = new LinuxDistro("Fedora",
"/etc/fedora-release");
- public static final ILinuxDistro GENTOO = new LinuxDistro("Gentoo",
"/etc/gentoo-release");
- public static final ILinuxDistro KNOPPIX = new LinuxDistro("Knoppix",
"knoppix_version");
- public static final ILinuxDistro MANDRAKE = new LinuxDistro("Mandrake",
"/etc/mandrake-release");
- public static final ILinuxDistro MANDRIVA = new LinuxDistro("Mandriva",
"/etc/mandriva-release");
- public static final ILinuxDistro PLD = new LinuxDistro("PLD",
"/etc/pld-release");
- public static final ILinuxDistro REDHAT = new LinuxDistro("RedHat",
"/etc/redhat-release");
- public static final ILinuxDistro SLACKWARE = new LinuxDistro("Slackware",
"/etc/slackware-version");
- public static final ILinuxDistro SUSE = new LinuxDistro("SUSE",
"/etc/SuSE-release");
- public static final ILinuxDistro UBUNTU = new LinuxDistro("Ubuntu",
"/etc/lsb-release");
- public static final ILinuxDistro YELLOWDOG = new LinuxDistro("YellowDog",
"/etc/yellowdog-release");
-
- private static final ILinuxDistro[] ALL = new ILinuxDistro[] {
- DEBIAN,
- FEDORA,
- GENTOO,
- KNOPPIX,
- MANDRAKE,
- MANDRIVA,
- PLD,
- REDHAT,
- SLACKWARE,
- SUSE,
- UBUNTU,
- YELLOWDOG
- };
-
- public ILinuxDistro getDistro() {
- for (ILinuxDistro distro : ALL) {
- if (distro.currentSysIsDistro()) {
- return distro;
- }
- }
- return null;
-
- }
-
- public String getNameAndVersion() {
- ILinuxDistro distro = getDistro();
- if (distro != null) {
- return distro.getName();
- } else {
- return "";
- }
- }
- }
-
- public boolean currentSysIsDistro();
-
- public String getName();
-
- public String getVersion();
-
- public String getNameAndVersion();
-
- public class LinuxDistro implements ILinuxDistro {
-
- /**
- * The pattern to match the contents of the release-file -
- * /etc/fedora-release etc. Attention: Ubuntu has multi-line release
- * file
- *
- * @see <a
- *
href="http://superuser.com/questions/11008/how-do-i-find-out-what-ve...
- * strings</a>
- */
- private final Pattern VERSION_REGEX = Pattern.compile("([0-9.]+)");
-
- private final String releaseFilePath;
- private String name;
-
- protected LinuxDistro(String name, String releaseFilePath) {
- this.name = name;
- this.releaseFilePath = releaseFilePath;
- }
-
- public boolean currentSysIsDistro() {
- return new File(releaseFilePath).exists();
- }
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- try {
- String distroString = getDistroFileContent(releaseFilePath);
- Matcher matcher = VERSION_REGEX.matcher(distroString);
- if (matcher.find()) {
- return matcher.group(1);
- }
- } catch (IOException e) {
- }
- return "";
- }
-
- public String getNameAndVersion() {
- return new StringBuilder().append(getName()).append(getVersion()).toString();
- }
-
- protected String getDistroFileContent(String filePath) throws IOException {
- int charachtersToRead = 1024;
- StringBuilder builder = new StringBuilder(charachtersToRead);
- BufferedReader reader = new BufferedReader(new FileReader(filePath));
- char[] buf = new char[charachtersToRead];
- int charRead = 0;
- while ((charRead = reader.read(buf)) != -1 && builder.length() <
charachtersToRead) {
- String readData = String.valueOf(buf, 0, charRead);
- builder.append(readData);
- }
- reader.close();
- return builder.toString();
- }
- }
-}
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java 2010-09-30
15:16:14 UTC (rev 25339)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java 2010-09-30
15:28:51 UTC (rev 25340)
@@ -12,7 +12,7 @@
import static org.junit.Assert.assertEquals;
import org.jboss.tools.usage.googleanalytics.eclipse.CurrentLinuxDistro;
-import org.jboss.tools.usage.googleanalytics.eclipse.ILinuxDistro;
+import org.jboss.tools.usage.googleanalytics.eclipse.CurrentLinuxDistro.LinuxDistro;
import org.jboss.tools.usage.test.fakes.LinuxDistroFake;
import org.junit.Test;
@@ -20,20 +20,20 @@
@Test
public void canExtractFedoraVersion() {
- ILinuxDistro distro = new LinuxDistroFake(CurrentLinuxDistro.FEDORA.getName(),
"Fedora release 13 (Goddard)");
+ LinuxDistro distro = new LinuxDistroFake(CurrentLinuxDistro.FEDORA.getName(),
"Fedora release 13 (Goddard)");
assertEquals("13", distro.getVersion());
}
@Test
public void canExtractUbuntuVersion() {
- ILinuxDistro distro = new LinuxDistroFake(CurrentLinuxDistro.UBUNTU.getName(),
+ LinuxDistro distro = new LinuxDistroFake(CurrentLinuxDistro.UBUNTU.getName(),
"DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=9.04\nDISTRIB_CODENAME=jaunty\nDISTRIB_DESCRIPTION=\"Ubuntu
9.04\"");
assertEquals("9.04", distro.getVersion());
}
@Test
public void canExtractREDHATVersion() {
- ILinuxDistro distro = new LinuxDistroFake(CurrentLinuxDistro.REDHAT.getName(),
+ LinuxDistro distro = new LinuxDistroFake(CurrentLinuxDistro.REDHAT.getName(),
"Red Hat Enterprise Linux Workstation release 6.0 (Santiago)");
assertEquals("6.0", distro.getVersion());
}
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/LinuxDistroFake.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/LinuxDistroFake.java 2010-09-30
15:16:14 UTC (rev 25339)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/LinuxDistroFake.java 2010-09-30
15:28:51 UTC (rev 25340)
@@ -11,7 +11,7 @@
import java.io.IOException;
-import org.jboss.tools.usage.googleanalytics.eclipse.ILinuxDistro.LinuxDistro;
+import org.jboss.tools.usage.googleanalytics.eclipse.CurrentLinuxDistro.LinuxDistro;
public class LinuxDistroFake extends LinuxDistro {