1 11 package org.eclipse.core.internal.boot; 12 13 import java.io.IOException ; 14 import java.net.URL ; 15 import org.eclipse.core.internal.runtime.CommonMessages; 16 import org.eclipse.osgi.util.NLS; 17 18 22 public class PlatformURLBaseConnection extends PlatformURLConnection { 23 24 public static final String PLATFORM = "base"; public static final String PLATFORM_URL_STRING = PlatformURLHandler.PROTOCOL + PlatformURLHandler.PROTOCOL_SEPARATOR + "/" + PLATFORM + "/"; 28 private static URL installURL; 29 30 33 public PlatformURLBaseConnection(URL url) { 34 super(url); 35 } 36 37 40 protected boolean allowCaching() { 41 return true; 42 } 43 44 47 protected URL resolve() throws IOException { 48 String spec = url.getFile().trim(); 49 if (spec.startsWith("/")) spec = spec.substring(1); 51 if (!spec.startsWith(PLATFORM + "/")) { String message = NLS.bind(CommonMessages.url_badVariant, url); 53 throw new IOException (message); 54 } 55 return spec.length() == PLATFORM.length() + 1 ? installURL : new URL (installURL, spec.substring(PLATFORM.length() + 1)); 56 } 57 58 public static void startup(URL url) { 59 if (installURL != null) 61 return; 62 installURL = url; 63 PlatformURLHandler.register(PLATFORM, PlatformURLBaseConnection.class); 64 } 65 } 66 | Popular Tags |