| package org.eclipse.epp.installer.internal.core.eclipse; |
| |
| import java.io.IOException; |
| import java.io.InputStream; |
| import java.io.InputStreamReader; |
| import java.io.LineNumberReader; |
| import java.util.HashMap; |
| import java.util.Map; |
| |
| import org.eclipse.epp.installer.core.eclipse.EclipseVersion; |
| |
| |
| public class EclipseUtils { |
| |
| /** |
| * A mapping from build identifer to the text describing the 3.0 version |
| * (e.g. "200312182000" ==> "M6") |
| * @see #getMilestone(String) |
| */ |
| private static Map buildIdMap; |
| |
| private EclipseUtils() { |
| super(); |
| } |
| |
| /** |
| * Determine the milestone from the build identifier |
| * @param buildId the build identifier |
| * @return the milestone or the build identifier if the milestone cannot be determined |
| */ |
| public static String getMilestone(String buildId) { |
| if (buildId == null) |
| return null; |
| if (buildIdMap == null) { |
| buildIdMap = new HashMap(); |
| |
| // Eclipse 3.0 Milestones |
| buildIdMap.put("200312182000", "M6"); |
| buildIdMap.put("200402122000", "M7"); |
| buildIdMap.put("200403261517", "M8"); |
| buildIdMap.put("200405211200", "M9"); |
| buildIdMap.put("200405290105", "RC1"); |
| buildIdMap.put("200406111814", "RC2"); |
| buildIdMap.put("200406192000", "RC3"); |
| |
| // Eclipse 3.0 GA |
| buildIdMap.put("200406251208", ""); |
| |
| // Eclipse 3.0.1 GA |
| buildIdMap.put("200409161125", ""); |
| |
| // Eclipse 3.0.2 GA |
| buildIdMap.put("200503110845", ""); |
| |
| // Eclipse 3.1 Milestones |
| buildIdMap.put("200408122000", "M1"); // M1 |
| buildIdMap.put("200409240800", "M2"); // M2 |
| buildIdMap.put("200411050810", "M3"); // M3 |
| buildIdMap.put("200412162000", "M4"); // M4 |
| buildIdMap.put("I20050218-1600", "M5"); // M5 |
| buildIdMap.put("200502181600", "M5"); // M5 |
| buildIdMap.put("I20050219-1500", "M5"); // M5a |
| buildIdMap.put("200502191500", "M5"); // M5a |
| buildIdMap.put("I20050401-1645", "M6"); // M6 |
| buildIdMap.put("200504011645", "M6"); // M6 |
| buildIdMap.put("I20050513-1415", ""); // M7 |
| buildIdMap.put("200505131415", ""); // M7 |
| buildIdMap.put("I20050527-1300", ""); // RC1 |
| buildIdMap.put("200505271300", ""); // RC1 |
| buildIdMap.put("I20050610-1757", ""); // RC2 |
| buildIdMap.put("200506101757", ""); // RC2 |
| buildIdMap.put("I20050617-1618", ""); // RC3 |
| buildIdMap.put("200506171618", ""); // RC3 |
| buildIdMap.put("I20050624-1300", ""); // RC4 |
| buildIdMap.put("200506241300", ""); // RC4 |
| |
| // Eclipse 3.1 GA |
| buildIdMap.put("I20050627-1435", ""); // 3.1 |
| buildIdMap.put("200506271435", ""); // 3.1 |
| |
| // Eclipse 3.1.1 GA |
| buildIdMap.put("M20050929-0840", ""); // 3.1.1 |
| buildIdMap.put("200509290840", ""); // 3.1.1 |
| |
| // Eclipse 3.2 Milestones |
| buildIdMap.put("I20050811-1530", ""); // M1 |
| buildIdMap.put("200508111530", ""); // M1 |
| buildIdMap.put("I20050923-1000", ""); // M2 |
| buildIdMap.put("200509231000", ""); // M2 |
| buildIdMap.put("I20051102-1600", ""); // M3 |
| buildIdMap.put("200511021600", ""); // M3 |
| buildIdMap.put("I20051215-1506", ""); // M4 |
| buildIdMap.put("200512151506", ""); // M4 |
| } |
| String milestone = (String) buildIdMap.get(buildId); |
| if (milestone == null) |
| return buildId; |
| if (milestone.length() == 0) |
| return null; |
| return milestone; |
| } |
| |
| /** |
| * Read the build identifier from the specified stream. |
| * @param stream the stream containing the build identifier |
| * @return the build identifier or "???" if it cannot be determined (not <code>null</code>) |
| */ |
| public static String readBuildId(InputStream stream) throws IOException { |
| LineNumberReader reader = new LineNumberReader(new InputStreamReader(stream)); |
| while (true) { |
| String line = reader.readLine(); |
| if (line == null) |
| return EclipseVersion.UNKNOWN_VERSION_TEXT; |
| if (line.startsWith("0=")) |
| return line.substring(2).trim(); |
| } |
| } |
| |
| } |