Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.common/src')
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLBaseConnection.java65
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java518
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLHandler.java83
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java353
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java428
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonMessages.java62
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java153
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DevClassPathHelper.java98
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java276
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterFactoryExt.java31
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterManagerProvider.java30
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IRuntimeConstants.java37
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/LocalizationUtils.java56
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MetaDataKeeper.java37
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLConfigConnection.java102
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLConverter.java56
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLFragmentConnection.java75
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLMetaConnection.java83
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLPluginConnection.java109
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java323
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java137
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java121
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/commonMessages.properties46
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/package.html24
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.java112
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AssertionFailedException.java39
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/CoreException.java107
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/FileLocator.java215
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdaptable.java49
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterFactory.java54
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterManager.java260
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroup.java91
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroupProvider.java36
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ILogListener.java32
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IPath.java505
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java129
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitorWithBlocking.java61
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ISafeRunnable.java49
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IStatus.java186
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java190
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/MultiStatus.java149
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/NullProgressMonitor.java126
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/OperationCanceledException.java44
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java989
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PlatformObject.java68
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PluginVersionIdentifier.java454
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ProgressMonitorWrapper.java170
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/QualifiedName.java116
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java70
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Status.java279
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java781
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubProgressMonitor.java183
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/package.html17
53 files changed, 0 insertions, 8864 deletions
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLBaseConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLBaseConnection.java
deleted file mode 100644
index 2e2b2c1f0..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLBaseConnection.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.boot;
-
-import java.io.IOException;
-import java.net.URL;
-import org.eclipse.core.internal.runtime.CommonMessages;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Platform URL support
- * platform:/base/ maps to platform installation location
- */
-public class PlatformURLBaseConnection extends PlatformURLConnection {
-
- // platform/ protocol
- public static final String PLATFORM = "base"; //$NON-NLS-1$
- public static final String PLATFORM_URL_STRING = PlatformURLHandler.PROTOCOL + PlatformURLHandler.PROTOCOL_SEPARATOR + "/" + PLATFORM + "/"; //$NON-NLS-1$ //$NON-NLS-2$
-
- private static URL installURL;
-
- /*
- * Constructor for the class.
- */
- public PlatformURLBaseConnection(URL url) {
- super(url);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.url.PlatformURLConnection#allowCaching()
- */
- protected boolean allowCaching() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.url.PlatformURLConnection#resolve()
- */
- protected URL resolve() throws IOException {
- String spec = url.getFile().trim();
- if (spec.startsWith("/")) //$NON-NLS-1$
- spec = spec.substring(1);
- if (!spec.startsWith(PLATFORM + "/")) { //$NON-NLS-1$
- String message = NLS.bind(CommonMessages.url_badVariant, url);
- throw new IOException(message);
- }
- return spec.length() == PLATFORM.length() + 1 ? installURL : new URL(installURL, spec.substring(PLATFORM.length() + 1));
- }
-
- public static void startup(URL url) {
- // register connection type for platform:/base/ handling
- if (installURL != null)
- return;
- installURL = url;
- PlatformURLHandler.register(PLATFORM, PlatformURLBaseConnection.class);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java
deleted file mode 100644
index 3b39d45bc..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.boot;
-
-import java.io.*;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Enumeration;
-import java.util.Properties;
-import org.eclipse.core.internal.runtime.Activator;
-import org.eclipse.core.internal.runtime.CommonMessages;
-import org.eclipse.osgi.service.debug.DebugOptions;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Version;
-
-/**
- * Platform URL support
- */
-public abstract class PlatformURLConnection extends URLConnection {
-
- // URL access
- private boolean isInCache = false;
- private boolean isJar = false;
-
- // protected URL url; // declared in super (platform: URL)
- private URL resolvedURL = null; // resolved file URL (e.g. http: URL)
- private URL cachedURL = null; // file URL in cache (file: URL)
-
- private URLConnection connection = null; // actual connection
-
- // local cache
- private static Properties cacheIndex = new Properties();
- private static String cacheLocation;
- private static String indexName;
- private static String filePrefix;
-
- // constants
- private static final int BUF_SIZE = 32768;
- private static final Object NOT_FOUND = new Object(); // marker
- private static final String CACHE_PROP = ".cache.properties"; //$NON-NLS-1$
- private static final String CACHE_LOCATION_PROP = "location"; //$NON-NLS-1$
- private static final String CACHE_INDEX_PROP = "index"; //$NON-NLS-1$
- private static final String CACHE_PREFIX_PROP = "prefix"; //$NON-NLS-1$
- private static final String CACHE_INDEX = ".index.properties"; //$NON-NLS-1$
- private static final String CACHE_DIR = ".eclipse-" + PlatformURLHandler.PROTOCOL + File.separator; //$NON-NLS-1$
-
- // debug tracing
- private static final String OPTION_DEBUG = "org.eclipse.core.runtime/url/debug"; //$NON-NLS-1$;
- private static final String OPTION_DEBUG_CONNECT = OPTION_DEBUG + "/connect"; //$NON-NLS-1$;
- private static final String OPTION_DEBUG_CACHE_LOOKUP = OPTION_DEBUG + "/cachelookup"; //$NON-NLS-1$;
- private static final String OPTION_DEBUG_CACHE_COPY = OPTION_DEBUG + "/cachecopy"; //$NON-NLS-1$;
-
- public final static boolean DEBUG;
- public final static boolean DEBUG_CONNECT;
- public final static boolean DEBUG_CACHE_LOOKUP;
- public final static boolean DEBUG_CACHE_COPY;
-
- static {
- Activator activator = Activator.getDefault();
- if (activator == null) {
- DEBUG = DEBUG_CONNECT = DEBUG_CACHE_LOOKUP = DEBUG_CACHE_COPY = false;
- } else {
- DebugOptions debugOptions = activator.getDebugOptions();
- if (debugOptions != null) {
- DEBUG = debugOptions.getBooleanOption(OPTION_DEBUG, false);
- DEBUG_CONNECT = debugOptions.getBooleanOption(OPTION_DEBUG_CONNECT, true);
- DEBUG_CACHE_LOOKUP = debugOptions.getBooleanOption(OPTION_DEBUG_CACHE_LOOKUP, true);
- DEBUG_CACHE_COPY = debugOptions.getBooleanOption(OPTION_DEBUG_CACHE_COPY, true);
- } else
- DEBUG = DEBUG_CONNECT = DEBUG_CACHE_LOOKUP = DEBUG_CACHE_COPY = false;
- }
- }
-
- protected PlatformURLConnection(URL url) {
- super(url);
- }
-
- protected boolean allowCaching() {
- return false;
- }
-
- public void connect() throws IOException {
- connect(false);
- }
-
- private synchronized void connect(boolean asLocal) throws IOException {
- if (connected)
- return;
-
- if (shouldCache(asLocal)) {
- try {
- URL inCache = getURLInCache();
- if (inCache != null)
- connection = inCache.openConnection();
- } catch (IOException e) {
- // failed to cache ... will use resolved URL instead
- }
- }
-
- // use resolved URL
- if (connection == null)
- connection = resolvedURL.openConnection();
- connected = true;
- if (DEBUG && DEBUG_CONNECT)
- debug("Connected as " + connection.getURL()); //$NON-NLS-1$
- }
-
- //TODO consider refactoring this method... it is too long
- //TODO avoid cryptic identifiers such as ix, tgt, tmp, srcis, tgtos...
- private void copyToCache() throws IOException {
-
- if (isInCache | cachedURL == null)
- return;
- String tmp;
- int ix;
-
- // cache entry key
- String key;
- if (isJar) {
- tmp = url.getFile();
- ix = tmp.lastIndexOf(PlatformURLHandler.JAR_SEPARATOR);
- if (ix != -1)
- tmp = tmp.substring(0, ix);
- key = tmp;
- } else
- key = url.getFile();
-
- // source url
- URL src;
- if (isJar) {
- tmp = resolvedURL.getFile();
- ix = tmp.lastIndexOf(PlatformURLHandler.JAR_SEPARATOR);
- if (ix != -1)
- tmp = tmp.substring(0, ix);
- src = new URL(tmp);
- } else
- src = resolvedURL;
- InputStream srcis = null;
-
- // cache target
- String tgt;
- if (isJar) {
- tmp = cachedURL.getFile();
- ix = tmp.indexOf(PlatformURLHandler.PROTOCOL_SEPARATOR);
- if (ix != -1)
- tmp = tmp.substring(ix + 1);
- ix = tmp.lastIndexOf(PlatformURLHandler.JAR_SEPARATOR);
- if (ix != -1)
- tmp = tmp.substring(0, ix);
- tgt = tmp;
- } else
- tgt = cachedURL.getFile();
- File tgtFile = null;
- FileOutputStream tgtos = null;
-
- boolean error = false;
- long total = 0;
-
- try {
- if (DEBUG && DEBUG_CACHE_COPY) {
- if (isJar)
- debug("Caching jar as " + tgt); //$NON-NLS-1$
- else
- debug("Caching as " + tgt); //$NON-NLS-1$
- }
-
- srcis = src.openStream();
- byte[] buf = new byte[BUF_SIZE];
- int count = srcis.read(buf);
-
- tgtFile = new File(tgt);
- tgtos = new FileOutputStream(tgtFile);
-
- while (count != -1) {
- total += count;
- tgtos.write(buf, 0, count);
- count = srcis.read(buf);
- }
-
- srcis.close();
- srcis = null;
- tgtos.flush();
- tgtos.getFD().sync();
- tgtos.close();
- tgtos = null;
-
- // add cache entry
- cacheIndex.put(key, tgt);
- isInCache = true;
- } catch (IOException e) {
- error = true;
- cacheIndex.put(key, NOT_FOUND);
- // mark cache entry for this execution
- if (DEBUG && DEBUG_CACHE_COPY)
- debug("Failed to cache due to " + e); //$NON-NLS-1$
- throw e;
- } finally {
- if (!error && DEBUG && DEBUG_CACHE_COPY)
- debug(total + " bytes copied"); //$NON-NLS-1$
- if (srcis != null)
- srcis.close();
- if (tgtos != null)
- tgtos.close();
- }
- }
-
- protected void debug(String s) {
- System.out.println("URL " + getURL().toString() + "^" + Integer.toHexString(Thread.currentThread().hashCode()) + " " + s); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- private static void debugStartup(String s) {
- System.out.println("URL " + s); //$NON-NLS-1$
- }
-
- public URL[] getAuxillaryURLs() throws IOException {
- return null;
- }
-
- public synchronized InputStream getInputStream() throws IOException {
- if (!connected)
- connect();
- return connection.getInputStream();
- }
-
- public URL getResolvedURL() {
- return resolvedURL;
- }
-
- public URL getURLAsLocal() throws IOException {
- connect(true); // connect and force caching if necessary
- URL u = connection.getURL();
- String up = u.getProtocol();
- if (!up.equals(PlatformURLHandler.FILE) && !up.equals(PlatformURLHandler.JAR) && !up.startsWith(PlatformURLHandler.BUNDLE))
- throw new IOException(NLS.bind(CommonMessages.url_noaccess, up));
- return u;
- }
-
- //TODO consider refactoring this method... it is too long
- private URL getURLInCache() throws IOException {
-
- if (!allowCaching())
- return null; // target should not be cached
-
- if (isInCache)
- return cachedURL;
-
- if (cacheLocation == null | cacheIndex == null)
- return null; // not caching
-
- // check if we are dealing with a .jar/ .zip
- String file = ""; //$NON-NLS-1$
- String jarEntry = null;
- if (isJar) {
- file = url.getFile();
- int ix = file.lastIndexOf(PlatformURLHandler.JAR_SEPARATOR);
- if (ix != -1) {
- jarEntry = file.substring(ix + PlatformURLHandler.JAR_SEPARATOR.length());
- file = file.substring(0, ix);
- }
- } else {
- file = url.getFile();
- }
-
- // check for cached entry
- String tmp = (String) cacheIndex.get(file);
-
- // check for "not found" marker
- if (tmp != null && tmp == NOT_FOUND)
- throw new IOException();
-
- // validate cache entry
- if (tmp != null && !(new File(tmp)).exists()) {
- tmp = null;
- cacheIndex.remove(url.getFile());
- }
-
- // found in cache
- if (tmp != null) {
- if (isJar) {
- if (DEBUG && DEBUG_CACHE_LOOKUP)
- debug("Jar located in cache as " + tmp); //$NON-NLS-1$
- tmp = PlatformURLHandler.FILE + PlatformURLHandler.PROTOCOL_SEPARATOR + tmp + PlatformURLHandler.JAR_SEPARATOR + jarEntry;
- cachedURL = new URL(PlatformURLHandler.JAR, null, -1, tmp);
- } else {
- if (DEBUG && DEBUG_CACHE_LOOKUP)
- debug("Located in cache as " + tmp); //$NON-NLS-1$
- cachedURL = new URL(PlatformURLHandler.FILE, null, -1, tmp);
- }
- isInCache = true;
- } else {
- // attempt to cache
- int ix = file.lastIndexOf("/"); //$NON-NLS-1$
- tmp = file.substring(ix + 1);
- tmp = cacheLocation + filePrefix + Long.toString((new java.util.Date()).getTime()) + "_" + tmp; //$NON-NLS-1$
- tmp = tmp.replace(File.separatorChar, '/');
- if (isJar) {
- tmp = PlatformURLHandler.FILE + PlatformURLHandler.PROTOCOL_SEPARATOR + tmp + PlatformURLHandler.JAR_SEPARATOR + jarEntry;
- cachedURL = new URL(PlatformURLHandler.JAR, null, -1, tmp);
- } else
- cachedURL = new URL(PlatformURLHandler.FILE, null, -1, tmp);
- copyToCache();
- }
-
- return cachedURL;
- }
-
- /*
- * to be implemented by subclass
- * @return URL resolved URL
- */
- protected URL resolve() throws IOException {
- // TODO throw UnsupportedOperationException instead - this is a bug in subclass, not an actual failure
- throw new IOException();
- }
-
- protected String getId(String spec) {
- String id = (String) parse(spec)[0];
- return id == null ? spec : id;
- }
-
- protected String getVersion(String spec) {
- Version version = (Version) parse(spec)[1];
- return version == null ? "" : version.toString(); //$NON-NLS-1$
- }
-
- private Object[] parse(String spec) {
- String bsn = null;
- Version version = null;
- int underScore = spec.indexOf('_');
- while (underScore >= 0) {
- bsn = spec.substring(0, underScore);
- try {
- version = Version.parseVersion(spec.substring(underScore + 1));
- } catch (IllegalArgumentException iae) {
- // continue to next underscore
- underScore = spec.indexOf('_', underScore + 1);
- continue;
- }
- break;
- }
- return new Object[] {bsn, version};
- }
-
- void setResolvedURL(URL url) throws IOException {
- if (url == null)
- throw new IOException();
- if (resolvedURL != null)
- return;
- int ix = url.getFile().lastIndexOf(PlatformURLHandler.JAR_SEPARATOR);
- isJar = -1 != ix;
- // Resolved URLs containing !/ separator are assumed to be jar URLs.
- // If the resolved protocol is not jar, new jar URL is created.
- if (isJar && !url.getProtocol().equals(PlatformURLHandler.JAR))
- url = new URL(PlatformURLHandler.JAR, "", -1, url.toExternalForm()); //$NON-NLS-1$
- resolvedURL = url;
- }
-
- private boolean shouldCache(boolean asLocal) {
-
- // don't cache files that are known to be local
- String rp = resolvedURL.getProtocol();
- String rf = resolvedURL.getFile();
- if (rp.equals(PlatformURLHandler.FILE))
- return false;
- if (rp.equals(PlatformURLHandler.JAR) && (rf.startsWith(PlatformURLHandler.FILE)))
- return false;
-
- // for other files force caching if local connection was requested
- if (asLocal)
- return true;
-
- // for now cache all files
- // XXX: add cache policy support
- return true;
- }
-
- static void shutdown() {
- if (indexName != null && cacheLocation != null) {
- // weed out "not found" entries
- Enumeration keys = cacheIndex.keys();
- String key;
- Object value;
- while (keys.hasMoreElements()) {
- key = (String) keys.nextElement();
- value = cacheIndex.get(key);
- if (value == NOT_FOUND)
- cacheIndex.remove(key);
- }
- //if the cache index is empty we don't need to save it
- if (cacheIndex.size() == 0)
- return;
- try {
- // try to save cache index
- FileOutputStream fos = null;
- fos = new FileOutputStream(cacheLocation + indexName);
- try {
- cacheIndex.store(fos, null);
- fos.flush();
- fos.getFD().sync();
- } finally {
- fos.close();
- }
- } catch (IOException e) {
- // failed to store cache index ... ignore
- }
- }
- }
-
- //TODO consider splitting this method into two or more steps - it is too long
- static void startup(String location, String os, String ws, String nl) {
- verifyLocation(location); // check for platform location, ignore errors
- String cacheProps = location.trim();
- if (!cacheProps.endsWith(File.separator))
- cacheProps += File.separator;
- cacheProps += CACHE_PROP;
- File cachePropFile = new File(cacheProps);
- Properties props = null;
- FileInputStream fis;
-
- if (cachePropFile.exists()) {
- // load existing properties
- try {
- props = new Properties();
- fis = new FileInputStream(cachePropFile);
- try {
- props.load(fis);
- } finally {
- fis.close();
- }
- } catch (IOException e) {
- props = null;
- }
- }
-
- if (props == null) {
- // first time up, or failed to load previous settings
- props = new Properties();
-
- String tmp = System.getProperty("user.home"); //$NON-NLS-1$
- if (!tmp.endsWith(File.separator))
- tmp += File.separator;
- tmp += CACHE_DIR;
- props.put(CACHE_LOCATION_PROP, tmp);
-
- tmp = Long.toString((new java.util.Date()).getTime());
- props.put(CACHE_PREFIX_PROP, tmp);
-
- tmp += CACHE_INDEX;
- props.put(CACHE_INDEX_PROP, tmp);
-
- // save for next time around
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(cachePropFile);
- try {
- props.store(fos, null);
- fos.flush();
- fos.getFD().sync();
- } finally {
- fos.close();
- }
- } catch (IOException e) {
- // failed to store cache location metadata ... ignore
- }
- }
-
- // remember settings for shutdown processing
- filePrefix = (String) props.get(CACHE_PREFIX_PROP);
- indexName = (String) props.get(CACHE_INDEX_PROP);
- cacheLocation = (String) props.get(CACHE_LOCATION_PROP);
-
- if (DEBUG) {
- debugStartup("Cache location: " + cacheLocation); //$NON-NLS-1$
- debugStartup("Cache index: " + indexName); //$NON-NLS-1$
- debugStartup("Cache file prefix: " + filePrefix); //$NON-NLS-1$
- }
-
- // create cache directory structure if needed
- if (!verifyLocation(cacheLocation)) {
- indexName = null;
- cacheLocation = null;
- if (DEBUG)
- debugStartup("Failed to create cache directory structure. Caching suspended"); //$NON-NLS-1$
- return;
- }
-
- // attempt to initialize cache index
- if (cacheLocation != null && indexName != null) {
- try {
- fis = new FileInputStream(cacheLocation + indexName);
- try {
- cacheIndex.load(fis);
- } finally {
- fis.close();
- }
- } catch (IOException e) {
- if (DEBUG)
- debugStartup("Failed to initialize cache"); //$NON-NLS-1$
- }
- }
- }
-
- private static boolean verifyLocation(String location) {
- // verify cache directory exists. Create if needed
- File cacheDir = new File(location);
- if (cacheDir.exists())
- return true;
- return cacheDir.mkdirs();
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLHandler.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLHandler.java
deleted file mode 100644
index 2bfa34b21..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLHandler.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.boot;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.net.*;
-import java.util.Hashtable;
-import org.eclipse.core.internal.runtime.CommonMessages;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.service.url.AbstractURLStreamHandlerService;
-
-/**
- * URL handler for the "platform" protocol
- */
-public class PlatformURLHandler extends AbstractURLStreamHandlerService {
-
- private static Hashtable connectionType = new Hashtable();
-
- // URL protocol designations
- public static final String PROTOCOL = "platform"; //$NON-NLS-1$
- public static final String FILE = "file"; //$NON-NLS-1$
- public static final String JAR = "jar"; //$NON-NLS-1$
- public static final String BUNDLE = "bundle"; //$NON-NLS-1$
- public static final String JAR_SEPARATOR = "!/"; //$NON-NLS-1$
- public static final String PROTOCOL_SEPARATOR = ":"; //$NON-NLS-1$
-
- /*
- * Constructor for the class.
- */
- public PlatformURLHandler() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.url.AbstractURLStreamHandlerService#openConnection(java.net.URL)
- */
- public URLConnection openConnection(URL url) throws IOException {
- // Note: openConnection() method is made public (rather than protected)
- // to enable request delegation from proxy handlers
- String spec = url.getFile().trim();
- if (spec.startsWith("/")) //$NON-NLS-1$
- spec = spec.substring(1);
- int ix = spec.indexOf("/"); //$NON-NLS-1$
- if (ix == -1)
- throw new MalformedURLException(NLS.bind(CommonMessages.url_invalidURL, url.toExternalForm()));
-
- String type = spec.substring(0, ix);
- Constructor construct = (Constructor) connectionType.get(type);
- if (construct == null)
- throw new MalformedURLException(NLS.bind(CommonMessages.url_badVariant, type));
-
- PlatformURLConnection connection = null;
- try {
- connection = (PlatformURLConnection) construct.newInstance(new Object[] {url});
- } catch (Exception e) {
- throw new IOException(NLS.bind(CommonMessages.url_createConnection, e.getMessage()));
- }
- connection.setResolvedURL(connection.resolve());
- return connection;
- }
-
- public static void register(String type, Class connectionClass) {
- try {
- Constructor c = connectionClass.getConstructor(new Class[] {URL.class});
- connectionType.put(type, c);
- } catch (NoSuchMethodException e) {
- //don't register connection classes that don't conform to the spec
- }
- }
-
- public static void unregister(String type) {
- connectionType.remove(type);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java
deleted file mode 100644
index e72eddba0..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.net.URL;
-import java.util.*;
-import org.eclipse.core.internal.boot.PlatformURLBaseConnection;
-import org.eclipse.core.internal.boot.PlatformURLHandler;
-import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.osgi.framework.log.FrameworkLog;
-import org.eclipse.osgi.service.datalocation.Location;
-import org.eclipse.osgi.service.debug.DebugOptions;
-import org.eclipse.osgi.service.localization.BundleLocalization;
-import org.eclipse.osgi.service.urlconversion.URLConverter;
-import org.osgi.framework.*;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.service.url.URLConstants;
-import org.osgi.service.url.URLStreamHandlerService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * The Common runtime plugin class.
- *
- * This class can only be used if OSGi plugin is available.
- */
-public class Activator implements BundleActivator {
-
- /**
- * Table to keep track of all the URL converter services.
- */
- private static Map urlTrackers = new HashMap();
- private static BundleContext bundleContext;
- private static Activator singleton;
- private ServiceRegistration platformURLConverterService = null;
- private ServiceRegistration adapterManagerService = null;
- private ServiceTracker installLocationTracker = null;
- private ServiceTracker instanceLocationTracker = null;
- private ServiceTracker configLocationTracker = null;
- private ServiceTracker bundleTracker = null;
- private ServiceTracker debugTracker = null;
- private ServiceTracker logTracker = null;
- private ServiceTracker localizationTracker = null;
-
- /*
- * Returns the singleton for this Activator. Callers should be aware that
- * this will return null if the bundle is not active.
- */
- public static Activator getDefault() {
- return singleton;
- }
-
- /**
- * Print a debug message to the console.
- * Pre-pend the message with the current date and the name of the current thread.
- */
- public static void message(String message) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(new Date(System.currentTimeMillis()));
- buffer.append(" - ["); //$NON-NLS-1$
- buffer.append(Thread.currentThread().getName());
- buffer.append("] "); //$NON-NLS-1$
- buffer.append(message);
- System.out.println(buffer.toString());
- }
-
- /* (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- bundleContext = context;
- singleton = this;
- Dictionary urlProperties = new Hashtable();
- urlProperties.put("protocol", "platform"); //$NON-NLS-1$ //$NON-NLS-2$
- platformURLConverterService = context.registerService(URLConverter.class.getName(), new PlatformURLConverter(), urlProperties);
- adapterManagerService = context.registerService(IAdapterManager.class.getName(), AdapterManager.getDefault(), null);
- installPlatformURLSupport();
- }
-
- /*
- * Return the configuration location service, if available.
- */
- public Location getConfigurationLocation() {
- if (configLocationTracker == null) {
- Filter filter = null;
- try {
- filter = bundleContext.createFilter(Location.CONFIGURATION_FILTER);
- } catch (InvalidSyntaxException e) {
- // should not happen
- }
- configLocationTracker = new ServiceTracker(bundleContext, filter, null);
- configLocationTracker.open();
- }
- return (Location) configLocationTracker.getService();
- }
-
- /*
- * Return the debug options service, if available.
- */
- public DebugOptions getDebugOptions() {
- if (debugTracker == null) {
- debugTracker = new ServiceTracker(bundleContext, DebugOptions.class.getName(), null);
- debugTracker.open();
- }
- return (DebugOptions) debugTracker.getService();
- }
-
- /*
- * Return the framework log service, if available.
- */
- public FrameworkLog getFrameworkLog() {
- if (logTracker == null) {
- logTracker = new ServiceTracker(bundleContext, FrameworkLog.class.getName(), null);
- logTracker.open();
- }
- return (FrameworkLog) logTracker.getService();
- }
-
- /*
- * Return the instance location service, if available.
- */
- public Location getInstanceLocation() {
- if (instanceLocationTracker == null) {
- Filter filter = null;
- try {
- filter = bundleContext.createFilter(Location.INSTANCE_FILTER);
- } catch (InvalidSyntaxException e) {
- // ignore this. It should never happen as we have tested the above format.
- }
- instanceLocationTracker = new ServiceTracker(bundleContext, filter, null);
- instanceLocationTracker.open();
- }
- return (Location) instanceLocationTracker.getService();
- }
-
- /**
- * Return the resolved bundle with the specified symbolic name.
- *
- * @see PackageAdmin#getBundles(String, String)
- */
- public Bundle getBundle(String symbolicName) {
- PackageAdmin admin = getBundleAdmin();
- if (admin == null)
- return null;
- Bundle[] bundles = admin.getBundles(symbolicName, null);
- if (bundles == null)
- return null;
- //Return the first bundle that is not installed or uninstalled
- for (int i = 0; i < bundles.length; i++) {
- if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
- return bundles[i];
- }
- }
- return null;
- }
-
- /*
- * Return the package admin service, if available.
- */
- private PackageAdmin getBundleAdmin() {
- if (bundleTracker == null) {
- bundleTracker = new ServiceTracker(getContext(), PackageAdmin.class.getName(), null);
- bundleTracker.open();
- }
- return (PackageAdmin) bundleTracker.getService();
- }
-
- /*
- * Return an array of fragments for the given bundle host.
- */
- public Bundle[] getFragments(Bundle host) {
- PackageAdmin admin = getBundleAdmin();
- if (admin == null)
- return new Bundle[0];
- return admin.getFragments(host);
- }
-
- /*
- * Return the install location service if available.
- */
- public Location getInstallLocation() {
- if (installLocationTracker == null) {
- Filter filter = null;
- try {
- filter = bundleContext.createFilter(Location.INSTALL_FILTER);
- } catch (InvalidSyntaxException e) {
- // should not happen
- }
- installLocationTracker = new ServiceTracker(bundleContext, filter, null);
- installLocationTracker.open();
- }
- return (Location) installLocationTracker.getService();
- }
-
- /**
- * Returns the bundle id of the bundle that contains the provided object, or
- * <code>null</code> if the bundle could not be determined.
- */
- public String getBundleId(Object object) {
- if (object == null)
- return null;
- if (bundleTracker == null) {
- message("Bundle tracker is not set"); //$NON-NLS-1$
- return null;
- }
- PackageAdmin packageAdmin = (PackageAdmin) bundleTracker.getService();
- if (packageAdmin == null)
- return null;
-
- Bundle source = packageAdmin.getBundle(object.getClass());
- if (source != null && source.getSymbolicName() != null)
- return source.getSymbolicName();
- return null;
- }
-
- public ResourceBundle getLocalization(Bundle bundle, String locale) {
- if (localizationTracker == null) {
- BundleContext context = Activator.getContext();
- if (context == null) {
- message("ResourceTranslator called before plugin is started"); //$NON-NLS-1$
- return null;
- }
- localizationTracker = new ServiceTracker(context, BundleLocalization.class.getName(), null);
- localizationTracker.open();
- }
- BundleLocalization location = (BundleLocalization) localizationTracker.getService();
- if (location != null)
- return location.getLocalization(bundle, locale);
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- closeURLTrackerServices();
- if (platformURLConverterService != null) {
- platformURLConverterService.unregister();
- platformURLConverterService = null;
- }
- if (adapterManagerService != null) {
- adapterManagerService.unregister();
- adapterManagerService = null;
- }
- if (installLocationTracker != null) {
- installLocationTracker.close();
- installLocationTracker = null;
- }
- if (configLocationTracker != null) {
- configLocationTracker.close();
- configLocationTracker = null;
- }
- if (bundleTracker != null) {
- bundleTracker.close();
- bundleTracker = null;
- }
- if (debugTracker != null) {
- debugTracker.close();
- debugTracker = null;
- }
- if (logTracker != null) {
- logTracker.close();
- logTracker = null;
- }
- if (instanceLocationTracker != null) {
- instanceLocationTracker.close();
- instanceLocationTracker = null;
- }
- if (localizationTracker != null) {
- localizationTracker.close();
- localizationTracker = null;
- }
- bundleContext = null;
- singleton = null;
- }
-
- /*
- * Return this bundle's context.
- */
- static BundleContext getContext() {
- return bundleContext;
- }
-
- /*
- * Let go of all the services that we acquired and kept track of.
- */
- private static void closeURLTrackerServices() {
- synchronized (urlTrackers) {
- if (!urlTrackers.isEmpty()) {
- for (Iterator iter = urlTrackers.keySet().iterator(); iter.hasNext();) {
- String key = (String) iter.next();
- ServiceTracker tracker = (ServiceTracker) urlTrackers.get(key);
- tracker.close();
- }
- urlTrackers = new HashMap();
- }
- }
- }
-
- /*
- * Return the URL Converter for the given URL. Return null if we can't
- * find one.
- */
- public static URLConverter getURLConverter(URL url) {
- String protocol = url.getProtocol();
- synchronized (urlTrackers) {
- ServiceTracker tracker = (ServiceTracker) urlTrackers.get(protocol);
- if (tracker == null) {
- // get the right service based on the protocol
- String FILTER_PREFIX = "(&(objectClass=" + URLConverter.class.getName() + ")(protocol="; //$NON-NLS-1$ //$NON-NLS-2$
- String FILTER_POSTFIX = "))"; //$NON-NLS-1$
- Filter filter = null;
- try {
- filter = getContext().createFilter(FILTER_PREFIX + protocol + FILTER_POSTFIX);
- } catch (InvalidSyntaxException e) {
- return null;
- }
- tracker = new ServiceTracker(getContext(), filter, null);
- tracker.open();
- // cache it in the registry
- urlTrackers.put(protocol, tracker);
- }
- return (URLConverter) tracker.getService();
- }
- }
-
- /**
- * Register the platform URL support as a service to the URLHandler service
- */
- private void installPlatformURLSupport() {
- PlatformURLPluginConnection.startup();
- PlatformURLFragmentConnection.startup();
- PlatformURLMetaConnection.startup();
- PlatformURLConfigConnection.startup();
-
- Location service = getInstallLocation();
- if (service != null)
- PlatformURLBaseConnection.startup(service.getURL());
-
- Hashtable properties = new Hashtable(1);
- properties.put(URLConstants.URL_HANDLER_PROTOCOL, new String[] {PlatformURLHandler.PROTOCOL});
- getContext().registerService(URLStreamHandlerService.class.getName(), new PlatformURLHandler(), properties);
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java
deleted file mode 100644
index b420e2db2..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- * David Green - fix factories with non-standard class loading (bug 200068)
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.util.*;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.core.runtime.IAdapterManager;
-
-/**
- * This class is the standard implementation of <code>IAdapterManager</code>. It provides
- * fast lookup of property values with the following semantics:
- * <ul>
- * <li>At most one factory will be invoked per property lookup
- * <li>If multiple installed factories provide the same adapter, only the first found in
- * the search order will be invoked.
- * <li>The search order from a class with the definition <br>
- * <code>class X extends Y implements A, B</code><br> is as follows: <il>
- * <li>the target's class: X
- * <li>X's superclasses in order to <code>Object</code>
- * <li>a breadth-first traversal of the target class's interfaces in the order returned by
- * <code>getInterfaces</code> (in the example, A and its superinterfaces then B and its
- * superinterfaces) </il>
- * </ul>
- *
- * @see IAdapterFactory
- * @see IAdapterManager
- */
-public final class AdapterManager implements IAdapterManager {
- /**
- * Cache of adapters for a given adaptable class. Maps String -> Map
- * (adaptable class name -> (adapter class name -> factory instance))
- * Thread safety note: The outer map is synchronized using a synchronized
- * map wrapper class. The inner map is not synchronized, but it is immutable
- * so synchronization is not necessary.
- */
- private Map adapterLookup;
-
- /**
- * Cache of classes for a given type name. Avoids too many loadClass calls.
- * (factory -> (type name -> Class)).
- * Thread safety note: Since this structure is a nested hash map, and both
- * the inner and outer maps are mutable, access to this entire structure is
- * controlled by the classLookupLock field. Note the field can still be
- * nulled concurrently without holding the lock.
- */
- private Map classLookup;
-
- /**
- * The lock object controlling access to the classLookup data structure.
- */
- private final Object classLookupLock = new Object();
-
- /**
- * Cache of class lookup order (Class -> Class[]). This avoids having to compute often, and
- * provides clients with quick lookup for instanceOf checks based on type name.
- * Thread safety note: The map is synchronized using a synchronized
- * map wrapper class. The arrays within the map are immutable.
- */
- private Map classSearchOrderLookup;
-
- /**
- * Map of factories, keyed by <code>String</code>, fully qualified class name of
- * the adaptable class that the factory provides adapters for. Value is a <code>List</code>
- * of <code>IAdapterFactory</code>.
- */
- private final HashMap factories;
-
- private final ArrayList lazyFactoryProviders;
-
- private static final AdapterManager singleton = new AdapterManager();
-
- public static AdapterManager getDefault() {
- return singleton;
- }
-
- /**
- * Private constructor to block instance creation.
- */
- private AdapterManager() {
- factories = new HashMap(5);
- lazyFactoryProviders = new ArrayList(1);
- }
-
- /**
- * Given a type name, add all of the factories that respond to those types into
- * the given table. Each entry will be keyed by the adapter class name (supplied in
- * IAdapterFactory.getAdapterList).
- */
- private void addFactoriesFor(String typeName, Map table) {
- List factoryList = (List) getFactories().get(typeName);
- if (factoryList == null)
- return;
- for (int i = 0, imax = factoryList.size(); i < imax; i++) {
- IAdapterFactory factory = (IAdapterFactory) factoryList.get(i);
- if (factory instanceof IAdapterFactoryExt) {
- String[] adapters = ((IAdapterFactoryExt) factory).getAdapterNames();
- for (int j = 0; j < adapters.length; j++) {
- if (table.get(adapters[j]) == null)
- table.put(adapters[j], factory);
- }
- } else {
- Class[] adapters = factory.getAdapterList();
- for (int j = 0; j < adapters.length; j++) {
- String adapterName = adapters[j].getName();
- if (table.get(adapterName) == null)
- table.put(adapterName, factory);
- }
- }
- }
- }
-
- private void cacheClassLookup(IAdapterFactory factory, Class clazz) {
- synchronized (classLookupLock) {
- //cache reference to lookup to protect against concurrent flush
- Map lookup = classLookup;
- if (lookup == null)
- classLookup = lookup = new HashMap(4);
- HashMap classes = (HashMap) lookup.get(factory);
- if (classes == null) {
- classes = new HashMap(4);
- lookup.put(factory, classes);
- }
- classes.put(clazz.getName(), clazz);
- }
- }
-
- private Class cachedClassForName(IAdapterFactory factory, String typeName) {
- synchronized (classLookupLock) {
- Class clazz = null;
- //cache reference to lookup to protect against concurrent flush
- Map lookup = classLookup;
- if (lookup != null) {
- HashMap classes = (HashMap) lookup.get(factory);
- if (classes != null) {
- clazz = (Class) classes.get(typeName);
- }
- }
- return clazz;
- }
- }
-
- /**
- * Returns the class with the given fully qualified name, or null
- * if that class does not exist or belongs to a plug-in that has not
- * yet been loaded.
- */
- private Class classForName(IAdapterFactory factory, String typeName) {
- Class clazz = cachedClassForName(factory, typeName);
- if (clazz == null) {
- if (factory instanceof IAdapterFactoryExt)
- factory = ((IAdapterFactoryExt) factory).loadFactory(false);
- if (factory != null) {
- try {
- clazz = factory.getClass().getClassLoader().loadClass(typeName);
- } catch (ClassNotFoundException e) {
- // it is possible that the default bundle classloader is unaware of this class
- // but the adaptor factory can load it in some other way. See bug 200068.
- if (typeName == null)
- return null;
- Class[] adapterList = factory.getAdapterList();
- clazz = null;
- for (int i = 0; i < adapterList.length; i++) {
- if (typeName.equals(adapterList[i].getName())) {
- clazz = adapterList[i];
- break;
- }
- }
- if (clazz == null)
- return null; // class not yet loaded
- }
- cacheClassLookup(factory, clazz);
- }
- }
- return clazz;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterManager#getAdapterTypes(java.lang.Class)
- */
- public String[] computeAdapterTypes(Class adaptable) {
- Set types = getFactories(adaptable).keySet();
- return (String[]) types.toArray(new String[types.size()]);
- }
-
- /**
- * Computes the adapters that the provided class can adapt to, along
- * with the factory object that can perform that transformation. Returns
- * a table of adapter class name to factory object.
- * @param adaptable
- */
- private Map getFactories(Class adaptable) {
- //cache reference to lookup to protect against concurrent flush
- Map lookup = adapterLookup;
- if (lookup == null)
- adapterLookup = lookup = Collections.synchronizedMap(new HashMap(30));
- Map table = (Map) lookup.get(adaptable.getName());
- if (table == null) {
- // calculate adapters for the class
- table = new HashMap(4);
- Class[] classes = computeClassOrder(adaptable);
- for (int i = 0; i < classes.length; i++)
- addFactoriesFor(classes[i].getName(), table);
- // cache the table
- lookup.put(adaptable.getName(), table);
- }
- return table;
- }
-
- public Class[] computeClassOrder(Class adaptable) {
- Class[] classes = null;
- //cache reference to lookup to protect against concurrent flush
- Map lookup = classSearchOrderLookup;
- if (lookup == null)
- classSearchOrderLookup = lookup = Collections.synchronizedMap(new HashMap());
- else
- classes = (Class[]) lookup.get(adaptable);
- // compute class order only if it hasn't been cached before
- if (classes == null) {
- ArrayList classList = new ArrayList();
- computeClassOrder(adaptable, classList);
- classes = (Class[]) classList.toArray(new Class[classList.size()]);
- lookup.put(adaptable, classes);
- }
- return classes;
- }
-
- /**
- * Builds and returns a table of adapters for the given adaptable type.
- * The table is keyed by adapter class name. The
- * value is the <b>sole<b> factory that defines that adapter. Note that
- * if multiple adapters technically define the same property, only the
- * first found in the search order is considered.
- *
- * Note that it is important to maintain a consistent class and interface
- * lookup order. See the class comment for more details.
- */
- private void computeClassOrder(Class adaptable, Collection classes) {
- Class clazz = adaptable;
- Set seen = new HashSet(4);
- while (clazz != null) {
- classes.add(clazz);
- computeInterfaceOrder(clazz.getInterfaces(), classes, seen);
- clazz = clazz.getSuperclass();
- }
- }
-
- private void computeInterfaceOrder(Class[] interfaces, Collection classes, Set seen) {
- List newInterfaces = new ArrayList(interfaces.length);
- for (int i = 0; i < interfaces.length; i++) {
- Class interfac = interfaces[i];
- if (seen.add(interfac)) {
- //note we cannot recurse here without changing the resulting interface order
- classes.add(interfac);
- newInterfaces.add(interfac);
- }
- }
- for (Iterator it = newInterfaces.iterator(); it.hasNext();)
- computeInterfaceOrder(((Class) it.next()).getInterfaces(), classes, seen);
- }
-
- /**
- * Flushes the cache of adapter search paths. This is generally required whenever an
- * adapter is added or removed.
- * <p>
- * It is likely easier to just toss the whole cache rather than trying to be smart
- * and remove only those entries affected.
- * </p>
- */
- public synchronized void flushLookup() {
- adapterLookup = null;
- classLookup = null;
- classSearchOrderLookup = null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterManager#getAdapter(java.lang.Object, java.lang.Class)
- */
- public Object getAdapter(Object adaptable, Class adapterType) {
- IAdapterFactory factory = (IAdapterFactory) getFactories(adaptable.getClass()).get(adapterType.getName());
- Object result = null;
- if (factory != null)
- result = factory.getAdapter(adaptable, adapterType);
- if (result == null && adapterType.isInstance(adaptable))
- return adaptable;
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterManager#getAdapter(java.lang.Object, java.lang.Class)
- */
- public Object getAdapter(Object adaptable, String adapterType) {
- return getAdapter(adaptable, adapterType, false);
- }
-
- /**
- * Returns an adapter of the given type for the provided adapter.
- * @param adaptable the object to adapt
- * @param adapterType the type to adapt the object to
- * @param force <code>true</code> if the plug-in providing the
- * factory should be activated if necessary. <code>false</code>
- * if no plugin activations are desired.
- */
- private Object getAdapter(Object adaptable, String adapterType, boolean force) {
- IAdapterFactory factory = (IAdapterFactory) getFactories(adaptable.getClass()).get(adapterType);
- if (force && factory instanceof IAdapterFactoryExt)
- factory = ((IAdapterFactoryExt) factory).loadFactory(true);
- Object result = null;
- if (factory != null) {
- Class clazz = classForName(factory, adapterType);
- if (clazz != null)
- result = factory.getAdapter(adaptable, clazz);
- }
- if (result == null && adaptable.getClass().getName().equals(adapterType))
- return adaptable;
- return result;
- }
-
- public boolean hasAdapter(Object adaptable, String adapterTypeName) {
- return getFactories(adaptable.getClass()).get(adapterTypeName) != null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterManager#queryAdapter(java.lang.Object, java.lang.String)
- */
- public int queryAdapter(Object adaptable, String adapterTypeName) {
- IAdapterFactory factory = (IAdapterFactory) getFactories(adaptable.getClass()).get(adapterTypeName);
- if (factory == null)
- return NONE;
- if (factory instanceof IAdapterFactoryExt) {
- factory = ((IAdapterFactoryExt) factory).loadFactory(false); // don't force loading
- if (factory == null)
- return NOT_LOADED;
- }
- return LOADED;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterManager#loadAdapter(java.lang.Object, java.lang.String)
- */
- public Object loadAdapter(Object adaptable, String adapterTypeName) {
- return getAdapter(adaptable, adapterTypeName, true);
- }
-
- /*
- * @see IAdapterManager#registerAdapters
- */
- public synchronized void registerAdapters(IAdapterFactory factory, Class adaptable) {
- registerFactory(factory, adaptable.getName());
- flushLookup();
- }
-
- /*
- * @see IAdapterManager#registerAdapters
- */
- public void registerFactory(IAdapterFactory factory, String adaptableType) {
- List list = (List) factories.get(adaptableType);
- if (list == null) {
- list = new ArrayList(5);
- factories.put(adaptableType, list);
- }
- list.add(factory);
- }
-
- /*
- * @see IAdapterManager#unregisterAdapters
- */
- public synchronized void unregisterAdapters(IAdapterFactory factory) {
- for (Iterator it = factories.values().iterator(); it.hasNext();)
- ((List) it.next()).remove(factory);
- flushLookup();
- }
-
- /*
- * @see IAdapterManager#unregisterAdapters
- */
- public synchronized void unregisterAdapters(IAdapterFactory factory, Class adaptable) {
- List factoryList = (List) factories.get(adaptable.getName());
- if (factoryList == null)
- return;
- factoryList.remove(factory);
- flushLookup();
- }
-
- /*
- * Shuts down the adapter manager by removing all factories
- * and removing the registry change listener. Should only be
- * invoked during platform shutdown.
- */
- public synchronized void unregisterAllAdapters() {
- factories.clear();
- flushLookup();
- }
-
- public void registerLazyFactoryProvider(IAdapterManagerProvider factoryProvider) {
- synchronized (lazyFactoryProviders) {
- lazyFactoryProviders.add(factoryProvider);
- }
- }
-
- public boolean unregisterLazyFactoryProvider(IAdapterManagerProvider factoryProvider) {
- synchronized (lazyFactoryProviders) {
- return lazyFactoryProviders.remove(factoryProvider);
- }
- }
-
- public HashMap getFactories() {
- // avoid the synchronize if we don't have to call it
- if (lazyFactoryProviders.size() == 0)
- return factories;
- synchronized (lazyFactoryProviders) {
- while (lazyFactoryProviders.size() > 0) {
- IAdapterManagerProvider provider = (IAdapterManagerProvider) lazyFactoryProviders.remove(0);
- if (provider.addFactories(this))
- flushLookup();
- }
- }
- return factories;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonMessages.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonMessages.java
deleted file mode 100644
index bbe69523c..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonMessages.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others. All rights reserved. This
- * program and the accompanying materials are 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:
- * IBM - Initial API and implementation
- **********************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import org.eclipse.osgi.util.NLS;
-
-// Common runtime plugin message catalog
-public class CommonMessages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.core.internal.runtime.commonMessages"; //$NON-NLS-1$
-
- public static String ok;
-
- // metadata
- public static String meta_couldNotCreate;
- public static String meta_instanceDataUnspecified;
- public static String meta_noDataModeSpecified;
- public static String meta_notDir;
- public static String meta_readonly;
- public static String meta_pluginProblems;
-
- // URL
- public static String url_badVariant;
- public static String url_createConnection;
- public static String url_invalidURL;
- public static String url_noaccess;
- public static String url_noOutput;
- public static String url_resolveFragment;
- public static String url_resolvePlugin;
-
- // parsing/resolve
- public static String parse_doubleSeparatorVersion;
- public static String parse_emptyPluginVersion;
- public static String parse_fourElementPluginVersion;
- public static String parse_numericMajorComponent;
- public static String parse_numericMinorComponent;
- public static String parse_numericServiceComponent;
- public static String parse_oneElementPluginVersion;
-
- public static String parse_postiveMajor;
- public static String parse_postiveMinor;
- public static String parse_postiveService;
- public static String parse_separatorEndVersion;
- public static String parse_separatorStartVersion;
-
- public static String activator_not_available;
-
- static {
- // load message values from bundle file
- reloadMessages();
- }
-
- public static void reloadMessages() {
- NLS.initializeMessages(BUNDLE_NAME, CommonMessages.class);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java
deleted file mode 100644
index 480d3aba4..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.framework.log.FrameworkLog;
-import org.eclipse.osgi.service.datalocation.Location;
-import org.eclipse.osgi.service.debug.DebugOptions;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Bundle;
-
-/**
- * This class can only be used if OSGi plugin is available
- */
-public class DataArea {
- private static final String OPTION_DEBUG = "org.eclipse.equinox.common/debug"; //$NON-NLS-1$;
-
- /* package */static final String F_META_AREA = ".metadata"; //$NON-NLS-1$
- /* package */static final String F_PLUGIN_DATA = ".plugins"; //$NON-NLS-1$
- /* package */static final String F_LOG = ".log"; //$NON-NLS-1$
- /**
- * Internal name of the preference storage file (value <code>"pref_store.ini"</code>) in this plug-in's (read-write) state area.
- */
- /* package */static final String PREFERENCES_FILE_NAME = "pref_store.ini"; //$NON-NLS-1$
-
- private IPath location; //The location of the instance data
- private boolean initialized = false;
-
- protected void assertLocationInitialized() throws IllegalStateException {
- if (location != null && initialized)
- return;
- Activator activator = Activator.getDefault();
- if (activator == null)
- throw new IllegalStateException(CommonMessages.activator_not_available);
- Location service = activator.getInstanceLocation();
- if (service == null)
- throw new IllegalStateException(CommonMessages.meta_noDataModeSpecified);
- try {
- URL url = service.getURL();
- if (url == null)
- throw new IllegalStateException(CommonMessages.meta_instanceDataUnspecified);
- // TODO assume the URL is a file:
- // Use the new File technique to ensure that the resultant string is
- // in the right format (e.g., leading / removed from /c:/foo etc)
- location = new Path(new File(url.getFile()).toString());
- initializeLocation();
- } catch (CoreException e) {
- throw new IllegalStateException(e.getMessage());
- }
- }
-
- public IPath getMetadataLocation() throws IllegalStateException {
- assertLocationInitialized();
- return location.append(F_META_AREA);
- }
-
- public IPath getInstanceDataLocation() throws IllegalStateException {
- assertLocationInitialized();
- return location;
- }
-
- public IPath getLogLocation() throws IllegalStateException {
- FrameworkLog log = Activator.getDefault().getFrameworkLog();
- if (log == null)
- return null;
- return new Path(log.getFile().getAbsolutePath());
- }
-
- /**
- * Returns the read/write location in which the given bundle can manage private state.
- */
- public IPath getStateLocation(Bundle bundle) throws IllegalStateException {
- assertLocationInitialized();
- return getStateLocation(bundle.getSymbolicName());
- }
-
- public IPath getStateLocation(String bundleName) throws IllegalStateException {
- assertLocationInitialized();
- return getMetadataLocation().append(F_PLUGIN_DATA).append(bundleName);
- }
-
- public IPath getPreferenceLocation(String bundleName, boolean create) throws IllegalStateException {
- IPath result = getStateLocation(bundleName);
- if (create)
- result.toFile().mkdirs();
- return result.append(PREFERENCES_FILE_NAME);
- }
-
- private void initializeLocation() throws CoreException {
- // check if the location can be created
- if (location.toFile().exists()) {
- if (!location.toFile().isDirectory()) {
- String message = NLS.bind(CommonMessages.meta_notDir, location);
- throw new CoreException(new Status(IStatus.ERROR, IRuntimeConstants.PI_RUNTIME, IRuntimeConstants.FAILED_WRITE_METADATA, message, null));
- }
- }
- //try infer the device if there isn't one (windows)
- if (location.getDevice() == null)
- location = new Path(location.toFile().getAbsolutePath());
- createLocation();
- initialized = true;
- }
-
- private void createLocation() throws CoreException {
- // append on the metadata location so that the whole structure is created.
- File file = location.append(F_META_AREA).toFile();
- try {
- file.mkdirs();
- } catch (Exception e) {
- String message = NLS.bind(CommonMessages.meta_couldNotCreate, file.getAbsolutePath());
- throw new CoreException(new Status(IStatus.ERROR, IRuntimeConstants.PI_RUNTIME, IRuntimeConstants.FAILED_WRITE_METADATA, message, e));
- }
- if (!file.canWrite()) {
- String message = NLS.bind(CommonMessages.meta_readonly, file.getAbsolutePath());
- throw new CoreException(new Status(IStatus.ERROR, IRuntimeConstants.PI_RUNTIME, IRuntimeConstants.FAILED_WRITE_METADATA, message, null));
- }
- // set the log file location now that we created the data area
- IPath path = location.append(F_META_AREA).append(F_LOG);
- try {
- Activator activator = Activator.getDefault();
- if (activator != null) {
- FrameworkLog log = activator.getFrameworkLog();
- if (log != null)
- log.setFile(path.toFile(), true);
- else if (debug())
- System.out.println("ERROR: Unable to acquire log service. Application will proceed, but logging will be disabled.");
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- private boolean debug() {
- Activator activator = Activator.getDefault();
- if (activator == null)
- return false;
- DebugOptions debugOptions = activator.getDebugOptions();
- if (debugOptions == null)
- return false;
- return debugOptions.getBooleanOption(OPTION_DEBUG, false);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DevClassPathHelper.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DevClassPathHelper.java
deleted file mode 100644
index 43955a7df..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DevClassPathHelper.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-
-public class DevClassPathHelper {
-
- // command line options
- public static final String PROP_DEV = "osgi.dev"; //$NON-NLS-1$
-
- static protected boolean inDevelopmentMode = false;
- static protected String[] devDefaultClasspath;
- static protected Properties devProperties = null;
-
- static {
- // Check the osgi.dev property to see if dev classpath entries have been defined.
- String osgiDev = Activator.getContext() == null ? System.getProperty(PROP_DEV) : Activator.getContext().getProperty(PROP_DEV);
- if (osgiDev != null) {
- try {
- inDevelopmentMode = true;
- URL location = new URL(osgiDev);
- devProperties = load(location);
- if (devProperties != null)
- devDefaultClasspath = getArrayFromList(devProperties.getProperty("*")); //$NON-NLS-1$
- } catch (MalformedURLException e) {
- devDefaultClasspath = getArrayFromList(osgiDev);
- }
- }
- }
-
- public static String[] getDevClassPath(String id) {
- String[] result = null;
- if (id != null && devProperties != null) {
- String entry = devProperties.getProperty(id);
- if (entry != null)
- result = getArrayFromList(entry);
- }
- if (result == null)
- result = devDefaultClasspath;
- return result;
- }
-
- /**
- * Returns the result of converting a list of comma-separated tokens into an array
- *
- * @return the array of string tokens
- * @param prop the initial comma-separated string
- */
- public static String[] getArrayFromList(String prop) {
- if (prop == null || prop.trim().equals("")) //$NON-NLS-1$
- return new String[0];
- Vector list = new Vector();
- StringTokenizer tokens = new StringTokenizer(prop, ","); //$NON-NLS-1$
- while (tokens.hasMoreTokens()) {
- String token = tokens.nextToken().trim();
- if (!token.equals("")) //$NON-NLS-1$
- list.addElement(token);
- }
- return list.isEmpty() ? new String[0] : (String[]) list.toArray(new String[list.size()]);
- }
-
- public static boolean inDevelopmentMode() {
- return inDevelopmentMode;
- }
-
- /*
- * Load the given properties file
- */
- private static Properties load(URL url) {
- Properties props = new Properties();
- try {
- InputStream is = null;
- try {
- is = url.openStream();
- props.load(is);
- } finally {
- if (is != null)
- is.close();
- }
- } catch (IOException e) {
- // TODO consider logging here
- }
- return props;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java
deleted file mode 100644
index 60566a959..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Map;
-import org.eclipse.core.runtime.*;
-import org.osgi.framework.Bundle;
-
-// This class provides implements the find* methods exposed on Platform.
-// It does the lookup in bundles and fragments and does the variable replacement.
-// Can only be used if OSGi is available.
-public class FindSupport {
- // OSGI system properties
- public static final String PROP_NL = "osgi.nl"; //$NON-NLS-1$
- public static final String PROP_OS = "osgi.os"; //$NON-NLS-1$
- public static final String PROP_WS = "osgi.ws"; //$NON-NLS-1$
- public static final String PROP_ARCH = "osgi.arch"; //$NON-NLS-1$
-
- private static String[] NL_JAR_VARIANTS = buildNLVariants(Activator.getContext() == null ? System.getProperty(PROP_NL) : Activator.getContext().getProperty(PROP_NL));
-
- private static String[] buildNLVariants(String nl) {
- ArrayList result = new ArrayList();
- IPath base = new Path("nl"); //$NON-NLS-1$
-
- IPath path = new Path(nl.replace('_', '/'));
- while (path.segmentCount() > 0) {
- result.add(base.append(path).toString());
- // for backwards compatibility only, don't replace the slashes
- if (path.segmentCount() > 1)
- result.add(base.append(path.toString().replace('/', '_')).toString());
- path = path.removeLastSegments(1);
- }
-
- return (String[]) result.toArray(new String[result.size()]);
- }
-
- /**
- * See doc on {@link FileLocator#find(Bundle, IPath, Map)}
- */
- public static URL find(Bundle bundle, IPath path) {
- return find(bundle, path, null);
- }
-
- /**
- * See doc on {@link FileLocator#find(Bundle, IPath, Map)}
- */
- public static URL find(Bundle b, IPath path, Map override) {
- return find(b, path, override, null);
- }
-
- /**
- * See doc on {@link FileLocator#findEntries(Bundle, IPath)}
- */
- public static URL[] findEntries(Bundle bundle, IPath path) {
- return findEntries(bundle, path, null);
- }
-
- /**
- * See doc on {@link FileLocator#findEntries(Bundle, IPath, Map)}
- */
- public static URL[] findEntries(Bundle bundle, IPath path, Map override) {
- ArrayList results = new ArrayList(1);
- find(bundle, path, override, results);
- return (URL[]) results.toArray(new URL[results.size()]);
- }
-
- private static URL find(Bundle b, IPath path, Map override, ArrayList multiple) {
- if (path == null)
- return null;
-
- URL result = null;
-
- // Check for the empty or root case first
- if (path.isEmpty() || path.isRoot()) {
- // Watch for the root case. It will produce a new
- // URL which is only the root directory (and not the
- // root of this plugin).
- result = findInPlugin(b, Path.EMPTY, multiple);
- if (result == null || multiple != null)
- result = findInFragments(b, Path.EMPTY, multiple);
- return result;
- }
-
- // Now check for paths without variable substitution
- String first = path.segment(0);
- if (first.charAt(0) != '$') {
- result = findInPlugin(b, path, multiple);
- if (result == null || multiple != null)
- result = findInFragments(b, path, multiple);
- return result;
- }
-
- // Worry about variable substitution
- IPath rest = path.removeFirstSegments(1);
- if (first.equalsIgnoreCase("$nl$")) //$NON-NLS-1$
- return findNL(b, rest, override, multiple);
- if (first.equalsIgnoreCase("$os$")) //$NON-NLS-1$
- return findOS(b, rest, override, multiple);
- if (first.equalsIgnoreCase("$ws$")) //$NON-NLS-1$
- return findWS(b, rest, override, multiple);
- if (first.equalsIgnoreCase("$files$")) //$NON-NLS-1$
- return null;
-
- return null;
- }
-
- private static URL findOS(Bundle b, IPath path, Map override, ArrayList multiple) {
- String os = null;
- if (override != null)
- try {
- // check for override
- os = (String) override.get("$os$"); //$NON-NLS-1$
- } catch (ClassCastException e) {
- // just in case
- }
- if (os == null)
- // use default
- os = Activator.getContext().getProperty(PROP_OS);
- if (os.length() == 0)
- return null;
-
- // Now do the same for osarch
- String osArch = null;
- if (override != null)
- try {
- // check for override
- osArch = (String) override.get("$arch$"); //$NON-NLS-1$
- } catch (ClassCastException e) {
- // just in case
- }
- if (osArch == null)
- // use default
- osArch = Activator.getContext().getProperty(PROP_ARCH);
- if (osArch.length() == 0)
- return null;
-
- URL result = null;
- IPath base = new Path("os").append(os).append(osArch); //$NON-NLS-1$
- // Keep doing this until all you have left is "os" as a path
- while (base.segmentCount() != 1) {
- IPath filePath = base.append(path);
- result = findInPlugin(b, filePath, multiple);
- if (result != null && multiple == null)
- return result;
- result = findInFragments(b, filePath, multiple);
- if (result != null && multiple == null)
- return result;
- base = base.removeLastSegments(1);
- }
- // If we get to this point, we haven't found it yet.
- // Look in the plugin and fragment root directories
- result = findInPlugin(b, path, multiple);
- if (result != null && multiple == null)
- return result;
- return findInFragments(b, path, multiple);
- }
-
- private static URL findWS(Bundle b, IPath path, Map override, ArrayList multiple) {
- String ws = null;
- if (override != null)
- try {
- // check for override
- ws = (String) override.get("$ws$"); //$NON-NLS-1$
- } catch (ClassCastException e) {
- // just in case
- }
- if (ws == null)
- // use default
- ws = Activator.getContext().getProperty(PROP_WS);
- IPath filePath = new Path("ws").append(ws).append(path); //$NON-NLS-1$
- // We know that there is only one segment to the ws path
- // e.g. ws/win32
- URL result = findInPlugin(b, filePath, multiple);
- if (result != null && multiple == null)
- return result;
- result = findInFragments(b, filePath, multiple);
- if (result != null && multiple == null)
- return result;
- // If we get to this point, we haven't found it yet.
- // Look in the plugin and fragment root directories
- result = findInPlugin(b, path, multiple);
- if (result != null && multiple == null)
- return result;
- return findInFragments(b, path, multiple);
- }
-
- private static URL findNL(Bundle b, IPath path, Map override, ArrayList multiple) {
- String nl = null;
- String[] nlVariants = null;
- if (override != null)
- try {
- // check for override
- nl = (String) override.get("$nl$"); //$NON-NLS-1$
- } catch (ClassCastException e) {
- // just in case
- }
- nlVariants = nl == null ? NL_JAR_VARIANTS : buildNLVariants(nl);
- if (nl != null && nl.length() == 0)
- return null;
-
- URL result = null;
- for (int i = 0; i < nlVariants.length; i++) {
- IPath filePath = new Path(nlVariants[i]).append(path);
- result = findInPlugin(b, filePath, multiple);
- if (result != null && multiple == null)
- return result;
- result = findInFragments(b, filePath, multiple);
- if (result != null && multiple == null)
- return result;
- }
- // If we get to this point, we haven't found it yet.
- // Look in the plugin and fragment root directories
- result = findInPlugin(b, path, multiple);
- if (result != null && multiple == null)
- return result;
- return findInFragments(b, path, multiple);
- }
-
- private static URL findInPlugin(Bundle b, IPath filePath, ArrayList multiple) {
- URL result = b.getEntry(filePath.toString());
- if (result != null && multiple != null)
- multiple.add(result);
- return result;
- }
-
- private static URL findInFragments(Bundle b, IPath filePath, ArrayList multiple) {
- Activator activator = Activator.getDefault();
- if (activator == null)
- return null;
- Bundle[] fragments = activator.getFragments(b);
- if (fragments == null)
- return null;
-
- if (multiple != null)
- multiple.ensureCapacity(fragments.length + 1);
-
- for (int i = 0; i < fragments.length; i++) {
- URL fileURL = fragments[i].getEntry(filePath.toString());
- if (fileURL != null) {
- if (multiple == null)
- return fileURL;
- multiple.add(fileURL);
- }
- }
- return null;
- }
-
- /**
- * See doc on {@link FileLocator#openStream(Bundle, IPath, boolean)}
- */
- public static final InputStream openStream(Bundle bundle, IPath file, boolean substituteArgs) throws IOException {
- URL url = null;
- if (!substituteArgs) {
- url = findInPlugin(bundle, file, null);
- if (url == null)
- url = findInFragments(bundle, file, null);
- } else {
- url = FindSupport.find(bundle, file);
- }
- if (url != null)
- return url.openStream();
- throw new IOException("Cannot find " + file.toString()); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterFactoryExt.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterFactoryExt.java
deleted file mode 100644
index c4739803d..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterFactoryExt.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-
-/**
- * An internal interface that exposes portion of AdapterFactoryProxy functionality
- * without the need to import the class itself.
- */
-public interface IAdapterFactoryExt {
-
- /**
- * Loads the real adapter factory, but only if its associated plug-in is
- * already loaded. Returns the real factory if it was successfully loaded.
- * @param force if <code>true</code> the plugin providing the
- * factory will be loaded if necessary, otherwise no plugin activations
- * will occur.
- */
- public IAdapterFactory loadFactory(boolean force);
-
- public String[] getAdapterNames();
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterManagerProvider.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterManagerProvider.java
deleted file mode 100644
index d7077a269..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IAdapterManagerProvider.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-/**
- * The callback interface for the elements desiring to lazily supply
- * information to the adapter manager.
- *
- * @since org.eclipse.core.runtime 3.2
- */
-public interface IAdapterManagerProvider {
-
- /**
- * Add factories. The method called before the AdapterManager starts
- * using factories.
- *
- * @param adapterManager the adapter manager that is about to be used
- * @return <code>true</code> if factories were added; <code>false</code>
- * if no factories were added in this method call.
- */
- public boolean addFactories(AdapterManager adapterManager);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IRuntimeConstants.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IRuntimeConstants.java
deleted file mode 100644
index a9d74d19f..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/IRuntimeConstants.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-public interface IRuntimeConstants {
-
- /**
- * The unique identifier constant (value "<code>org.eclipse.core.runtime</code>")
- * of the Core Runtime (pseudo-) plug-in.
- */
- public static final String PI_RUNTIME = "org.eclipse.core.runtime"; //$NON-NLS-1$
-
- /**
- * Name of this bundle.
- */
- public static final String PI_COMMON = "org.eclipse.equinox.common"; //$NON-NLS-1$
-
- /**
- * Status code constant (value 2) indicating an error occurred while running a plug-in.
- */
- public static final int PLUGIN_ERROR = 2;
-
- /**
- * Status code constant (value 5) indicating the platform could not write
- * some of its metadata.
- */
- public static final int FAILED_WRITE_METADATA = 5;
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/LocalizationUtils.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/LocalizationUtils.java
deleted file mode 100644
index a679c7cc8..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/LocalizationUtils.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.lang.reflect.Field;
-
-/**
- * Helper methods related to string localization.
- *
- * @since org.eclipse.equinox.common 3.3
- */
-public class LocalizationUtils {
- /**
- * This method can be used in the absence of NLS class. The method tries to
- * use the NLS-based translation routine. If it falls, the method returns the original
- * non-translated key.
- *
- * @param key case-sensitive name of the filed in the translation file representing
- * the string to be translated
- * @return The localized message or the non-translated key
- */
- static public String safeLocalize(String key) {
- try {
- Class messageClass = Class.forName("org.eclipse.core.internal.runtime.CommonMessages"); //$NON-NLS-1$
- if (messageClass == null)
- return key;
- Field field = messageClass.getDeclaredField(key);
- if (field == null)
- return key;
- Object value = field.get(null);
- if (value instanceof String)
- return (String) value;
- } catch (ClassNotFoundException e) {
- // eat exception and fall through
- } catch (NoClassDefFoundError e) {
- // eat exception and fall through
- } catch (SecurityException e) {
- // eat exception and fall through
- } catch (NoSuchFieldException e) {
- // eat exception and fall through
- } catch (IllegalArgumentException e) {
- // eat exception and fall through
- } catch (IllegalAccessException e) {
- // eat exception and fall through
- }
- return key;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MetaDataKeeper.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MetaDataKeeper.java
deleted file mode 100644
index dac414a4c..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/MetaDataKeeper.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import org.eclipse.core.internal.runtime.DataArea;
-
-/**
- * The class contains a set of utilities working platform metadata area.
- * This class can only be used if OSGi plugin is available.
- *
- * Copied from InternalPlatform as of August 30, 2005.
- * @since org.eclipse.equinox.common 3.2
- */
-public class MetaDataKeeper {
-
- private static DataArea metaArea = null;
-
- /**
- * Returns the object which defines the location and organization
- * of the platform's meta area.
- */
- public static DataArea getMetaArea() {
- if (metaArea != null)
- return metaArea;
-
- metaArea = new DataArea();
- return metaArea;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLConfigConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLConfigConnection.java
deleted file mode 100644
index a42711cd1..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLConfigConnection.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.io.*;
-import java.net.URL;
-import java.net.UnknownServiceException;
-import org.eclipse.core.internal.boot.PlatformURLConnection;
-import org.eclipse.core.internal.boot.PlatformURLHandler;
-import org.eclipse.osgi.service.datalocation.Location;
-import org.eclipse.osgi.util.NLS;
-
-public class PlatformURLConfigConnection extends PlatformURLConnection {
- private static final String FILE_PROTOCOL = "file"; //$NON-NLS-1$
- private static boolean isRegistered = false;
- public static final String CONFIG = "config"; //$NON-NLS-1$
-
- private boolean parentConfiguration = false;
-
- /*
- * Constructor for the class.
- */
- public PlatformURLConfigConnection(URL url) {
- super(url);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.url.PlatformURLConnection#resolve()
- */
- protected URL resolve() throws IOException {
- String spec = url.getFile().trim();
- if (spec.startsWith("/")) //$NON-NLS-1$
- spec = spec.substring(1);
- if (!spec.startsWith(CONFIG))
- throw new IOException(NLS.bind(CommonMessages.url_badVariant, url.toString()));
- String path = spec.substring(CONFIG.length() + 1);
- // resolution takes parent configuration into account (if it exists)
- Activator activator = Activator.getDefault();
- if (activator == null)
- throw new IOException(CommonMessages.activator_not_available);
- Location localConfig = activator.getConfigurationLocation();
- Location parentConfig = localConfig.getParentLocation();
- // assume we will find the file locally
- URL localURL = new URL(localConfig.getURL(), path);
- if (!FILE_PROTOCOL.equals(localURL.getProtocol()) || parentConfig == null)
- // we only support cascaded file: URLs
- return localURL;
- File localFile = new File(localURL.getPath());
- if (localFile.exists())
- // file exists in local configuration
- return localURL;
- // try to find in the parent configuration
- URL parentURL = new URL(parentConfig.getURL(), path);
- if (FILE_PROTOCOL.equals(parentURL.getProtocol())) {
- // we only support cascaded file: URLs
- File parentFile = new File(parentURL.getPath());
- if (parentFile.exists()) {
- // parent has the location
- parentConfiguration = true;
- return parentURL;
- }
- }
- return localURL;
- }
-
- public static void startup() {
- // register connection type for platform:/config handling
- if (isRegistered)
- return;
- PlatformURLHandler.register(CONFIG, PlatformURLConfigConnection.class);
- isRegistered = true;
- }
-
- /* (non-Javadoc)
- * @see java.net.URLConnection#getOutputStream()
- */
- public OutputStream getOutputStream() throws IOException {
- if (parentConfiguration || Activator.getDefault() == null || Activator.getDefault().getConfigurationLocation().isReadOnly())
- throw new UnknownServiceException(NLS.bind(CommonMessages.url_noOutput, url));
- //This is not optimal but connection is a private instance variable in the super-class.
- URL resolved = getResolvedURL();
- if (resolved != null) {
- String fileString = resolved.getFile();
- if (fileString != null) {
- File file = new File(fileString);
- String parent = file.getParent();
- if (parent != null)
- new File(parent).mkdirs();
- return new FileOutputStream(file);
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLConverter.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLConverter.java
deleted file mode 100644
index e486568df..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLConverter.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-import org.eclipse.core.internal.boot.PlatformURLConnection;
-import org.eclipse.core.internal.boot.PlatformURLHandler;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.osgi.service.urlconversion.URLConverter;
-
-/**
- * Class which implements the URLConverter service. Manages conversion of a
- * platform: URL to one with a more well known protocol.
- *
- * @since 3.2
- */
-public class PlatformURLConverter implements URLConverter {
-
- /* (non-Javadoc)
- * @see org.eclipse.osgi.service.urlconversion.URLConverter#toFileURL(java.net.URL)
- */
- public URL toFileURL(URL url) throws IOException {
- URLConnection connection = url.openConnection();
- if (!(connection instanceof PlatformURLConnection))
- return url;
- URL result = ((PlatformURLConnection) connection).getURLAsLocal();
- // if we have a bundle*: URL we should try to convert it
- if (!result.getProtocol().startsWith(PlatformURLHandler.BUNDLE))
- return result;
- return FileLocator.toFileURL(result);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.osgi.service.urlconversion.URLConverter#resolve(java.net.URL)
- */
- public URL resolve(URL url) throws IOException {
- URLConnection connection = url.openConnection();
- if (!(connection instanceof PlatformURLConnection))
- return url;
- URL result = ((PlatformURLConnection) connection).getResolvedURL();
- // if we have a bundle*: URL we should try to convert it
- if (!result.getProtocol().startsWith(PlatformURLHandler.BUNDLE))
- return result;
- return FileLocator.resolve(result);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLFragmentConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLFragmentConnection.java
deleted file mode 100644
index de3053c41..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLFragmentConnection.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.io.IOException;
-import java.net.URL;
-import org.eclipse.core.internal.boot.PlatformURLConnection;
-import org.eclipse.core.internal.boot.PlatformURLHandler;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Bundle;
-
-/**
- * Platform URL support
- * platform:/fragment/fragmentId/ maps to fragmentDescriptor.getInstallURLInternal()
- */
-public class PlatformURLFragmentConnection extends PlatformURLConnection {
-
- private Bundle target = null;
- private static boolean isRegistered = false;
- public static final String FRAGMENT = "fragment"; //$NON-NLS-1$
-
- /*
- * Constructor for the class.
- */
- public PlatformURLFragmentConnection(URL url) {
- super(url);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.url.PlatformURLConnection#allowCaching()
- */
- protected boolean allowCaching() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.url.PlatformURLConnection#resolve()
- */
- protected URL resolve() throws IOException {
- String spec = url.getFile().trim();
- if (spec.startsWith("/")) //$NON-NLS-1$
- spec = spec.substring(1);
- if (!spec.startsWith(FRAGMENT))
- throw new IOException(NLS.bind(CommonMessages.url_badVariant, url));
- int ix = spec.indexOf("/", FRAGMENT.length() + 1); //$NON-NLS-1$
- String ref = ix == -1 ? spec.substring(FRAGMENT.length() + 1) : spec.substring(FRAGMENT.length() + 1, ix);
- String id = getId(ref);
- Activator activator = Activator.getDefault();
- if (activator == null)
- throw new IOException(CommonMessages.activator_not_available);
- target = activator.getBundle(id);
- if (target == null)
- throw new IOException(NLS.bind(CommonMessages.url_resolveFragment, url));
- URL result = target.getEntry("/"); //$NON-NLS-1$
- if (ix == -1 || (ix + 1) >= spec.length())
- return result;
- return new URL(result, spec.substring(ix + 1));
- }
-
- public static void startup() {
- // register connection type for platform:/fragment handling
- if (isRegistered)
- return;
- PlatformURLHandler.register(FRAGMENT, PlatformURLFragmentConnection.class);
- isRegistered = true;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLMetaConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLMetaConnection.java
deleted file mode 100644
index 7ebad2198..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLMetaConnection.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.io.*;
-import java.net.URL;
-import org.eclipse.core.internal.boot.PlatformURLConnection;
-import org.eclipse.core.internal.boot.PlatformURLHandler;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Bundle;
-
-public class PlatformURLMetaConnection extends PlatformURLConnection {
- private Bundle target = null;
- private static boolean isRegistered = false;
- public static final String META = "meta"; //$NON-NLS-1$
-
- /*
- * Constructor for the class.
- */
- public PlatformURLMetaConnection(URL url) {
- super(url);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.url.PlatformURLConnection#resolve()
- */
- protected URL resolve() throws IOException {
- String spec = url.getFile().trim();
- if (spec.startsWith("/")) //$NON-NLS-1$
- spec = spec.substring(1);
- if (!spec.startsWith(META))
- throw new IOException(NLS.bind(CommonMessages.url_badVariant, url.toString()));
- int ix = spec.indexOf("/", META.length() + 1); //$NON-NLS-1$
- String ref = ix == -1 ? spec.substring(META.length() + 1) : spec.substring(META.length() + 1, ix);
- String id = getId(ref);
- Activator activator = Activator.getDefault();
- if (activator == null)
- throw new IOException(CommonMessages.activator_not_available);
- target = activator.getBundle(id);
- if (target == null)
- throw new IOException(NLS.bind(CommonMessages.url_resolvePlugin, url.toString()));
- IPath path = MetaDataKeeper.getMetaArea().getStateLocation(target);
- if (ix != -1 || (ix + 1) <= spec.length())
- path = path.append(spec.substring(ix + 1));
- return path.toFile().toURL();
- }
-
- public static void startup() {
- // register connection type for platform:/meta handling
- if (isRegistered)
- return;
- PlatformURLHandler.register(META, PlatformURLMetaConnection.class);
- isRegistered = true;
- }
-
- /* (non-Javadoc)
- * @see java.net.URLConnection#getOutputStream()
- */
- public OutputStream getOutputStream() throws IOException {
- //This is not optimal but connection is a private instance variable in super.
- URL resolved = getResolvedURL();
- if (resolved != null) {
- String fileString = resolved.getFile();
- if (fileString != null) {
- File file = new File(fileString);
- String parent = file.getParent();
- if (parent != null)
- new File(parent).mkdirs();
- return new FileOutputStream(file);
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLPluginConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLPluginConnection.java
deleted file mode 100644
index ccb56865f..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLPluginConnection.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.io.IOException;
-import java.net.URL;
-import org.eclipse.core.internal.boot.PlatformURLConnection;
-import org.eclipse.core.internal.boot.PlatformURLHandler;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Bundle;
-
-/**
- * Platform URL support
- * platform:/plugin/pluginId/ maps to pluginDescriptor.getInstallURLInternal()
- */
-public class PlatformURLPluginConnection extends PlatformURLConnection {
-
- private Bundle target = null;
- private static boolean isRegistered = false;
- public static final String PLUGIN = "plugin"; //$NON-NLS-1$
-
- /*
- * Constructor for the class.
- */
- public PlatformURLPluginConnection(URL url) {
- super(url);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.url.PlatformURLConnection#allowCaching()
- */
- protected boolean allowCaching() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.url.PlatformURLConnection#resolve()
- */
- protected URL resolve() throws IOException {
- String spec = url.getFile().trim();
- if (spec.startsWith("/")) //$NON-NLS-1$
- spec = spec.substring(1);
- if (!spec.startsWith(PLUGIN))
- throw new IOException(NLS.bind(CommonMessages.url_badVariant, url));
- int ix = spec.indexOf("/", PLUGIN.length() + 1); //$NON-NLS-1$
- String ref = ix == -1 ? spec.substring(PLUGIN.length() + 1) : spec.substring(PLUGIN.length() + 1, ix);
- String id = getId(ref);
- Activator activator = Activator.getDefault();
- if (activator == null)
- throw new IOException(CommonMessages.activator_not_available);
- target = activator.getBundle(id);
- if (target == null)
- throw new IOException(NLS.bind(CommonMessages.url_resolvePlugin, url));
- if (ix == -1 || (ix + 1) >= spec.length())
- return target.getEntry("/"); //$NON-NLS-1$
- URL result = target.getEntry(spec.substring(ix + 1));
- if (result != null)
- return result;
- // if the result is null then force the creation of a URL that will throw FileNotFoundExceptions
- return new URL(target.getEntry("/"), spec.substring(ix + 1)); //$NON-NLS-1$
-
- }
-
- public static void startup() {
- // register connection type for platform:/plugin handling
- if (isRegistered)
- return;
- PlatformURLHandler.register(PLUGIN, PlatformURLPluginConnection.class);
- isRegistered = true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.url.PlatformURLConnection#getAuxillaryURLs()
- */
- public URL[] getAuxillaryURLs() throws IOException {
- if (target == null) {
- String spec = url.getFile().trim();
- if (spec.startsWith("/")) //$NON-NLS-1$
- spec = spec.substring(1);
- if (!spec.startsWith(PLUGIN))
- throw new IOException(NLS.bind(CommonMessages.url_badVariant, url));
- int ix = spec.indexOf("/", PLUGIN.length() + 1); //$NON-NLS-1$
- String ref = ix == -1 ? spec.substring(PLUGIN.length() + 1) : spec.substring(PLUGIN.length() + 1, ix);
- String id = getId(ref);
- Activator activator = Activator.getDefault();
- if (activator == null)
- throw new IOException(CommonMessages.activator_not_available);
- target = activator.getBundle(id);
- if (target == null)
- throw new IOException(NLS.bind(CommonMessages.url_resolvePlugin, url));
- }
- Bundle[] fragments = Activator.getDefault().getFragments(target);
- int fragmentLength = (fragments == null) ? 0 : fragments.length;
- if (fragmentLength == 0)
- return null;
- URL[] result = new URL[fragmentLength];
- for (int i = 0; i < fragmentLength; i++)
- result[i] = fragments[i].getEntry("/"); //$NON-NLS-1$
- return result;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java
deleted file mode 100644
index 05887f8f8..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ReferenceHashSet.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.lang.ref.*;
-
-/**
- * A hashset whose values can be garbage collected.
- * This API is EXPERIMENTAL and provided as early access.
- * @since 3.1
- */
-public class ReferenceHashSet {
-
- private interface HashedReference {
- int hashCode();
-
- Object get();
- }
-
- private class HashableWeakReference extends WeakReference implements HashedReference {
- public int hashCode;
-
- public HashableWeakReference(Object referent, ReferenceQueue queue) {
- super(referent, queue);
- this.hashCode = referent.hashCode();
- }
-
- public boolean equals(Object obj) {
- if (!(obj instanceof HashableWeakReference))
- return false;
- Object referent = super.get();
- Object other = ((HashableWeakReference) obj).get();
- if (referent == null)
- return other == null;
- return referent.equals(other);
- }
-
- public int hashCode() {
- return this.hashCode;
- }
-
- public String toString() {
- Object referent = super.get();
- if (referent == null)
- return "[hashCode=" + this.hashCode + "] <referent was garbage collected>"; //$NON-NLS-1$ //$NON-NLS-2$
- return "[hashCode=" + this.hashCode + "] " + referent.toString(); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- private class HashableSoftReference extends SoftReference implements HashedReference {
- public int hashCode;
-
- public HashableSoftReference(Object referent, ReferenceQueue queue) {
- super(referent, queue);
- this.hashCode = referent.hashCode();
- }
-
- public boolean equals(Object obj) {
- if (!(obj instanceof HashableWeakReference))
- return false;
- Object referent = super.get();
- Object other = ((HashableWeakReference) obj).get();
- if (referent == null)
- return other == null;
- return referent.equals(other);
- }
-
- public int hashCode() {
- return this.hashCode;
- }
-
- public String toString() {
- Object referent = super.get();
- if (referent == null)
- return "[hashCode=" + this.hashCode + "] <referent was garbage collected>"; //$NON-NLS-1$ //$NON-NLS-2$
- return "[hashCode=" + this.hashCode + "] " + referent.toString(); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- private class StrongReference implements HashedReference {
- private Object referent;
-
- public StrongReference(Object referent, ReferenceQueue queue) {
- this.referent = referent;
- }
-
- public int hashCode() {
- return referent.hashCode();
- }
-
- public Object get() {
- return referent;
- }
-
- public boolean equals(Object obj) {
- return referent.equals(obj);
- }
- }
-
- HashedReference[] values;
-
- public int elementSize; // number of elements in the table
-
- int threshold;
-
- ReferenceQueue referenceQueue = new ReferenceQueue();
-
- public ReferenceHashSet() {
- this(5);
- }
-
- public ReferenceHashSet(int size) {
- this.elementSize = 0;
- this.threshold = size; // size represents the expected
- // number of elements
- int extraRoom = (int) (size * 1.75f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.values = new HashedReference[extraRoom];
- }
-
- /**
- * Constant indicating that hard references should be used.
- */
- final public static int HARD = 0;
-
- /**
- * Constant indiciating that soft references should be used.
- */
- final public static int SOFT = 1;
-
- /**
- * Constant indicating that weak references should be used.
- */
- final public static int WEAK = 2;
-
- private HashedReference toReference(int type, Object referent) {
- switch (type) {
- case HARD :
- return new StrongReference(referent, referenceQueue);
- case SOFT :
- return new HashableSoftReference(referent, referenceQueue);
- case WEAK :
- return new HashableWeakReference(referent, referenceQueue);
- default :
- throw new Error();
- }
- }
-
- /*
- * Adds the given object to this set. If an object that is equals to the
- * given object already exists, do nothing. Returns the existing object or
- * the new object if not found.
- */
- public Object add(Object obj, int referenceType) {
- cleanupGarbageCollectedValues();
- int index = (obj.hashCode() & 0x7FFFFFFF) % this.values.length;
- HashedReference currentValue;
- while ((currentValue = this.values[index]) != null) {
- Object referent;
- if (obj.equals(referent = currentValue.get())) {
- return referent;
- }
- index = (index + 1) % this.values.length;
- }
- this.values[index] = toReference(referenceType, obj);
-
- // assumes the threshold is never equal to the size of the table
- if (++this.elementSize > this.threshold)
- rehash();
-
- return obj;
- }
-
- private void addValue(HashedReference value) {
- Object obj = value.get();
- if (obj == null)
- return;
- int valuesLength = this.values.length;
- int index = (value.hashCode() & 0x7FFFFFFF) % valuesLength;
- HashedReference currentValue;
- while ((currentValue = this.values[index]) != null) {
- if (obj.equals(currentValue.get())) {
- return;
- }
- index = (index + 1) % valuesLength;
- }
- this.values[index] = value;
-
- // assumes the threshold is never equal to the size of the table
- if (++this.elementSize > this.threshold)
- rehash();
- }
-
- private void cleanupGarbageCollectedValues() {
- HashedReference toBeRemoved;
- while ((toBeRemoved = (HashedReference) this.referenceQueue.poll()) != null) {
- int hashCode = toBeRemoved.hashCode();
- int valuesLength = this.values.length;
- int index = (hashCode & 0x7FFFFFFF) % valuesLength;
- HashedReference currentValue;
- while ((currentValue = this.values[index]) != null) {
- if (currentValue == toBeRemoved) {
- // replace the value at index with the last value with the
- // same hash
- int sameHash = index;
- int current;
- while ((currentValue = this.values[current = (sameHash + 1) % valuesLength]) != null && currentValue.hashCode() == hashCode)
- sameHash = current;
- this.values[index] = this.values[sameHash];
- this.values[sameHash] = null;
- this.elementSize--;
- break;
- }
- index = (index + 1) % valuesLength;
- }
- }
- }
-
- public boolean contains(Object obj) {
- return get(obj) != null;
- }
-
- /*
- * Return the object that is in this set and that is equals to the given
- * object. Return null if not found.
- */
- public Object get(Object obj) {
- cleanupGarbageCollectedValues();
- int valuesLength = this.values.length;
- int index = (obj.hashCode() & 0x7FFFFFFF) % valuesLength;
- HashedReference currentValue;
- while ((currentValue = this.values[index]) != null) {
- Object referent;
- if (obj.equals(referent = currentValue.get())) {
- return referent;
- }
- index = (index + 1) % valuesLength;
- }
- return null;
- }
-
- private void rehash() {
- ReferenceHashSet newHashSet = new ReferenceHashSet(this.elementSize * 2); // double the number of expected elements
- newHashSet.referenceQueue = this.referenceQueue;
- HashedReference currentValue;
- for (int i = 0, length = this.values.length; i < length; i++)
- if ((currentValue = this.values[i]) != null)
- newHashSet.addValue(currentValue);
-
- this.values = newHashSet.values;
- this.threshold = newHashSet.threshold;
- this.elementSize = newHashSet.elementSize;
- }
-
- /*
- * Removes the object that is in this set and that is equals to the given
- * object. Return the object that was in the set, or null if not found.
- */
- public Object remove(Object obj) {
- cleanupGarbageCollectedValues();
- int valuesLength = this.values.length;
- int index = (obj.hashCode() & 0x7FFFFFFF) % valuesLength;
- HashedReference currentValue;
- while ((currentValue = this.values[index]) != null) {
- Object referent;
- if (obj.equals(referent = currentValue.get())) {
- this.elementSize--;
- this.values[index] = null;
- rehash();
- return referent;
- }
- index = (index + 1) % valuesLength;
- }
- return null;
- }
-
- public int size() {
- return this.elementSize;
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer("{"); //$NON-NLS-1$
- for (int i = 0, length = this.values.length; i < length; i++) {
- HashedReference value = this.values[i];
- if (value != null) {
- Object ref = value.get();
- if (ref != null) {
- buffer.append(ref.toString());
- buffer.append(", "); //$NON-NLS-1$
- }
- }
- }
- buffer.append("}"); //$NON-NLS-1$
- return buffer.toString();
- }
-
- public Object[] toArray() {
- cleanupGarbageCollectedValues();
- Object[] result = new Object[elementSize];
- int resultSize = 0;
- for (int i = 0; i < values.length; i++) {
- if (values[i] == null)
- continue;
- Object tmp = values[i].get();
- if (tmp != null)
- result[resultSize++] = tmp;
- }
- if (result.length == resultSize)
- return result;
- Object[] finalResult = new Object[resultSize];
- System.arraycopy(result, 0, finalResult, 0, resultSize);
- return finalResult;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java
deleted file mode 100644
index 38002a658..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.*;
-import org.eclipse.osgi.util.ManifestElement;
-import org.osgi.framework.*;
-
-/**
- * This class can only be used if OSGi plugin is available.
- */
-public class ResourceTranslator {
- private static final String KEY_PREFIX = "%"; //$NON-NLS-1$
- private static final String KEY_DOUBLE_PREFIX = "%%"; //$NON-NLS-1$
-
- public static String getResourceString(Bundle bundle, String value) {
- return getResourceString(bundle, value, null);
- }
-
- public static String getResourceString(Bundle bundle, String value, ResourceBundle resourceBundle) {
- String s = value.trim();
- if (!s.startsWith(KEY_PREFIX, 0))
- return s;
- if (s.startsWith(KEY_DOUBLE_PREFIX, 0))
- return s.substring(1);
-
- int ix = s.indexOf(' ');
- String key = ix == -1 ? s : s.substring(0, ix);
- String dflt = ix == -1 ? s : s.substring(ix + 1);
-
- if (resourceBundle == null && bundle != null) {
- try {
- resourceBundle = getResourceBundle(bundle);
- } catch (MissingResourceException e) {
- // just return the default (dflt)
- }
- }
-
- if (resourceBundle == null)
- return dflt;
-
- try {
- return resourceBundle.getString(key.substring(1));
- } catch (MissingResourceException e) {
- //this will avoid requiring a bundle access on the next lookup
- return dflt;
- }
- }
-
- public static ResourceBundle getResourceBundle(Bundle bundle) throws MissingResourceException {
- if (hasRuntime21(bundle))
- return ResourceBundle.getBundle("plugin", Locale.getDefault(), createTempClassloader(bundle)); //$NON-NLS-1$
- return Activator.getDefault().getLocalization(bundle, null);
- }
-
- private static boolean hasRuntime21(Bundle b) {
- try {
- ManifestElement[] prereqs = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, (String) b.getHeaders("").get(Constants.REQUIRE_BUNDLE)); //$NON-NLS-1$
- if (prereqs == null)
- return false;
- for (int i = 0; i < prereqs.length; i++) {
- if ("2.1".equals(prereqs[i].getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE)) && "org.eclipse.core.runtime".equals(prereqs[i].getValue())) { //$NON-NLS-1$//$NON-NLS-2$
- return true;
- }
- }
- } catch (BundleException e) {
- return false;
- }
- return false;
- }
-
- private static ClassLoader createTempClassloader(Bundle b) {
- ArrayList classpath = new ArrayList();
- addClasspathEntries(b, classpath);
- addBundleRoot(b, classpath);
- addDevEntries(b, classpath);
- addFragments(b, classpath);
- URL[] urls = new URL[classpath.size()];
- return new URLClassLoader((URL[]) classpath.toArray(urls));
- }
-
- private static void addFragments(Bundle host, ArrayList classpath) {
- Activator activator = Activator.getDefault();
- if (activator == null)
- return;
- Bundle[] fragments = activator.getFragments(host);
- if (fragments == null)
- return;
-
- for (int i = 0; i < fragments.length; i++) {
- addClasspathEntries(fragments[i], classpath);
- addDevEntries(fragments[i], classpath);
- }
- }
-
- private static void addClasspathEntries(Bundle b, ArrayList classpath) {
- ManifestElement[] classpathElements;
- try {
- classpathElements = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, (String) b.getHeaders("").get(Constants.BUNDLE_CLASSPATH)); //$NON-NLS-1$
- if (classpathElements == null)
- return;
- for (int i = 0; i < classpathElements.length; i++) {
- URL classpathEntry = b.getEntry(classpathElements[i].getValue());
- if (classpathEntry != null)
- classpath.add(classpathEntry);
- }
- } catch (BundleException e) {
- //ignore
- }
- }
-
- private static void addBundleRoot(Bundle b, ArrayList classpath) {
- classpath.add(b.getEntry("/")); //$NON-NLS-1$
- }
-
- private static void addDevEntries(Bundle b, ArrayList classpath) {
- if (!DevClassPathHelper.inDevelopmentMode())
- return;
-
- String[] binaryPaths = DevClassPathHelper.getDevClassPath(b.getSymbolicName());
- for (int i = 0; i < binaryPaths.length; i++) {
- URL classpathEntry = b.getEntry(binaryPaths[i]);
- if (classpathEntry != null)
- classpath.add(classpathEntry);
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java
deleted file mode 100644
index c8ee9ea02..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- * Julian Chen - fix for bug #92572, jclRM
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import org.eclipse.core.runtime.*;
-
-/**
- * NOT API!!! This log infrastructure was split from the InternalPlatform.
- *
- * @since org.eclipse.equinox.common 3.2
- */
-// XXX this must be removed and replaced with something more reasonable
-public final class RuntimeLog {
-
- private static ArrayList logListeners = new ArrayList(5);
-
- /**
- * Keep the messages until the first log listener is registered.
- * Once first log listeners is registred, it is going to receive
- * all status messages accumulated during the period when no log
- * listener was available.
- */
- private static ArrayList queuedMessages = new ArrayList(5);
-
- /**
- * See org.eclipse.core.runtime.Platform#addLogListener(ILogListener)
- */
- public static void addLogListener(ILogListener listener) {
- synchronized (logListeners) {
- boolean firstListener = (logListeners.size() == 0);
- // replace if already exists (Set behaviour but we use an array
- // since we want to retain order)
- logListeners.remove(listener);
- logListeners.add(listener);
- if (firstListener) {
- for (Iterator i = queuedMessages.iterator(); i.hasNext();) {
- try {
- IStatus recordedMessage = (IStatus) i.next();
- listener.logging(recordedMessage, IRuntimeConstants.PI_RUNTIME);
- } catch (Exception e) {
- handleException(e);
- } catch (LinkageError e) {
- handleException(e);
- }
- }
- queuedMessages.clear();
- }
- }
- }
-
- /**
- * See org.eclipse.core.runtime.Platform#removeLogListener(ILogListener)
- */
- public static void removeLogListener(ILogListener listener) {
- synchronized (logListeners) {
- logListeners.remove(listener);
- }
- }
-
- /**
- * Checks if the given listener is present
- */
- public static boolean contains(ILogListener listener) {
- synchronized (logListeners) {
- return logListeners.contains(listener);
- }
- }
-
- /**
- * Notifies all listeners of the platform log.
- */
- public static void log(final IStatus status) {
- // create array to avoid concurrent access
- ILogListener[] listeners;
- synchronized (logListeners) {
- listeners = (ILogListener[]) logListeners.toArray(new ILogListener[logListeners.size()]);
- if (listeners.length == 0) {
- queuedMessages.add(status);
- return;
- }
- }
- for (int i = 0; i < listeners.length; i++) {
- try {
- listeners[i].logging(status, IRuntimeConstants.PI_RUNTIME);
- } catch (Exception e) {
- handleException(e);
- } catch (LinkageError e) {
- handleException(e);
- }
- }
- }
-
- private static void handleException(Throwable e) {
- if (!(e instanceof OperationCanceledException)) {
- // Got a error while logging. Don't try to log again, just put it into stderr
- e.printStackTrace();
- }
- }
-
- /**
- * Helps determine if any listeners are registered with the logging mechanism.
- * @return true if no listeners are registered
- */
- public static boolean isEmpty() {
- synchronized (logListeners) {
- return (logListeners.size() == 0);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/commonMessages.properties b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/commonMessages.properties
deleted file mode 100644
index 5faef9316..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/commonMessages.properties
+++ /dev/null
@@ -1,46 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2006 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-### Common runtime plugin messages
-
-ok = OK
-
-### metadata
-meta_couldNotCreate = Error trying to create the platform metadata area: {0}.
-meta_instanceDataUnspecified = The instance data location has not been specified yet.
-meta_noDataModeSpecified = No instance data can be specified.
-meta_notDir = Specified platform location \"{0}\" is not a directory.
-meta_readonly = The platform metadata area could not be written: {0}. By default the platform writes its content\nunder the current working directory when the platform is launched. Use the -data parameter to\nspecify a different content area for the platform.
-meta_pluginProblems = Problems occurred when invoking code from plug-in: \"{0}\".
-
-### parsing/resolve
-parse_doubleSeparatorVersion=Plug-in version identifier, \"{0}\", must not contain two consecutive separator characters.
-parse_emptyPluginVersion=A plug-in version identifier must be non-empty.
-parse_fourElementPluginVersion=Plug-in version identifier, \"{0}\", can contain a maximum of four components.
-parse_numericMajorComponent=The major (1st) component of plug-in version identifier, \"{0}\", must be numeric.
-parse_numericMinorComponent=The minor (2nd) component of plug-in version identifier, \"{0}\", must be numeric.
-parse_numericServiceComponent=The service (3rd) component of plug-in version identifier, \"{0}\", must be numeric.
-parse_oneElementPluginVersion=Plug-in version identifier, \"{0}\", must contain at least one component.
-parse_postiveMajor=Plug-in version identifier, \"{0}\", must have a positive major (1st) component.
-parse_postiveMinor=Plug-in version identifier, \"{0}\", must have a positive minor (2nd) component.
-parse_postiveService=Plug-in version identifier, \"{0}\", must have a positive service (3rd) component.
-parse_separatorEndVersion=Plug-in version identifier, \"{0}\", must not end with a separator character.
-parse_separatorStartVersion=Plug-in version identifier, \"{0}\", must not start with a separator character.
-
-### URL
-url_badVariant = Unsupported \"platform:\" protocol variation \"{0}\".
-url_createConnection = Unable to create connection on \"{0}\".
-url_invalidURL = Invalid URL \"{0}\".
-url_noOutput = Output is not supported for \"{0}\", location is read-only.
-url_noaccess = Unhandled URL protocol \"{0}\".
-url_resolveFragment = Unable to resolve fragment \"{0}\".
-url_resolvePlugin = Unable to resolve plug-in \"{0}\".
-
-activator_not_available = The bundle activator for the org.eclipse.equinox.common bundle is not available.
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/package.html b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/package.html
deleted file mode 100644
index 0898ea239..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides core support for the runtime.
-<h2>
-Package Specification</h2>
-This package contains some classes that require OSGi presence. If OSGi plugin is not present in
-the platform, class loader errors will be raised if those classes get activated. The classes are:
-<UL>
-<LI>FindSupport
-<LI>DataArea
-<LI>MetaDataKeeper
-<LI>ResourceTranslator
-<LI>CommonRuntimeBundle
-<LI>CommonOSGiUtils
-</UL>
-
-
-</body>
-</html>
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.java
deleted file mode 100644
index d6547de81..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * <code>Assert</code> is useful for for embedding runtime sanity checks
- * in code. The predicate methods all test a condition and throw some
- * type of unchecked exception if the condition does not hold.
- * <p>
- * Assertion failure exceptions, like most runtime exceptions, are
- * thrown when something is misbehaving. Assertion failures are invariably
- * unspecified behavior; consequently, clients should never rely on
- * these being thrown (and certainly should not being catching them
- * specifically).
- * </p><p>
- * This class can be used without OSGi running.
- * </p><p>
- * This class is not intended to be instantiated or sub-classed by clients.
- * </p>
- * @since org.eclipse.equinox.common 3.2
- */
-public final class Assert {
- /* This class is not intended to be instantiated. */
- private Assert() {
- // not allowed
- }
-
- /** Asserts that an argument is legal. If the given boolean is
- * not <code>true</code>, an <code>IllegalArgumentException</code>
- * is thrown.
- *
- * @param expression the outcode of the check
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- * @exception IllegalArgumentException if the legality test failed
- */
- public static boolean isLegal(boolean expression) {
- return isLegal(expression, ""); //$NON-NLS-1$
- }
-
- /** Asserts that an argument is legal. If the given boolean is
- * not <code>true</code>, an <code>IllegalArgumentException</code>
- * is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param expression the outcode of the check
- * @param message the message to include in the exception
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- * @exception IllegalArgumentException if the legality test failed
- */
- public static boolean isLegal(boolean expression, String message) {
- if (!expression)
- throw new IllegalArgumentException(message);
- return expression;
- }
-
- /** Asserts that the given object is not <code>null</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- *
- * @param object the value to test
- */
- public static void isNotNull(Object object) {
- isNotNull(object, ""); //$NON-NLS-1$
- }
-
- /** Asserts that the given object is not <code>null</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param object the value to test
- * @param message the message to include in the exception
- */
- public static void isNotNull(Object object, String message) {
- if (object == null)
- throw new AssertionFailedException("null argument:" + message); //$NON-NLS-1$
- }
-
- /** Asserts that the given boolean is <code>true</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- *
- * @param expression the outcode of the check
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- */
- public static boolean isTrue(boolean expression) {
- return isTrue(expression, ""); //$NON-NLS-1$
- }
-
- /** Asserts that the given boolean is <code>true</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param expression the outcode of the check
- * @param message the message to include in the exception
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- */
- public static boolean isTrue(boolean expression, String message) {
- if (!expression)
- throw new AssertionFailedException("assertion failed: " + message); //$NON-NLS-1$
- return expression;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AssertionFailedException.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AssertionFailedException.java
deleted file mode 100644
index cb561c181..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AssertionFailedException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * <code>AssertionFailedException</code> is a runtime exception thrown
- * by some of the methods in <code>Assert</code>.
- * <p>
- * This class can be used without OSGi running.
- * </p><p>
- * This class is not intended to be instantiated or sub-classed by clients.
- * </p>
- * @see Assert
- * @since org.eclipse.equinox.common 3.2
- */
-public class AssertionFailedException extends RuntimeException {
-
- /**
- * All serializable objects should have a stable serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructs a new exception with the given message.
- *
- * @param detail the message
- */
- public AssertionFailedException(String detail) {
- super(detail);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/CoreException.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/CoreException.java
deleted file mode 100644
index 614ccceca..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/CoreException.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
-/**
- * A checked exception representing a failure.
- * <p>
- * Core exceptions contain a status object describing the
- * cause of the exception.
- * </p><p>
- * This class can be used without OSGi running.
- * </p>
- * @see IStatus
- */
-public class CoreException extends Exception {
-
- /**
- * All serializable objects should have a stable serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- /** Status object. */
- private IStatus status;
-
- /**
- * Creates a new exception with the given status object. The message
- * of the given status is used as the exception message.
- *
- * @param status the status object to be associated with this exception
- */
- public CoreException(IStatus status) {
- super(status.getMessage());
- this.status = status;
- }
-
- /**
- * Returns the status object for this exception.
- * <p>
- * <b>IMPORTANT:</b><br>
- * The result must NOT be used to log a <code>CoreException</code>
- * (e.g., using <code>yourPlugin.getLog().log(status);</code>),
- * since that code pattern hides the original stacktrace.
- * Instead, create a new {@link Status} with your plug-in ID and
- * this <code>CoreException</code>, and log that new status.
- * </p>
- *
- * @return a status object
- */
- public final IStatus getStatus() {
- return status;
- }
-
- /**
- * Prints a stack trace out for the exception, and
- * any nested exception that it may have embedded in
- * its Status object.
- */
- public void printStackTrace() {
- printStackTrace(System.err);
- }
-
- /**
- * Prints a stack trace out for the exception, and
- * any nested exception that it may have embedded in
- * its Status object.
- *
- * @param output the stream to write to
- */
- public void printStackTrace(PrintStream output) {
- synchronized (output) {
- super.printStackTrace(output);
- if (status.getException() != null) {
- output.print(getClass().getName() + "[" + status.getCode() + "]: "); //$NON-NLS-1$ //$NON-NLS-2$
- status.getException().printStackTrace(output);
- }
- }
- }
-
- /**
- * Prints a stack trace out for the exception, and
- * any nested exception that it may have embedded in
- * its Status object.
- *
- * @param output the stream to write to
- */
- public void printStackTrace(PrintWriter output) {
- synchronized (output) {
- super.printStackTrace(output);
- if (status.getException() != null) {
- output.print(getClass().getName() + "[" + status.getCode() + "]: "); //$NON-NLS-1$ //$NON-NLS-2$
- status.getException().printStackTrace(output);
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/FileLocator.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/FileLocator.java
deleted file mode 100644
index 070e9f672..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/FileLocator.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import java.io.*;
-import java.net.URL;
-import java.util.Map;
-import org.eclipse.core.internal.runtime.Activator;
-import org.eclipse.core.internal.runtime.FindSupport;
-import org.eclipse.osgi.service.urlconversion.URLConverter;
-import org.osgi.framework.Bundle;
-
-/**
- * This class contains collection of helper methods aimed at finding files in bundles.
- * This class can only be used if OSGi plugin is available.
- * <p>
- * The class is not intended to be subclassed or instantiated by clients.
- * </p>
- * @since org.eclipse.equinox.common 3.2
- */
-public final class FileLocator {
-
- private FileLocator() {
- // prevent instantiation
- }
-
- /**
- * Returns a URL for the given path in the given bundle. Returns <code>null</code> if the URL
- * could not be computed or created.
- * <p>
- * find looks for this path in given bundle and any attached fragments.
- * <code>null</code> is returned if no such entry is found. Note that
- * there is no specific order to the fragments.
- * </p><p>
- * The following arguments may also be used
- * <pre>
- * $nl$ - for language specific information
- * $os$ - for operating system specific information
- * $ws$ - for windowing system specific information
- * </pre>
- * </p><p>
- * A path of $nl$/about.properties in an environment with a default
- * locale of en_CA will return a URL corresponding to the first place
- * about.properties is found according to the following order:
- * <pre>
- * plugin root/nl/en/CA/about.properties
- * fragment1 root/nl/en/CA/about.properties
- * fragment2 root/nl/en/CA/about.properties
- * ...
- * plugin root/nl/en/about.properties
- * fragment1 root/nl/en/about.properties
- * fragment2 root/nl/en/about.properties
- * ...
- * plugin root/about.properties
- * fragment1 root/about.properties
- * fragment2 root/about.properties
- * ...
- * </pre>
- * </p><p>
- * The current environment variable values can be overridden using
- * the override map argument or <code>null</code> can be specified
- * if this is not desired.
- * </p>
- *
- * @param bundle the bundle in which to search
- * @param path file path relative to plug-in installation location
- * @param override map of override substitution arguments to be used for
- * any $arg$ path elements. The map keys correspond to the substitution
- * arguments (eg. "$nl$" or "$os$"). The resulting
- * values must be of type java.lang.String. If the map is <code>null</code>,
- * or does not contain the required substitution argument, the default
- * is used.
- * @return a URL for the given path or <code>null</code>. The actual form
- * of the returned URL is not specified.
- */
- public static URL find(Bundle bundle, IPath path, Map override) {
- return FindSupport.find(bundle, path, override);
- }
-
- /**
- * Same as {@link #findEntries(Bundle, IPath, Map)} except multiple entries
- * can be returned if more than one entry matches the path in the host and
- * any of its fragments.
- *
- * @param bundle the bundle in which to search
- * @param path file path relative to plug-in installation location
- * @param override map of override substitution arguments to be used for
- * any $arg$ path elements. The map keys correspond to the substitution
- * arguments (eg. "$nl$" or "$os$"). The resulting
- * values must be of type java.lang.String. If the map is <code>null</code>,
- * or does not contain the required substitution argument, the default
- * is used.
- * @return an array of entries which match the given path. An empty
- * array is returned if no matches are found.
- *
- * @since org.eclipse.equinox.common 3.3
- */
- public static URL[] findEntries(Bundle bundle, IPath path, Map override) {
- return FindSupport.findEntries(bundle, path, override);
- }
-
- /**
- * Same as {@link #findEntries(Bundle, IPath)} except multiple entries
- * can be returned if more than one entry matches the path in the host
- * any of its fragments.
- *
- * @param bundle the bundle in which to search
- * @param path file path relative to plug-in installation location
- * @return an array of entries which match the given path. An empty
- * array is returned if no matches are found.
- *
- * @since org.eclipse.equinox.common 3.3
- */
- public static URL[] findEntries(Bundle bundle, IPath path) {
- return FindSupport.findEntries(bundle, path);
- }
-
- /**
- * Returns an input stream for the specified file. The file path
- * must be specified relative to this plug-in's installation location.
- * Optionally, the path specified may contain $arg$ path elements that can
- * be used as substitution arguments. If this option is used then the $arg$
- * path elements are processed in the same way as {@link #find(Bundle, IPath, Map)}.
- * <p>
- * The caller must close the returned stream when done.
- * </p>
- *
- * @param bundle the bundle in which to search
- * @param file path relative to plug-in installation location
- * @param substituteArgs <code>true</code> to process substitution arguments,
- * and <code>false</code> for the file exactly as specified without processing any
- * substitution arguments.
- * @return an input stream
- * @exception IOException if the given path cannot be found in this plug-in
- */
- public static InputStream openStream(Bundle bundle, IPath file, boolean substituteArgs) throws IOException {
- return FindSupport.openStream(bundle, file, substituteArgs);
- }
-
- /**
- * Converts a URL that uses a user-defined protocol into a URL that uses the file
- * protocol. The contents of the URL may be extracted into a cache on the file-system
- * in order to get a file URL.
- * <p>
- * If the protocol for the given URL is not recognized by this converter, the original
- * URL is returned as-is.
- * </p>
- * @param url the original URL
- * @return the converted file URL or the original URL passed in if it is
- * not recognized by this converter
- * @throws IOException if an error occurs during the conversion
- */
- public static URL toFileURL(URL url) throws IOException {
- URLConverter converter = Activator.getURLConverter(url);
- return converter == null ? url : converter.toFileURL(url);
- }
-
- /**
- * Converts a URL that uses a client-defined protocol into a URL that uses a
- * protocol which is native to the Java class library (file, jar, http, etc).
- * <p>
- * Note however that users of this API should not assume too much about the
- * results of this method. While it may consistently return a file: URL in certain
- * installation configurations, others may result in jar: or http: URLs.
- * </p>
- * <p>
- * If the protocol is not recognized by this converter, then the original URL is
- * returned as-is.
- * </p>
- * @param url the original URL
- * @return the resolved URL or the original if the protocol is unknown to this converter
- * @exception IOException if unable to resolve URL
- * @throws IOException if an error occurs during the resolution
- */
- public static URL resolve(URL url) throws IOException {
- URLConverter converter = Activator.getURLConverter(url);
- return converter == null ? url : converter.resolve(url);
- }
-
- /**
- * Returns a file for the contents of the specified bundle. Depending
- * on how the bundle is installed the returned file may be a directory or a jar file
- * containing the bundle content.
- *
- * @param bundle the bundle
- * @return a file with the contents of the bundle
- * @throws IOException if an error occurs during the resolution
- *
- * @since org.eclipse.equinox.common 3.4
- */
- public static File getBundleFile(Bundle bundle) throws IOException {
- URL rootEntry = bundle.getEntry("/"); //$NON-NLS-1$
- rootEntry = resolve(rootEntry);
- if ("file".equals(rootEntry.getProtocol())) //$NON-NLS-1$
- return new File(rootEntry.getPath());
- if ("jar".equals(rootEntry.getProtocol())) { //$NON-NLS-1$
- String path = rootEntry.getPath();
- if (path.startsWith("file:")) {
- // strip off the file: and the !/
- path = path.substring(5, path.length() - 2);
- return new File(path);
- }
- }
- throw new IOException("Unknown protocol"); //$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdaptable.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdaptable.java
deleted file mode 100644
index 1c3f6d1de..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdaptable.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * An interface for an adaptable object.
- * <p>
- * Adaptable objects can be dynamically extended to provide different
- * interfaces (or "adapters"). Adapters are created by adapter
- * factories, which are in turn managed by type by adapter managers.
- * </p>
- * For example,
- * <pre>
- * IAdaptable a = [some adaptable];
- * IFoo x = (IFoo)a.getAdapter(IFoo.class);
- * if (x != null)
- * [do IFoo things with x]
- * </pre>
- * <p>
- * This interface can be used without OSGi running.
- * </p><p>
- * Clients may implement this interface, or obtain a default implementation
- * of this interface by subclassing <code>PlatformObject</code>.
- * </p>
- * @see IAdapterFactory
- * @see IAdapterManager
- * @see PlatformObject
- */
-public interface IAdaptable {
- /**
- * Returns an object which is an instance of the given class
- * associated with this object. Returns <code>null</code> if
- * no such object can be found.
- *
- * @param adapter the adapter class to look up
- * @return a object castable to the given class,
- * or <code>null</code> if this object does not
- * have an adapter for the given class
- */
- public Object getAdapter(Class adapter);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterFactory.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterFactory.java
deleted file mode 100644
index a3dfcb497..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterFactory.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * An adapter factory defines behavioral extensions for
- * one or more classes that implements the <code>IAdaptable</code>
- * interface. Adapter factories are registered with an
- * adapter manager.
- * <p>
- * This interface can be used without OSGi running.
- * </p><p>
- * Clients may implement this interface.
- * </p>
- * @see IAdapterManager
- * @see IAdaptable
- */
-public interface IAdapterFactory {
- /**
- * Returns an object which is an instance of the given class
- * associated with the given object. Returns <code>null</code> if
- * no such object can be found.
- *
- * @param adaptableObject the adaptable object being queried
- * (usually an instance of <code>IAdaptable</code>)
- * @param adapterType the type of adapter to look up
- * @return a object castable to the given adapter type,
- * or <code>null</code> if this adapter factory
- * does not have an adapter of the given type for the
- * given object
- */
- public Object getAdapter(Object adaptableObject, Class adapterType);
-
- /**
- * Returns the collection of adapter types handled by this
- * factory.
- * <p>
- * This method is generally used by an adapter manager
- * to discover which adapter types are supported, in advance
- * of dispatching any actual <code>getAdapter</code> requests.
- * </p>
- *
- * @return the collection of adapter types
- */
- public Class[] getAdapterList();
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterManager.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterManager.java
deleted file mode 100644
index 316e5514b..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterManager.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * An adapter manager maintains a registry of adapter factories. Clients
- * directly invoke methods on an adapter manager to register and unregister
- * adapters. All adaptable objects (that is, objects that implement the <code>IAdaptable</code>
- * interface) funnel <code>IAdaptable.getAdapter</code> invocations to their
- * adapter manager's <code>IAdapterManger.getAdapter</code> method. The
- * adapter manager then forwards this request unmodified to the <code>IAdapterFactory.getAdapter</code>
- * method on one of the registered adapter factories.
- * <p>
- * Adapter factories can be registered programmatically using the <code>registerAdapters</code>
- * method. Alternatively, they can be registered declaratively using the
- * <code>org.eclipse.core.runtime.adapters</code> extension point. Factories registered
- * with this extension point will not be able to provide adapters until their
- * corresponding plugin has been activated.
- * <p>
- * The following code snippet shows how one might register an adapter of type
- * <code>com.example.acme.Sticky</code> on resources in the workspace.
- * <p>
- *
- * <pre>
- * IAdapterFactory pr = new IAdapterFactory() {
- * public Class[] getAdapterList() {
- * return new Class[] { com.example.acme.Sticky.class };
- * }
- * public Object getAdapter(Object adaptableObject, Class adapterType) {
- * IResource res = (IResource) adaptableObject;
- * QualifiedName key = new QualifiedName(&quot;com.example.acme&quot;, &quot;sticky-note&quot;);
- * try {
- * com.example.acme.Sticky v = (com.example.acme.Sticky) res.getSessionProperty(key);
- * if (v == null) {
- * v = new com.example.acme.Sticky();
- * res.setSessionProperty(key, v);
- * }
- * } catch (CoreException e) {
- * // unable to access session property - ignore
- * }
- * return v;
- * }
- * }
- * Platform.getAdapterManager().registerAdapters(pr, IResource.class);
- * </pre>
- *
- * </p><p>
- * This interface can be used without OSGi running.
- * </p><p>
- * This interface is not intended to be implemented by clients.
- * </p>
- * @see IAdaptable
- * @see IAdapterFactory
- */
-public interface IAdapterManager {
-
- /**
- * This value can be returned to indicate that no applicable adapter factory
- * was found.
- * @since org.eclipse.equinox.common 3.3
- */
- public static final int NONE = 0;
-
- /**
- * This value can be returned to indicate that an adapter factory was found,
- * but has not been loaded.
- * @since org.eclipse.equinox.common 3.3
- */
- public static final int NOT_LOADED = 1;
-
- /**
- * This value can be returned to indicate that an adapter factory is loaded.
- * @since org.eclipse.equinox.common 3.3
- */
- public static final int LOADED = 2;
-
- /**
- * Returns the types that can be obtained by converting <code>adaptableClass</code>
- * via this manager. Converting means that subsequent calls to <code>getAdapter()</code>
- * or <code>loadAdapter()</code> could result in an adapted object.
- * <p>
- * Note that the returned types do not guarantee that
- * a subsequent call to <code>getAdapter</code> with the same type as an argument
- * will return a non-null result. If the factory's plug-in has not yet been
- * loaded, or if the factory itself returns <code>null</code>, then
- * <code>getAdapter</code> will still return <code>null</code>.
- * </p>
- * @param adaptableClass the adaptable class being queried
- * @return an array of type names that can be obtained by converting
- * <code>adaptableClass</code> via this manager. An empty array
- * is returned if there are none.
- * @since 3.1
- */
- public String[] computeAdapterTypes(Class adaptableClass);
-
- /**
- * Returns the class search order for a given class. The search order from a
- * class with the definition <br>
- * <code>class X extends Y implements A, B</code><br>
- * is as follows:
- * <ul>
- * <li>the target's class: X
- * <li>X's superclasses in order to <code>Object</code>
- * <li>a breadth-first traversal of the target class's interfaces in the
- * order returned by <code>getInterfaces</code> (in the example, A and its
- * superinterfaces then B and its superinterfaces) </li>
- * </ul>
- *
- * @param clazz the class for which to return the class order.
- * @return the class search order for the given class. The returned
- * search order will minimally contain the target class.
- * @since 3.1
- */
- public Class[] computeClassOrder(Class clazz);
-
- /**
- * Returns an object which is an instance of the given class associated
- * with the given object. Returns <code>null</code> if no such object can
- * be found.
- * <p>
- * Note that this method will never cause plug-ins to be loaded. If the
- * only suitable factory is not yet loaded, this method will return <code>null</code>.
- *
- * @param adaptable the adaptable object being queried (usually an instance
- * of <code>IAdaptable</code>)
- * @param adapterType the type of adapter to look up
- * @return an object castable to the given adapter type, or <code>null</code>
- * if the given adaptable object does not have an available adapter of the
- * given type
- */
- public Object getAdapter(Object adaptable, Class adapterType);
-
- /**
- * Returns an object which is an instance of the given class name associated
- * with the given object. Returns <code>null</code> if no such object can
- * be found.
- * <p>
- * Note that this method will never cause plug-ins to be loaded. If the
- * only suitable factory is not yet loaded, this method will return <code>null</code>.
- * If activation of the plug-in providing the factory is required, use the
- * <code>loadAdapter</code> method instead.
- *
- * @param adaptable the adaptable object being queried (usually an instance
- * of <code>IAdaptable</code>)
- * @param adapterTypeName the fully qualified name of the type of adapter to look up
- * @return an object castable to the given adapter type, or <code>null</code>
- * if the given adaptable object does not have an available adapter of the
- * given type
- * @since 3.0
- */
- public Object getAdapter(Object adaptable, String adapterTypeName);
-
- /**
- * Returns whether there is an adapter factory registered that may be able
- * to convert <code>adaptable</code> to an object of type <code>adapterTypeName</code>.
- * <p>
- * Note that a return value of <code>true</code> does not guarantee that
- * a subsequent call to <code>getAdapter</code> with the same arguments
- * will return a non-null result. If the factory's plug-in has not yet been
- * loaded, or if the factory itself returns <code>null</code>, then
- * <code>getAdapter</code> will still return <code>null</code>.
- *
- * @param adaptable the adaptable object being queried (usually an instance
- * of <code>IAdaptable</code>)
- * @param adapterTypeName the fully qualified class name of an adapter to
- * look up
- * @return <code>true</code> if there is an adapter factory that claims
- * it can convert <code>adaptable</code> to an object of type <code>adapterType</code>,
- * and <code>false</code> otherwise.
- * @since 3.0
- */
- public boolean hasAdapter(Object adaptable, String adapterTypeName);
-
- /**
- * Returns a status of an adapter factory registered that may be able
- * to convert <code>adaptable</code> to an object of type <code>adapterTypeName</code>.
- * <p>
- * One of the following values can be returned:<ul>
- * <li>{@link org.eclipse.core.runtime.IAdapterManager#NONE} if no applicable adapter factory was found;</li>
- * <li>{@link org.eclipse.core.runtime.IAdapterManager#NOT_LOADED} if an adapter factory was found, but has not been loaded;</li>
- * <li>{@link org.eclipse.core.runtime.IAdapterManager#LOADED} if an adapter factory was found, and it is loaded.</li>
- * </ul></p>
- * @param adaptable the adaptable object being queried (usually an instance
- * of <code>IAdaptable</code>)
- * @param adapterTypeName the fully qualified class name of an adapter to
- * look up
- * @return a status of the adapter
- * @since org.eclipse.equinox.common 3.3
- */
- public int queryAdapter(Object adaptable, String adapterTypeName);
-
- /**
- * Returns an object that is an instance of the given class name associated
- * with the given object. Returns <code>null</code> if no such object can
- * be found.
- * <p>
- * Note that unlike the <code>getAdapter</code> methods, this method
- * will cause the plug-in that contributes the adapter factory to be loaded
- * if necessary. As such, this method should be used judiciously, in order
- * to avoid unnecessary plug-in activations. Most clients should avoid
- * activation by using <code>getAdapter</code> instead.
- *
- * @param adaptable the adaptable object being queried (usually an instance
- * of <code>IAdaptable</code>)
- * @param adapterTypeName the fully qualified name of the type of adapter to look up
- * @return an object castable to the given adapter type, or <code>null</code>
- * if the given adaptable object does not have an available adapter of the
- * given type
- * @since 3.0
- */
- public Object loadAdapter(Object adaptable, String adapterTypeName);
-
- /**
- * Registers the given adapter factory as extending objects of the given
- * type.
- * <p>
- * If the type being extended is a class, the given factory's adapters are
- * available on instances of that class and any of its subclasses. If it is
- * an interface, the adapters are available to all classes that directly or
- * indirectly implement that interface.
- * </p>
- *
- * @param factory the adapter factory
- * @param adaptable the type being extended
- * @see #unregisterAdapters(IAdapterFactory)
- * @see #unregisterAdapters(IAdapterFactory, Class)
- */
- public void registerAdapters(IAdapterFactory factory, Class adaptable);
-
- /**
- * Removes the given adapter factory completely from the list of registered
- * factories. Equivalent to calling <code>unregisterAdapters(IAdapterFactory,Class)</code>
- * on all classes against which it had been explicitly registered. Does
- * nothing if the given factory is not currently registered.
- *
- * @param factory the adapter factory to remove
- * @see #registerAdapters(IAdapterFactory, Class)
- */
- public void unregisterAdapters(IAdapterFactory factory);
-
- /**
- * Removes the given adapter factory from the list of factories registered
- * as extending the given class. Does nothing if the given factory and type
- * combination is not registered.
- *
- * @param factory the adapter factory to remove
- * @param adaptable one of the types against which the given factory is
- * registered
- * @see #registerAdapters(IAdapterFactory, Class)
- */
- public void unregisterAdapters(IAdapterFactory factory, Class adaptable);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroup.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroup.java
deleted file mode 100644
index 3f5339404..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroup.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import org.osgi.framework.Bundle;
-
-/**
- * Bundle groups represent a logical collection of plug-ins (aka bundles). Bundle
- * groups do not contain their constituents but rather collect them together under
- * a common label. The main role of a bundle group is to report to the system
- * (e.g., the About dialog) what bundles have been installed. They are not intended
- * for use in managing the set of bundles they represent.
- * <p>
- * Since the bulk of the branding related information is specific to the consumer,
- * bundle groups also carry an arbitrary set of properties. The valid set of
- * key-value pairs and their interpretation defined by the consumer in the
- * target environment.
- * </p><p>
- * The Eclipse UI is the typical consumer of bundle groups and defines various
- * property keys that it will use, for example, to display About information. See
- * <code>org.eclipse.ui.branding.IBundleGroupConstants</code>.
- * </p>
- * @see IBundleGroupProvider
- * @since 3.0
- */
-public interface IBundleGroup {
-
- /**
- * Returns the identifier of this bundle group. Bundle groups are uniquely identified by the combination of
- * their identifier and their version.
- *
- * @see #getVersion()
- * @return the identifier for this bundle group
- */
- public String getIdentifier();
-
- /**
- * Returns the human-readable name of this bundle group.
- *
- * @return the human-readable name
- */
- public String getName();
-
- /**
- * Returns the version of this bundle group. Bundle group version strings have the same format as
- * bundle versions (i.e., major.minor.service.qualifier). Bundle groups are uniquely identified
- * by the combination of their identifier and their version.
- *
- * @see #getIdentifier()
- * @return the string form of this bundle group's version
- */
- public String getVersion();
-
- /**
- * Returns a text description of this bundle group.
- *
- * @return text description of this bundle group
- */
- public String getDescription();
-
- /**
- * Returns the name of the provider of this bundle group.
- *
- * @return the name of the provider or <code>null</code> if none
- */
- public String getProviderName();
-
- /**
- * Returns a list of all bundles supplied by this bundle group.
- *
- * @return the bundles supplied by this bundle group
- */
- public Bundle[] getBundles();
-
- /**
- * Returns the property of this bundle group with the given key.
- * <code>null</code> is returned if there is no such key/value pair.
- *
- * @param key the name of the property to return
- * @return the value associated with the given key or <code>null</code> if none
- */
- public String getProperty(String key);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroupProvider.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroupProvider.java
deleted file mode 100644
index 5de0835f2..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroupProvider.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * Bundle group providers define groups of plug-ins which have been installed in
- * the current system. Typically, a configuration agent (i.e., plug-in installer) will
- * define a bundle group provider so that it can report to the system the list
- * of plug-ins it has installed.
- * @see IBundleGroup
- * @since 3.0
- */
-public interface IBundleGroupProvider {
-
- /**
- * Returns the human-readable name of this bundle group provider.
- *
- * @return the name of this bundle group provider
- */
- public String getName();
-
- /**
- * Returns the bundle groups provided by this provider.
- *
- * @return the bundle groups provided by this provider
- */
- public IBundleGroup[] getBundleGroups();
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ILogListener.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ILogListener.java
deleted file mode 100644
index 9b68336b1..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ILogListener.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import java.util.EventListener;
-
-/**
- * A log listener is notified of entries added to a plug-in's log.
- * <p>
- * This interface can be used without OSGi running.
- * </p><p>
- * Clients may implement this interface.
- * </p>
- */
-public interface ILogListener extends EventListener {
- /**
- * Notifies this listener that given status has been logged by
- * a plug-in. The listener is free to retain or ignore this status.
- *
- * @param status the status being logged
- * @param plugin the plugin of the log which generated this event
- */
- public void logging(IStatus status, String plugin);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IPath.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IPath.java
deleted file mode 100644
index 6a5e8a1d2..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IPath.java
+++ /dev/null
@@ -1,505 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * A path is an ordered collection of string segments,
- * separated by a standard separator character, "/".
- * A path may also have a leading and/or a trailing separator.
- * Paths may also be prefixed by an optional device id, which includes
- * the character(s) which separate the device id from the rest
- * of the path. For example, "C:" and "Server/Volume:" are typical
- * device ids.
- * A device independent path has <code>null</code> for a device id.
- * <p>
- * Note that paths are value objects; all operations on paths
- * return a new path; the path that is operated on is unscathed.
- * </p>
- * <p>
- * UNC paths are denoted by leading double-slashes such
- * as <code>//Server/Volume/My/Path</code>. When a new path
- * is constructed all double-slashes are removed except those
- * appearing at the beginning of the path.
- * </p>
- * <p>
- * This interface can be used without OSGi running.
- * </p><p>
- * This interface is not intended to be implemented by clients.
- * </p>
- * @see Path
- */
-public interface IPath extends Cloneable {
-
- /**
- * Path separator character constant "/" used in paths.
- */
- public static final char SEPARATOR = '/';
-
- /**
- * Device separator character constant ":" used in paths.
- */
- public static final char DEVICE_SEPARATOR = ':';
-
- /**
- * Returns a new path which is the same as this path but with
- * the given file extension added. If this path is empty, root or has a
- * trailing separator, this path is returned. If this path already
- * has an extension, the existing extension is left and the given
- * extension simply appended. Clients wishing to replace
- * the current extension should first remove the extension and
- * then add the desired one.
- * <p>
- * The file extension portion is defined as the string
- * following the last period (".") character in the last segment.
- * The given extension should not include a leading ".".
- * </p>
- *
- * @param extension the file extension to append
- * @return the new path
- */
- public IPath addFileExtension(String extension);
-
- /**
- * Returns a path with the same segments as this path
- * but with a trailing separator added.
- * This path must have at least one segment.
- * <p>
- * If this path already has a trailing separator,
- * this path is returned.
- * </p>
- *
- * @return the new path
- * @see #hasTrailingSeparator()
- * @see #removeTrailingSeparator()
- */
- public IPath addTrailingSeparator();
-
- /**
- * Returns the canonicalized path obtained from the
- * concatenation of the given string path to the
- * end of this path. The given string path must be a valid
- * path. If it has a trailing separator,
- * the result will have a trailing separator.
- * The device id of this path is preserved (the one
- * of the given string is ignored). Duplicate slashes
- * are removed from the path except at the beginning
- * where the path is considered to be UNC.
- *
- * @param path the string path to concatenate
- * @return the new path
- * @see #isValidPath(String)
- */
- public IPath append(String path);
-
- /**
- * Returns the canonicalized path obtained from the
- * concatenation of the given path's segments to the
- * end of this path. If the given path has a trailing
- * separator, the result will have a trailing separator.
- * The device id of this path is preserved (the one
- * of the given path is ignored). Duplicate slashes
- * are removed from the path except at the beginning
- * where the path is considered to be UNC.
- *
- * @param path the path to concatenate
- * @return the new path
- */
- public IPath append(IPath path);
-
- /**
- * Returns a copy of this path.
- *
- * @return the cloned path
- */
- public Object clone();
-
- /**
- * Returns whether this path equals the given object.
- * <p>
- * Equality for paths is defined to be: same sequence of segments,
- * same absolute/relative status, and same device.
- * Trailing separators are disregarded.
- * Paths are not generally considered equal to objects other than paths.
- * </p>
- *
- * @param obj the other object
- * @return <code>true</code> if the paths are equivalent,
- * and <code>false</code> if they are not
- */
- public boolean equals(Object obj);
-
- /**
- * Returns the device id for this path, or <code>null</code> if this
- * path has no device id. Note that the result will end in ':'.
- *
- * @return the device id, or <code>null</code>
- * @see #setDevice(String)
- */
- public String getDevice();
-
- /**
- * Returns the file extension portion of this path,
- * or <code>null</code> if there is none.
- * <p>
- * The file extension portion is defined as the string
- * following the last period (".") character in the last segment.
- * If there is no period in the last segment, the path has no
- * file extension portion. If the last segment ends in a period,
- * the file extension portion is the empty string.
- * </p>
- *
- * @return the file extension or <code>null</code>
- */
- public String getFileExtension();
-
- /**
- * Returns whether this path has a trailing separator.
- * <p>
- * Note: In the root path ("/"), the separator is considered to
- * be leading rather than trailing.
- * </p>
- *
- * @return <code>true</code> if this path has a trailing
- * separator, and <code>false</code> otherwise
- * @see #addTrailingSeparator()
- * @see #removeTrailingSeparator()
- */
- public boolean hasTrailingSeparator();
-
- /**
- * Returns whether this path is an absolute path (ignoring
- * any device id).
- * <p>
- * Absolute paths start with a path separator.
- * A root path, like <code>/</code> or <code>C:/</code>,
- * is considered absolute. UNC paths are always absolute.
- * </p>
- *
- * @return <code>true</code> if this path is an absolute path,
- * and <code>false</code> otherwise
- */
- public boolean isAbsolute();
-
- /**
- * Returns whether this path has no segments and is not
- * a root path.
- *
- * @return <code>true</code> if this path is empty,
- * and <code>false</code> otherwise
- */
- public boolean isEmpty();
-
- /**
- * Returns whether this path is a prefix of the given path.
- * To be a prefix, this path's segments must
- * appear in the argument path in the same order,
- * and their device ids must match.
- * <p>
- * An empty path is a prefix of all paths with the same device; a root path is a prefix of
- * all absolute paths with the same device.
- * </p>
- * @param anotherPath the other path
- * @return <code>true</code> if this path is a prefix of the given path,
- * and <code>false</code> otherwise
- */
- public boolean isPrefixOf(IPath anotherPath);
-
- /**
- * Returns whether this path is a root path.
- * <p>
- * The root path is the absolute non-UNC path with zero segments;
- * e.g., <code>/</code> or <code>C:/</code>.
- * The separator is considered a leading separator, not a trailing one.
- * </p>
- *
- * @return <code>true</code> if this path is a root path,
- * and <code>false</code> otherwise
- */
- public boolean isRoot();
-
- /**
- * Returns a boolean value indicating whether or not this path
- * is considered to be in UNC form. Return false if this path
- * has a device set or if the first 2 characters of the path string
- * are not <code>Path.SEPARATOR</code>.
- *
- * @return boolean indicating if this path is UNC
- */
- public boolean isUNC();
-
- /**
- * Returns whether the given string is syntactically correct as
- * a path. The device id is the prefix up to and including the device
- * separator for the local file system; the path proper is everything to
- * the right of it, or the entire string if there is no device separator.
- * When the platform location is a file system with no meaningful device
- * separator, the entire string is treated as the path proper.
- * The device id is not checked for validity; the path proper is correct
- * if each of the segments in its canonicalized form is valid.
- *
- * @param path the path to check
- * @return <code>true</code> if the given string is a valid path,
- * and <code>false</code> otherwise
- * @see #isValidSegment(String)
- */
- public boolean isValidPath(String path);
-
- /**
- * Returns whether the given string is valid as a segment in
- * a path. The rules for valid segments are as follows:
- * <ul>
- * <li> the empty string is not valid
- * <li> any string containing the slash character ('/') is not valid
- * <li>any string containing segment or device separator characters
- * on the local file system, such as the backslash ('\') and colon (':')
- * on some file systems.
- * </ul>
- *
- * @param segment the path segment to check
- * @return <code>true</code> if the given path segment is valid,
- * and <code>false</code> otherwise
- */
- public boolean isValidSegment(String segment);
-
- /**
- * Returns the last segment of this path, or
- * <code>null</code> if it does not have any segments.
- *
- * @return the last segment of this path, or <code>null</code>
- */
- public String lastSegment();
-
- /**
- * Returns an absolute path with the segments and device id of this path.
- * Absolute paths start with a path separator. If this path is absolute,
- * it is simply returned.
- *
- * @return the new path
- */
- public IPath makeAbsolute();
-
- /**
- * Returns a relative path with the segments and device id of this path.
- * Absolute paths start with a path separator and relative paths do not.
- * If this path is relative, it is simply returned.
- *
- * @return the new path
- */
- public IPath makeRelative();
-
- /**
- * Return a new path which is the equivalent of this path converted to UNC
- * form (if the given boolean is true) or this path not as a UNC path (if the given
- * boolean is false). If UNC, the returned path will not have a device and the
- * first 2 characters of the path string will be <code>Path.SEPARATOR</code>. If not UNC, the
- * first 2 characters of the returned path string will not be <code>Path.SEPARATOR</code>.
- *
- * @param toUNC true if converting to UNC, false otherwise
- * @return the new path, either in UNC form or not depending on the boolean parameter
- */
- public IPath makeUNC(boolean toUNC);
-
- /**
- * Returns a count of the number of segments which match in
- * this path and the given path (device ids are ignored),
- * comparing in increasing segment number order.
- *
- * @param anotherPath the other path
- * @return the number of matching segments
- */
- public int matchingFirstSegments(IPath anotherPath);
-
- /**
- * Returns a new path which is the same as this path but with
- * the file extension removed. If this path does not have an
- * extension, this path is returned.
- * <p>
- * The file extension portion is defined as the string
- * following the last period (".") character in the last segment.
- * If there is no period in the last segment, the path has no
- * file extension portion. If the last segment ends in a period,
- * the file extension portion is the empty string.
- * </p>
- *
- * @return the new path
- */
- public IPath removeFileExtension();
-
- /**
- * Returns a copy of this path with the given number of segments
- * removed from the beginning. The device id is preserved.
- * The number must be greater or equal zero.
- * If the count is zero, this path is returned.
- * The resulting path will always be a relative path with respect
- * to this path. If the number equals or exceeds the number
- * of segments in this path, an empty relative path is returned.
- *
- * @param count the number of segments to remove
- * @return the new path
- */
- public IPath removeFirstSegments(int count);
-
- /**
- * Returns a copy of this path with the given number of segments
- * removed from the end. The device id is preserved.
- * The number must be greater or equal zero.
- * If the count is zero, this path is returned.
- * <p>
- * If this path has a trailing separator, it will still
- * have a trailing separator after the last segments are removed
- * (assuming there are some segments left). If there is no
- * trailing separator, the result will not have a trailing
- * separator.
- * If the number equals or exceeds the number
- * of segments in this path, a path with no segments is returned.
- * </p>
- *
- * @param count the number of segments to remove
- * @return the new path
- */
- public IPath removeLastSegments(int count);
-
- /**
- * Returns a path with the same segments as this path
- * but with a trailing separator removed.
- * Does nothing if this path does not have at least one segment.
- * The device id is preserved.
- * <p>
- * If this path does not have a trailing separator,
- * this path is returned.
- * </p>
- *
- * @return the new path
- * @see #addTrailingSeparator()
- * @see #hasTrailingSeparator()
- */
- public IPath removeTrailingSeparator();
-
- /**
- * Returns the specified segment of this path, or
- * <code>null</code> if the path does not have such a segment.
- *
- * @param index the 0-based segment index
- * @return the specified segment, or <code>null</code>
- */
- public String segment(int index);
-
- /**
- * Returns the number of segments in this path.
- * <p>
- * Note that both root and empty paths have 0 segments.
- * </p>
- *
- * @return the number of segments
- */
- public int segmentCount();
-
- /**
- * Returns the segments in this path in order.
- *
- * @return an array of string segments
- */
- public String[] segments();
-
- /**
- * Returns a new path which is the same as this path but with
- * the given device id. The device id must end with a ":".
- * A device independent path is obtained by passing <code>null</code>.
- * <p>
- * For example, "C:" and "Server/Volume:" are typical device ids.
- * </p>
- *
- * @param device the device id or <code>null</code>
- * @return a new path
- * @see #getDevice()
- */
- public IPath setDevice(String device);
-
- /**
- * Returns a <code>java.io.File</code> corresponding to this path.
- *
- * @return the file corresponding to this path
- */
- public java.io.File toFile();
-
- /**
- * Returns a string representation of this path which uses the
- * platform-dependent path separator defined by <code>java.io.File</code>.
- * This method is like <code>toString()</code> except that the
- * latter always uses the same separator (<code>/</code>) regardless of platform.
- * <p>
- * This string is suitable for passing to <code>java.io.File(String)</code>.
- * </p>
- *
- * @return a platform-dependent string representation of this path
- */
- public String toOSString();
-
- /**
- * Returns a platform-neutral string representation of this path. The
- * format is not specified, except that the resulting string can be
- * passed back to the <code>Path#fromPortableString(String)</code>
- * constructor to produce the exact same path on any platform.
- * <p>
- * This string is suitable for passing to <code>Path#fromPortableString(String)</code>.
- * </p>
- *
- * @return a platform-neutral string representation of this path
- * @see Path#fromPortableString(String)
- * @since 3.1
- */
- public String toPortableString();
-
- /**
- * Returns a string representation of this path, including its
- * device id. The same separator, "/", is used on all platforms.
- * <p>
- * Example result strings (without and with device id):
- * <pre>
- * "/foo/bar.txt"
- * "bar.txt"
- * "/foo/"
- * "foo/"
- * ""
- * "/"
- * "C:/foo/bar.txt"
- * "C:bar.txt"
- * "C:/foo/"
- * "C:foo/"
- * "C:"
- * "C:/"
- * </pre>
- * This string is suitable for passing to <code>Path(String)</code>.
- * </p>
- *
- * @return a string representation of this path
- * @see Path
- */
- public String toString();
-
- /**
- * Returns a copy of this path truncated after the
- * given number of segments. The number must not be negative.
- * The device id is preserved.
- * <p>
- * If this path has a trailing separator, the result will too
- * (assuming there are some segments left). If there is no
- * trailing separator, the result will not have a trailing
- * separator.
- * Copying up to segment zero simply means making an copy with
- * no path segments.
- * </p>
- *
- * @param count the segment number at which to truncate the path
- * @return the new path
- */
- public IPath uptoSegment(int count);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java
deleted file mode 100644
index 39406794c..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * The <code>IProgressMonitor</code> interface is implemented
- * by objects that monitor the progress of an activity; the methods
- * in this interface are invoked by code that performs the activity.
- * <p>
- * All activity is broken down into a linear sequence of tasks against
- * which progress is reported. When a task begins, a <code>beginTask(String, int)
- * </code> notification is reported, followed by any number and mixture of
- * progress reports (<code>worked()</code>) and subtask notifications
- * (<code>subTask(String)</code>). When the task is eventually completed, a
- * <code>done()</code> notification is reported. After the <code>done()</code>
- * notification, the progress monitor cannot be reused; i.e., <code>
- * beginTask(String, int)</code> cannot be called again after the call to
- * <code>done()</code>.
- * </p>
- * <p>
- * A request to cancel an operation can be signaled using the
- * <code>setCanceled</code> method. Operations taking a progress
- * monitor are expected to poll the monitor (using <code>isCanceled</code>)
- * periodically and abort at their earliest convenience. Operation can however
- * choose to ignore cancelation requests.
- * </p>
- * <p>
- * Since notification is synchronous with the activity itself, the listener should
- * provide a fast and robust implementation. If the handling of notifications would
- * involve blocking operations, or operations which might throw uncaught exceptions,
- * the notifications should be queued, and the actual processing deferred (or perhaps
- * delegated to a separate thread).
- * </p><p>
- * This interface can be used without OSGi running.
- * </p><p>
- * Clients may implement this interface.
- * </p>
- */
-public interface IProgressMonitor {
-
- /** Constant indicating an unknown amount of work.
- */
- public final static int UNKNOWN = -1;
-
- /**
- * Notifies that the main task is beginning. This must only be called once
- * on a given progress monitor instance.
- *
- * @param name the name (or description) of the main task
- * @param totalWork the total number of work units into which
- * the main task is been subdivided. If the value is <code>UNKNOWN</code>
- * the implementation is free to indicate progress in a way which
- * doesn't require the total number of work units in advance.
- */
- public void beginTask(String name, int totalWork);
-
- /**
- * Notifies that the work is done; that is, either the main task is completed
- * or the user canceled it. This method may be called more than once
- * (implementations should be prepared to handle this case).
- */
- public void done();
-
- /**
- * Internal method to handle scaling correctly. This method
- * must not be called by a client. Clients should
- * always use the method </code>worked(int)</code>.
- *
- * @param work the amount of work done
- */
- public void internalWorked(double work);
-
- /**
- * Returns whether cancelation of current operation has been requested.
- * Long-running operations should poll to see if cancelation
- * has been requested.
- *
- * @return <code>true</code> if cancellation has been requested,
- * and <code>false</code> otherwise
- * @see #setCanceled(boolean)
- */
- public boolean isCanceled();
-
- /**
- * Sets the cancel state to the given value.
- *
- * @param value <code>true</code> indicates that cancelation has
- * been requested (but not necessarily acknowledged);
- * <code>false</code> clears this flag
- * @see #isCanceled()
- */
- public void setCanceled(boolean value);
-
- /**
- * Sets the task name to the given value. This method is used to
- * restore the task label after a nested operation was executed.
- * Normally there is no need for clients to call this method.
- *
- * @param name the name (or description) of the main task
- * @see #beginTask(java.lang.String, int)
- */
- public void setTaskName(String name);
-
- /**
- * Notifies that a subtask of the main task is beginning.
- * Subtasks are optional; the main task might not have subtasks.
- *
- * @param name the name (or description) of the subtask
- */
- public void subTask(String name);
-
- /**
- * Notifies that a given number of work unit of the main task
- * has been completed. Note that this amount represents an
- * installment, as opposed to a cumulative amount of work done
- * to date.
- *
- * @param work a non-negative number of work units just completed
- */
- public void worked(int work);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitorWithBlocking.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitorWithBlocking.java
deleted file mode 100644
index ea578d59c..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitorWithBlocking.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * An extension to the IProgressMonitor interface for monitors that want to
- * support feedback when an activity is blocked due to concurrent activity in
- * another thread.
- * <p>
- * When a monitor that supports this extension is passed to an operation, the
- * operation should call <code>setBlocked</code> whenever it knows that it
- * must wait for a lock that is currently held by another thread. The operation
- * should continue to check for and respond to cancelation requests while
- * blocked. When the operation is no longer blocked, it must call <code>clearBlocked</code>
- * to clear the blocked state.
- * <p>
- * This interface can be used without OSGi running.
- * </p><p>
- * Clients may implement this interface.
- * </p>
- * @see IProgressMonitor
- * @since 3.0
- */
-public interface IProgressMonitorWithBlocking extends IProgressMonitor {
- /**
- * Indicates that this operation is blocked by some background activity. If
- * a running operation ever calls <code>setBlocked</code>, it must
- * eventually call <code>clearBlocked</code> before the operation
- * completes.
- * <p>
- * If the caller is blocked by a currently executing job, this method will return
- * an <code>IJobStatus</code> indicating the job that is currently blocking
- * the caller. If this blocking job is not known, this method will return a plain
- * informational <code>IStatus</code> object.
- * </p>
- *
- * @param reason an optional status object whose message describes the
- * reason why this operation is blocked, or <code>null</code> if this
- * information is not available.
- * @see #clearBlocked()
- */
- public void setBlocked(IStatus reason);
-
- /**
- * Clears the blocked state of the running operation. If a running
- * operation ever calls <code>setBlocked</code>, it must eventually call
- * <code>clearBlocked</code> before the operation completes.
- *
- * @see #setBlocked(IStatus)
- */
- public void clearBlocked();
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ISafeRunnable.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ISafeRunnable.java
deleted file mode 100644
index 5bb4439e8..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ISafeRunnable.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * Safe runnables represent blocks of code and associated exception
- * handlers. They are typically used when a plug-in needs to call some
- * untrusted code (e.g., code contributed by another plug-in via an
- * extension).
- * <p>
- * This interface can be used without OSGi running.
- * </p><p>
- * Clients may implement this interface.
- * </p>
- * @see SafeRunner#run(ISafeRunnable)
- */
-public interface ISafeRunnable {
- /**
- * Handles an exception thrown by this runnable's <code>run</code>
- * method. The processing done here should be specific to the
- * particular usecase for this runnable. Generalized exception
- * processing (e.g., logging in the platform's log) is done by the
- * Platform's run mechanism.
- *
- * @param exception an exception which occurred during processing
- * the body of this runnable (i.e., in <code>run()</code>)
- * @see SafeRunner#run(ISafeRunnable)
- */
- public void handleException(Throwable exception);
-
- /**
- * Runs this runnable. Any exceptions thrown from this method will
- * be passed to this runnable's <code>handleException</code>
- * method.
- *
- * @exception Exception if a problem occurred while running this method.
- * The exception will be processed by <code>handleException</code>
- * @see SafeRunner#run(ISafeRunnable)
- */
- public void run() throws Exception;
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IStatus.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IStatus.java
deleted file mode 100644
index f146519f8..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IStatus.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * A status object represents the outcome of an operation.
- * All <code>CoreException</code>s carry a status object to indicate
- * what went wrong. Status objects are also returned by methods needing
- * to provide details of failures (e.g., validation methods).
- * <p>
- * A status carries the following information:
- * <ul>
- * <li> plug-in identifier (required)</li>
- * <li> severity (required)</li>
- * <li> status code (required)</li>
- * <li> message (required) - localized to current locale</li>
- * <li> exception (optional) - for problems stemming from a failure at
- * a lower level</li>
- * </ul>
- * Some status objects, known as multi-statuses, have other status objects
- * as children.
- * </p>
- * <p>
- * The class <code>Status</code> is the standard public implementation
- * of status objects; the subclass <code>MultiStatus</code> is the
- * implements multi-status objects.
- * </p><p>
- * This interface can be used without OSGi running.
- * </p>
- * @see MultiStatus
- * @see Status
- */
-public interface IStatus {
-
- /** Status severity constant (value 0) indicating this status represents the nominal case.
- * This constant is also used as the status code representing the nominal case.
- * @see #getSeverity()
- * @see #isOK()
- */
- public static final int OK = 0;
-
- /** Status type severity (bit mask, value 1) indicating this status is informational only.
- * @see #getSeverity()
- * @see #matches(int)
- */
- public static final int INFO = 0x01;
-
- /** Status type severity (bit mask, value 2) indicating this status represents a warning.
- * @see #getSeverity()
- * @see #matches(int)
- */
- public static final int WARNING = 0x02;
-
- /** Status type severity (bit mask, value 4) indicating this status represents an error.
- * @see #getSeverity()
- * @see #matches(int)
- */
- public static final int ERROR = 0x04;
-
- /** Status type severity (bit mask, value 8) indicating this status represents a
- * cancelation
- * @see #getSeverity()
- * @see #matches(int)
- * @since 3.0
- */
- public static final int CANCEL = 0x08;
-
- /**
- * Returns a list of status object immediately contained in this
- * multi-status, or an empty list if this is not a multi-status.
- *
- * @return an array of status objects
- * @see #isMultiStatus()
- */
- public IStatus[] getChildren();
-
- /**
- * Returns the plug-in-specific status code describing the outcome.
- *
- * @return plug-in-specific status code
- */
- public int getCode();
-
- /**
- * Returns the relevant low-level exception, or <code>null</code> if none.
- * For example, when an operation fails because of a network communications
- * failure, this might return the <code>java.io.IOException</code>
- * describing the exact nature of that failure.
- *
- * @return the relevant low-level exception, or <code>null</code> if none
- */
- public Throwable getException();
-
- /**
- * Returns the message describing the outcome.
- * The message is localized to the current locale.
- *
- * @return a localized message
- */
- public String getMessage();
-
- /**
- * Returns the unique identifier of the plug-in associated with this status
- * (this is the plug-in that defines the meaning of the status code).
- *
- * @return the unique identifier of the relevant plug-in
- */
- public String getPlugin();
-
- /**
- * Returns the severity. The severities are as follows (in
- * descending order):
- * <ul>
- * <li><code>CANCEL</code> - cancelation occurred</li>
- * <li><code>ERROR</code> - a serious error (most severe)</li>
- * <li><code>WARNING</code> - a warning (less severe)</li>
- * <li><code>INFO</code> - an informational ("fyi") message (least severe)</li>
- * <li><code>OK</code> - everything is just fine</li>
- * </ul>
- * <p>
- * The severity of a multi-status is defined to be the maximum
- * severity of any of its children, or <code>OK</code> if it has
- * no children.
- * </p>
- *
- * @return the severity: one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @see #matches(int)
- */
- public int getSeverity();
-
- /**
- * Returns whether this status is a multi-status.
- * A multi-status describes the outcome of an operation
- * involving multiple operands.
- * <p>
- * The severity of a multi-status is derived from the severities
- * of its children; a multi-status with no children is
- * <code>OK</code> by definition.
- * A multi-status carries a plug-in identifier, a status code,
- * a message, and an optional exception. Clients may treat
- * multi-status objects in a multi-status unaware way.
- * </p>
- *
- * @return <code>true</code> for a multi-status,
- * <code>false</code> otherwise
- * @see #getChildren()
- */
- public boolean isMultiStatus();
-
- /**
- * Returns whether this status indicates everything is okay
- * (neither info, warning, nor error).
- *
- * @return <code>true</code> if this status has severity
- * <code>OK</code>, and <code>false</code> otherwise
- */
- public boolean isOK();
-
- /**
- * Returns whether the severity of this status matches the given
- * severity mask. Note that a status with severity <code>OK</code>
- * will never match; use <code>isOK</code> instead to detect
- * a status with a severity of <code>OK</code>.
- *
- * @param severityMask a mask formed by bitwise or'ing severity mask
- * constants (<code>ERROR</code>, <code>WARNING</code>,
- * <code>INFO</code>, <code>CANCEL</code>)
- * @return <code>true</code> if there is at least one match,
- * <code>false</code> if there are no matches
- * @see #getSeverity()
- * @see #CANCEL
- * @see #ERROR
- * @see #WARNING
- * @see #INFO
- */
- public boolean matches(int severityMask);
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java
deleted file mode 100644
index 9363ac13c..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * This class is a thread safe list that is designed for storing lists of listeners.
- * The implementation is optimized for minimal memory footprint, frequent reads
- * and infrequent writes. Modification of the list is synchronized and relatively
- * expensive, while accessing the listeners is very fast. Readers are given access
- * to the underlying array data structure for reading, with the trust that they will
- * not modify the underlying array.
- * <p>
- * <a name="same">A listener list handles the <i>same</i> listener being added
- * multiple times, and tolerates removal of listeners that are the same as other
- * listeners in the list. For this purpose, listeners can be compared with each other
- * using either equality or identity, as specified in the list constructor.
- * </p>
- * <p>
- * Use the <code>getListeners</code> method when notifying listeners. The recommended
- * code sequence for notifying all registered listeners of say,
- * <code>FooListener.eventHappened</code>, is:
- *
- * <pre>
- * Object[] listeners = myListenerList.getListeners();
- * for (int i = 0; i &lt; listeners.length; ++i) {
- * ((FooListener) listeners[i]).eventHappened(event);
- * }
- * </pre>
- *
- * </p><p>
- * This class can be used without OSGi running.
- * </p>
- * @since org.eclipse.equinox.common 3.2
- */
-public class ListenerList {
-
- /**
- * The empty array singleton instance.
- */
- private static final Object[] EmptyArray = new Object[0];
-
- /**
- * Mode constant (value 0) indicating that listeners should be considered
- * the <a href="#same">same</a> if they are equal.
- */
- public static final int EQUALITY = 0;
-
- /**
- * Mode constant (value 1) indicating that listeners should be considered
- * the <a href="#same">same</a> if they are identical.
- */
- public static final int IDENTITY = 1;
-
- /**
- * Indicates the comparison mode used to determine if two
- * listeners are equivalent
- */
- private final boolean identity;
-
- /**
- * The list of listeners. Initially empty but initialized
- * to an array of size capacity the first time a listener is added.
- * Maintains invariant: listeners != null
- */
- private volatile Object[] listeners = EmptyArray;
-
- /**
- * Creates a listener list in which listeners are compared using equality.
- */
- public ListenerList() {
- this(EQUALITY);
- }
-
- /**
- * Creates a listener list using the provided comparison mode.
- *
- * @param mode The mode used to determine if listeners are the <a href="#same">same</a>.
- */
- public ListenerList(int mode) {
- if (mode != EQUALITY && mode != IDENTITY)
- throw new IllegalArgumentException();
- this.identity = mode == IDENTITY;
- }
-
- /**
- * Adds a listener to this list. This method has no effect if the <a href="#same">same</a>
- * listener is already registered.
- *
- * @param listener the non-<code>null</code> listener to add
- */
- public synchronized void add(Object listener) {
- // This method is synchronized to protect against multiple threads adding
- // or removing listeners concurrently. This does not block concurrent readers.
- if (listener == null)
- throw new IllegalArgumentException();
- // check for duplicates
- final int oldSize = listeners.length;
- for (int i = 0; i < oldSize; ++i) {
- Object listener2 = listeners[i];
- if (identity ? listener == listener2 : listener.equals(listener2))
- return;
- }
- // Thread safety: create new array to avoid affecting concurrent readers
- Object[] newListeners = new Object[oldSize + 1];
- System.arraycopy(listeners, 0, newListeners, 0, oldSize);
- newListeners[oldSize] = listener;
- //atomic assignment
- this.listeners = newListeners;
- }
-
- /**
- * Returns an array containing all the registered listeners.
- * The resulting array is unaffected by subsequent adds or removes.
- * If there are no listeners registered, the result is an empty array.
- * Use this method when notifying listeners, so that any modifications
- * to the listener list during the notification will have no effect on
- * the notification itself.
- * <p>
- * Note: Callers of this method <b>must not</b> modify the returned array.
- *
- * @return the list of registered listeners
- */
- public Object[] getListeners() {
- return listeners;
- }
-
- /**
- * Returns whether this listener list is empty.
- *
- * @return <code>true</code> if there are no registered listeners, and
- * <code>false</code> otherwise
- */
- public boolean isEmpty() {
- return listeners.length == 0;
- }
-
- /**
- * Removes a listener from this list. Has no effect if the <a href="#same">same</a>
- * listener was not already registered.
- *
- * @param listener the non-<code>null</code> listener to remove
- */
- public synchronized void remove(Object listener) {
- // This method is synchronized to protect against multiple threads adding
- // or removing listeners concurrently. This does not block concurrent readers.
- if (listener == null)
- throw new IllegalArgumentException();
- int oldSize = listeners.length;
- for (int i = 0; i < oldSize; ++i) {
- Object listener2 = listeners[i];
- if (identity ? listener == listener2 : listener.equals(listener2)) {
- if (oldSize == 1) {
- listeners = EmptyArray;
- } else {
- // Thread safety: create new array to avoid affecting concurrent readers
- Object[] newListeners = new Object[oldSize - 1];
- System.arraycopy(listeners, 0, newListeners, 0, i);
- System.arraycopy(listeners, i + 1, newListeners, i, oldSize - i - 1);
- //atomic assignment to field
- this.listeners = newListeners;
- }
- return;
- }
- }
- }
-
- /**
- * Returns the number of registered listeners.
- *
- * @return the number of registered listeners
- */
- public int size() {
- return listeners.length;
- }
-
- /**
- * Removes all listeners from this list.
- */
- public synchronized void clear() {
- listeners = EmptyArray;
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/MultiStatus.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/MultiStatus.java
deleted file mode 100644
index 8f74789f1..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/MultiStatus.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * A concrete multi-status implementation,
- * suitable either for instantiating or subclassing.
- * <p>
- * This class can be used without OSGi running.
- * </p>
- */
-public class MultiStatus extends Status {
-
- /** List of child statuses.
- */
- private IStatus[] children;
-
- /**
- * Creates and returns a new multi-status object with the given children.
- *
- * @param pluginId the unique identifier of the relevant plug-in
- * @param code the plug-in-specific status code
- * @param newChildren the list of children status objects
- * @param message a human-readable message, localized to the
- * current locale
- * @param exception a low-level exception, or <code>null</code> if not
- * applicable
- */
- public MultiStatus(String pluginId, int code, IStatus[] newChildren, String message, Throwable exception) {
- this(pluginId, code, message, exception);
- Assert.isLegal(newChildren != null);
- int maxSeverity = getSeverity();
- for (int i = 0; i < newChildren.length; i++) {
- Assert.isLegal(newChildren[i] != null);
- int severity = newChildren[i].getSeverity();
- if (severity > maxSeverity)
- maxSeverity = severity;
- }
- this.children = new IStatus[newChildren.length];
- setSeverity(maxSeverity);
- System.arraycopy(newChildren, 0, this.children, 0, newChildren.length);
- }
-
- /**
- * Creates and returns a new multi-status object with no children.
- *
- * @param pluginId the unique identifier of the relevant plug-in
- * @param code the plug-in-specific status code
- * @param message a human-readable message, localized to the
- * current locale
- * @param exception a low-level exception, or <code>null</code> if not
- * applicable
- */
- public MultiStatus(String pluginId, int code, String message, Throwable exception) {
- super(OK, pluginId, code, message, exception);
- children = new IStatus[0];
- }
-
- /**
- * Adds the given status to this multi-status.
- *
- * @param status the new child status
- */
- public void add(IStatus status) {
- Assert.isLegal(status != null);
- IStatus[] result = new IStatus[children.length + 1];
- System.arraycopy(children, 0, result, 0, children.length);
- result[result.length - 1] = status;
- children = result;
- int newSev = status.getSeverity();
- if (newSev > getSeverity()) {
- setSeverity(newSev);
- }
- }
-
- /**
- * Adds all of the children of the given status to this multi-status.
- * Does nothing if the given status has no children (which includes
- * the case where it is not a multi-status).
- *
- * @param status the status whose children are to be added to this one
- */
- public void addAll(IStatus status) {
- Assert.isLegal(status != null);
- IStatus[] statuses = status.getChildren();
- for (int i = 0; i < statuses.length; i++) {
- add(statuses[i]);
- }
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public IStatus[] getChildren() {
- return children;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public boolean isMultiStatus() {
- return true;
- }
-
- /**
- * Merges the given status into this multi-status.
- * Equivalent to <code>add(status)</code> if the
- * given status is not a multi-status.
- * Equivalent to <code>addAll(status)</code> if the
- * given status is a multi-status.
- *
- * @param status the status to merge into this one
- * @see #add(IStatus)
- * @see #addAll(IStatus)
- */
- public void merge(IStatus status) {
- Assert.isLegal(status != null);
- if (!status.isMultiStatus()) {
- add(status);
- } else {
- addAll(status);
- }
- }
-
- /**
- * Returns a string representation of the status, suitable
- * for debugging purposes only.
- */
- public String toString() {
- StringBuffer buf = new StringBuffer(super.toString());
- buf.append(" children=["); //$NON-NLS-1$
- for (int i = 0; i < children.length; i++) {
- if (i != 0) {
- buf.append(" "); //$NON-NLS-1$
- }
- buf.append(children[i].toString());
- }
- buf.append("]"); //$NON-NLS-1$
- return buf.toString();
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/NullProgressMonitor.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/NullProgressMonitor.java
deleted file mode 100644
index 5a7c2611a..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/NullProgressMonitor.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * A default progress monitor implementation suitable for
- * subclassing.
- * <p>
- * This implementation supports cancelation. The default
- * implementations of the other methods do nothing.
- * </p><p>
- * This class can be used without OSGi running.
- * </p>
- */
-public class NullProgressMonitor implements IProgressMonitor {
-
- /**
- * Indicates whether cancel has been requested.
- */
- private boolean cancelled = false;
-
- /**
- * Constructs a new progress monitor.
- */
- public NullProgressMonitor() {
- super();
- }
-
- /**
- * This implementation does nothing.
- * Subclasses may override this method to do interesting
- * processing when a task begins.
- *
- * @see IProgressMonitor#beginTask(String, int)
- */
- public void beginTask(String name, int totalWork) {
- // do nothing
- }
-
- /**
- * This implementation does nothing.
- * Subclasses may override this method to do interesting
- * processing when a task is done.
- *
- * @see IProgressMonitor#done()
- */
- public void done() {
- // do nothing
- }
-
- /**
- * This implementation does nothing.
- * Subclasses may override this method.
- *
- * @see IProgressMonitor#internalWorked(double)
- */
- public void internalWorked(double work) {
- // do nothing
- }
-
- /**
- * This implementation returns the value of the internal
- * state variable set by <code>setCanceled</code>.
- * Subclasses which override this method should
- * override <code>setCanceled</code> as well.
- *
- * @see IProgressMonitor#isCanceled()
- * @see IProgressMonitor#setCanceled(boolean)
- */
- public boolean isCanceled() {
- return cancelled;
- }
-
- /**
- * This implementation sets the value of an internal state variable.
- * Subclasses which override this method should override
- * <code>isCanceled</code> as well.
- *
- * @see IProgressMonitor#isCanceled()
- * @see IProgressMonitor#setCanceled(boolean)
- */
- public void setCanceled(boolean cancelled) {
- this.cancelled = cancelled;
- }
-
- /**
- * This implementation does nothing.
- * Subclasses may override this method to do something
- * with the name of the task.
- *
- * @see IProgressMonitor#setTaskName(String)
- */
- public void setTaskName(String name) {
- // do nothing
- }
-
- /**
- * This implementation does nothing.
- * Subclasses may override this method to do interesting
- * processing when a subtask begins.
- *
- * @see IProgressMonitor#subTask(String)
- */
- public void subTask(String name) {
- // do nothing
- }
-
- /**
- * This implementation does nothing.
- * Subclasses may override this method to do interesting
- * processing when some work has been completed.
- *
- * @see IProgressMonitor#worked(int)
- */
- public void worked(int work) {
- // do nothing
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/OperationCanceledException.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/OperationCanceledException.java
deleted file mode 100644
index 75bfffda3..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/OperationCanceledException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * This exception is thrown to blow out of a long-running method
- * when the user cancels it.
- * <p>
- * This class can be used without OSGi running.
- * </p><p>
- * This class is not intended to be subclassed by clients but
- * may be instantiated.
- * </p>
- */
-public final class OperationCanceledException extends RuntimeException {
- /**
- * All serializable objects should have a stable serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * Creates a new exception.
- */
- public OperationCanceledException() {
- super();
- }
-
- /**
- * Creates a new exception with the given message.
- *
- * @param message the message for the exception
- */
- public OperationCanceledException(String message) {
- super(message);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java
deleted file mode 100644
index 5e194a0d1..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java
+++ /dev/null
@@ -1,989 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import java.io.File;
-
-/**
- * The standard implementation of the <code>IPath</code> interface.
- * Paths are always maintained in canonicalized form. That is, parent
- * references (i.e., <code>../../</code>) and duplicate separators are
- * resolved. For example,
- * <pre> new Path("/a/b").append("../foo/bar")</pre>
- * will yield the path
- * <pre> /a/foo/bar</pre>
- * <p>
- * This class can be used without OSGi running.
- * </p><p>
- * This class is not intended to be subclassed by clients but
- * may be instantiated.
- * </p>
- * @see IPath
- */
-public class Path implements IPath, Cloneable {
- /** masks for separator values */
- private static final int HAS_LEADING = 1;
- private static final int IS_UNC = 2;
- private static final int HAS_TRAILING = 4;
-
- private static final int ALL_SEPARATORS = HAS_LEADING | IS_UNC | HAS_TRAILING;
-
- /** Constant empty string value. */
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
- /** Constant value indicating no segments */
- private static final String[] NO_SEGMENTS = new String[0];
-
- /** Constant value containing the empty path with no device. */
- public static final Path EMPTY = new Path(EMPTY_STRING);
-
- /** Mask for all bits that are involved in the hash code */
- private static final int HASH_MASK = ~HAS_TRAILING;
-
-
- /** Constant root path string (<code>"/"</code>). */
- private static final String ROOT_STRING = "/"; //$NON-NLS-1$
-
- /** Constant value containing the root path with no device. */
- public static final Path ROOT = new Path(ROOT_STRING);
-
- /** Constant value indicating if the current platform is Windows */
- private static final boolean WINDOWS = java.io.File.separatorChar == '\\';
-
- /** The device id string. May be null if there is no device. */
- private String device = null;
-
- //Private implementation note: the segments and separators
- //arrays are never modified, so that they can be shared between
- //path instances
-
- /** The path segments */
- private String[] segments;
-
- /** flags indicating separators (has leading, is UNC, has trailing) */
- private int separators;
-
- /**
- * Constructs a new path from the given string path.
- * The string path must represent a valid file system path
- * on the local file system.
- * The path is canonicalized and double slashes are removed
- * except at the beginning. (to handle UNC paths). All forward
- * slashes ('/') are treated as segment delimiters, and any
- * segment and device delimiters for the local file system are
- * also respected.
- *
- * @param pathString the portable string path
- * @see IPath#toPortableString()
- * @since 3.1
- */
- public static IPath fromOSString(String pathString) {
- return new Path(pathString);
- }
-
- /**
- * Constructs a new path from the given path string.
- * The path string must have been produced by a previous
- * call to <code>IPath.toPortableString</code>.
- *
- * @param pathString the portable path string
- * @see IPath#toPortableString()
- * @since 3.1
- */
- public static IPath fromPortableString(String pathString) {
- int firstMatch = pathString.indexOf(DEVICE_SEPARATOR) +1;
- //no extra work required if no device characters
- if (firstMatch <= 0)
- return new Path().initialize(null, pathString);
- //if we find a single colon, then the path has a device
- String devicePart = null;
- int pathLength = pathString.length();
- if (firstMatch == pathLength || pathString.charAt(firstMatch) != DEVICE_SEPARATOR) {
- devicePart = pathString.substring(0, firstMatch);
- pathString = pathString.substring(firstMatch, pathLength);
- }
- //optimize for no colon literals
- if (pathString.indexOf(DEVICE_SEPARATOR) == -1)
- return new Path().initialize(devicePart, pathString);
- //contract colon literals
- char[] chars = pathString.toCharArray();
- int readOffset = 0, writeOffset = 0, length = chars.length;
- while (readOffset < length) {
- if (chars[readOffset] == DEVICE_SEPARATOR)
- if (++readOffset >= length)
- break;
- chars[writeOffset++] = chars[readOffset++];
- }
- return new Path().initialize(devicePart, new String(chars, 0, writeOffset));
- }
-
- /* (Intentionally not included in javadoc)
- * Private constructor.
- */
- private Path() {
- // not allowed
- }
-
- /**
- * Constructs a new path from the given string path.
- * The string path must represent a valid file system path
- * on the local file system.
- * The path is canonicalized and double slashes are removed
- * except at the beginning. (to handle UNC paths). All forward
- * slashes ('/') are treated as segment delimiters, and any
- * segment and device delimiters for the local file system are
- * also respected (such as colon (':') and backslash ('\') on some file systems).
- *
- * @param fullPath the string path
- * @see #isValidPath(String)
- */
- public Path(String fullPath) {
- String devicePart = null;
- if (WINDOWS) {
- //convert backslash to forward slash
- fullPath = fullPath.indexOf('\\') == -1 ? fullPath : fullPath.replace('\\', SEPARATOR);
- //extract device
- int i = fullPath.indexOf(DEVICE_SEPARATOR);
- if (i != -1) {
- //remove leading slash from device part to handle output of URL.getFile()
- int start = fullPath.charAt(0) == SEPARATOR ? 1 : 0;
- devicePart = fullPath.substring(start, i + 1);
- fullPath = fullPath.substring(i + 1, fullPath.length());
- }
- }
- initialize(devicePart, fullPath);
- }
-
- /**
- * Constructs a new path from the given device id and string path.
- * The given string path must be valid.
- * The path is canonicalized and double slashes are removed except
- * at the beginning (to handle UNC paths). All forward
- * slashes ('/') are treated as segment delimiters, and any
- * segment delimiters for the local file system are
- * also respected (such as backslash ('\') on some file systems).
- *
- * @param device the device id
- * @param path the string path
- * @see #isValidPath(String)
- * @see #setDevice(String)
- */
- public Path(String device, String path) {
- if (WINDOWS) {
- //convert backslash to forward slash
- path = path.indexOf('\\') == -1 ? path : path.replace('\\', SEPARATOR);
- }
- initialize(device, path);
- }
-
- /* (Intentionally not included in javadoc)
- * Private constructor.
- */
- private Path(String device, String[] segments, int _separators) {
- // no segment validations are done for performance reasons
- this.segments = segments;
- this.device = device;
- //hash code is cached in all but the bottom three bits of the separators field
- this.separators = (computeHashCode() << 3) | (_separators & ALL_SEPARATORS);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#addFileExtension
- */
- public IPath addFileExtension(String extension) {
- if (isRoot() || isEmpty() || hasTrailingSeparator())
- return this;
- int len = segments.length;
- String[] newSegments = new String[len];
- System.arraycopy(segments, 0, newSegments, 0, len - 1);
- newSegments[len - 1] = segments[len - 1] + '.' + extension;
- return new Path(device, newSegments, separators);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#addTrailingSeparator
- */
- public IPath addTrailingSeparator() {
- if (hasTrailingSeparator() || isRoot()) {
- return this;
- }
- //XXX workaround, see 1GIGQ9V
- if (isEmpty()) {
- return new Path(device, segments, HAS_LEADING);
- }
- return new Path(device, segments, separators | HAS_TRAILING);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#append(IPath)
- */
- public IPath append(IPath tail) {
- //optimize some easy cases
- if (tail == null || tail.segmentCount() == 0)
- return this;
- //these call chains look expensive, but in most cases they are no-ops
- if (this.isEmpty())
- return tail.setDevice(device).makeRelative().makeUNC(isUNC());
- if (this.isRoot())
- return tail.setDevice(device).makeAbsolute().makeUNC(isUNC());
-
- //concatenate the two segment arrays
- int myLen = segments.length;
- int tailLen = tail.segmentCount();
- String[] newSegments = new String[myLen + tailLen];
- System.arraycopy(segments, 0, newSegments, 0, myLen);
- for (int i = 0; i < tailLen; i++) {
- newSegments[myLen + i] = tail.segment(i);
- }
- //use my leading separators and the tail's trailing separator
- Path result = new Path(device, newSegments, (separators & (HAS_LEADING | IS_UNC)) | (tail.hasTrailingSeparator() ? HAS_TRAILING : 0));
- String tailFirstSegment = newSegments[myLen];
- if (tailFirstSegment.equals("..") || tailFirstSegment.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$
- result.canonicalize();
- }
- return result;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#append(java.lang.String)
- */
- public IPath append(String tail) {
- //optimize addition of a single segment
- if (tail.indexOf(SEPARATOR) == -1 && tail.indexOf("\\") == -1 && tail.indexOf(DEVICE_SEPARATOR) == -1) { //$NON-NLS-1$
- int tailLength = tail.length();
- if (tailLength < 3) {
- //some special cases
- if (tailLength == 0 || ".".equals(tail)) { //$NON-NLS-1$
- return this;
- }
- if ("..".equals(tail)) //$NON-NLS-1$
- return removeLastSegments(1);
- }
- //just add the segment
- int myLen = segments.length;
- String[] newSegments = new String[myLen + 1];
- System.arraycopy(segments, 0, newSegments, 0, myLen);
- newSegments[myLen] = tail;
- return new Path(device, newSegments, separators & ~HAS_TRAILING);
- }
- //go with easy implementation
- return append(new Path(tail));
- }
-
- /**
- * Destructively converts this path to its canonical form.
- * <p>
- * In its canonical form, a path does not have any
- * "." segments, and parent references ("..") are collapsed
- * where possible.
- * </p>
- * @return true if the path was modified, and false otherwise.
- */
- private boolean canonicalize() {
- //look for segments that need canonicalizing
- for (int i = 0, max = segments.length; i < max; i++) {
- String segment = segments[i];
- if (segment.charAt(0) == '.' && (segment.equals("..") || segment.equals("."))) { //$NON-NLS-1$ //$NON-NLS-2$
- //path needs to be canonicalized
- collapseParentReferences();
- //paths of length 0 have no trailing separator
- if (segments.length == 0)
- separators &= (HAS_LEADING | IS_UNC);
- //recompute hash because canonicalize affects hash
- separators = (separators & ALL_SEPARATORS) | (computeHashCode() << 3);
- return true;
- }
- }
- return false;
- }
-
- /* (Intentionally not included in javadoc)
- * Clones this object.
- */
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
-
- /**
- * Destructively removes all occurrences of ".." segments from this path.
- */
- private void collapseParentReferences() {
- int segmentCount = segments.length;
- String[] stack = new String[segmentCount];
- int stackPointer = 0;
- for (int i = 0; i < segmentCount; i++) {
- String segment = segments[i];
- if (segment.equals("..")) { //$NON-NLS-1$
- if (stackPointer == 0) {
- // if the stack is empty we are going out of our scope
- // so we need to accumulate segments. But only if the original
- // path is relative. If it is absolute then we can't go any higher than
- // root so simply toss the .. references.
- if (!isAbsolute())
- stack[stackPointer++] = segment; //stack push
- } else {
- // if the top is '..' then we are accumulating segments so don't pop
- if ("..".equals(stack[stackPointer - 1])) //$NON-NLS-1$
- stack[stackPointer++] = ".."; //$NON-NLS-1$
- else
- stackPointer--;
- //stack pop
- }
- //collapse current references
- } else if (!segment.equals(".") || segmentCount == 1) //$NON-NLS-1$
- stack[stackPointer++] = segment; //stack push
- }
- //if the number of segments hasn't changed, then no modification needed
- if (stackPointer == segmentCount)
- return;
- //build the new segment array backwards by popping the stack
- String[] newSegments = new String[stackPointer];
- System.arraycopy(stack, 0, newSegments, 0, stackPointer);
- this.segments = newSegments;
- }
-
- /**
- * Removes duplicate slashes from the given path, with the exception
- * of leading double slash which represents a UNC path.
- */
- private String collapseSlashes(String path) {
- int length = path.length();
- // if the path is only 0, 1 or 2 chars long then it could not possibly have illegal
- // duplicate slashes.
- if (length < 3)
- return path;
- // check for an occurrence of // in the path. Start at index 1 to ensure we skip leading UNC //
- // If there are no // then there is nothing to collapse so just return.
- if (path.indexOf("//", 1) == -1) //$NON-NLS-1$
- return path;
- // We found an occurrence of // in the path so do the slow collapse.
- char[] result = new char[path.length()];
- int count = 0;
- boolean hasPrevious = false;
- char[] characters = path.toCharArray();
- for (int index = 0; index < characters.length; index++) {
- char c = characters[index];
- if (c == SEPARATOR) {
- if (hasPrevious) {
- // skip double slashes, except for beginning of UNC.
- // note that a UNC path can't have a device.
- if (device == null && index == 1) {
- result[count] = c;
- count++;
- }
- } else {
- hasPrevious = true;
- result[count] = c;
- count++;
- }
- } else {
- hasPrevious = false;
- result[count] = c;
- count++;
- }
- }
- return new String(result, 0, count);
- }
-
- /* (Intentionally not included in javadoc)
- * Computes the hash code for this object.
- */
- private int computeHashCode() {
- int hash = device == null ? 17 : device.hashCode();
- int segmentCount = segments.length;
- for (int i = 0; i < segmentCount; i++) {
- //this function tends to given a fairly even distribution
- hash = hash * 37 + segments[i].hashCode();
- }
- return hash;
- }
-
- /* (Intentionally not included in javadoc)
- * Returns the size of the string that will be created by toString or toOSString.
- */
- private int computeLength() {
- int length = 0;
- if (device != null)
- length += device.length();
- if ((separators & HAS_LEADING) != 0)
- length++;
- if ((separators & IS_UNC) != 0)
- length++;
- //add the segment lengths
- int max = segments.length;
- if (max > 0) {
- for (int i = 0; i < max; i++) {
- length += segments[i].length();
- }
- //add the separator lengths
- length += max - 1;
- }
- if ((separators & HAS_TRAILING) != 0)
- length++;
- return length;
- }
-
- /* (Intentionally not included in javadoc)
- * Returns the number of segments in the given path
- */
- private int computeSegmentCount(String path) {
- int len = path.length();
- if (len == 0 || (len == 1 && path.charAt(0) == SEPARATOR)) {
- return 0;
- }
- int count = 1;
- int prev = -1;
- int i;
- while ((i = path.indexOf(SEPARATOR, prev + 1)) != -1) {
- if (i != prev + 1 && i != len) {
- ++count;
- }
- prev = i;
- }
- if (path.charAt(len - 1) == SEPARATOR) {
- --count;
- }
- return count;
- }
-
- /**
- * Computes the segment array for the given canonicalized path.
- */
- private String[] computeSegments(String path) {
- // performance sensitive --- avoid creating garbage
- int segmentCount = computeSegmentCount(path);
- if (segmentCount == 0)
- return NO_SEGMENTS;
- String[] newSegments = new String[segmentCount];
- int len = path.length();
- // check for initial slash
- int firstPosition = (path.charAt(0) == SEPARATOR) ? 1 : 0;
- // check for UNC
- if (firstPosition == 1 && len > 1 && (path.charAt(1) == SEPARATOR))
- firstPosition = 2;
- int lastPosition = (path.charAt(len - 1) != SEPARATOR) ? len - 1 : len - 2;
- // for non-empty paths, the number of segments is
- // the number of slashes plus 1, ignoring any leading
- // and trailing slashes
- int next = firstPosition;
- for (int i = 0; i < segmentCount; i++) {
- int start = next;
- int end = path.indexOf(SEPARATOR, next);
- if (end == -1) {
- newSegments[i] = path.substring(start, lastPosition + 1);
- } else {
- newSegments[i] = path.substring(start, end);
- }
- next = end + 1;
- }
- return newSegments;
- }
- /**
- * Returns the platform-neutral encoding of the given segment onto
- * the given string buffer. This escapes literal colon characters with double colons.
- */
- private void encodeSegment(String string, StringBuffer buf) {
- int len = string.length();
- for (int i = 0; i < len; i++) {
- char c = string.charAt(i);
- buf.append(c);
- if (c == DEVICE_SEPARATOR)
- buf.append(DEVICE_SEPARATOR);
- }
- }
-
- /* (Intentionally not included in javadoc)
- * Compares objects for equality.
- */
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!(obj instanceof Path))
- return false;
- Path target = (Path) obj;
- //check leading separators and hash code
- if ((separators & HASH_MASK) != (target.separators & HASH_MASK))
- return false;
- String[] targetSegments = target.segments;
- int i = segments.length;
- //check segment count
- if (i != targetSegments.length)
- return false;
- //check segments in reverse order - later segments more likely to differ
- while (--i >= 0)
- if (!segments[i].equals(targetSegments[i]))
- return false;
- //check device last (least likely to differ)
- return device == target.device || (device != null && device.equals(target.device));
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#getDevice
- */
- public String getDevice() {
- return device;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#getFileExtension
- */
- public String getFileExtension() {
- if (hasTrailingSeparator()) {
- return null;
- }
- String lastSegment = lastSegment();
- if (lastSegment == null) {
- return null;
- }
- int index = lastSegment.lastIndexOf('.');
- if (index == -1) {
- return null;
- }
- return lastSegment.substring(index + 1);
- }
-
- /* (Intentionally not included in javadoc)
- * Computes the hash code for this object.
- */
- public int hashCode() {
- return separators & HASH_MASK;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#hasTrailingSeparator2
- */
- public boolean hasTrailingSeparator() {
- return (separators & HAS_TRAILING) != 0;
- }
-
- /*
- * Initialize the current path with the given string.
- */
- private IPath initialize(String deviceString, String path) {
- Assert.isNotNull(path);
- this.device = deviceString;
-
- path = collapseSlashes(path);
- int len = path.length();
-
- //compute the separators array
- if (len < 2) {
- if (len == 1 && path.charAt(0) == SEPARATOR) {
- this.separators = HAS_LEADING;
- } else {
- this.separators = 0;
- }
- } else {
- boolean hasLeading = path.charAt(0) == SEPARATOR;
- boolean isUNC = hasLeading && path.charAt(1) == SEPARATOR;
- //UNC path of length two has no trailing separator
- boolean hasTrailing = !(isUNC && len == 2) && path.charAt(len - 1) == SEPARATOR;
- separators = hasLeading ? HAS_LEADING : 0;
- if (isUNC)
- separators |= IS_UNC;
- if (hasTrailing)
- separators |= HAS_TRAILING;
- }
- //compute segments and ensure canonical form
- segments = computeSegments(path);
- if (!canonicalize()) {
- //compute hash now because canonicalize didn't need to do it
- separators = (separators & ALL_SEPARATORS) | (computeHashCode() << 3);
- }
- return this;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isAbsolute
- */
- public boolean isAbsolute() {
- //it's absolute if it has a leading separator
- return (separators & HAS_LEADING) != 0;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isEmpty
- */
- public boolean isEmpty() {
- //true if no segments and no leading prefix
- return segments.length == 0 && ((separators & ALL_SEPARATORS) != HAS_LEADING);
-
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isPrefixOf
- */
- public boolean isPrefixOf(IPath anotherPath) {
- if (device == null) {
- if (anotherPath.getDevice() != null) {
- return false;
- }
- } else {
- if (!device.equalsIgnoreCase(anotherPath.getDevice())) {
- return false;
- }
- }
- if (isEmpty() || (isRoot() && anotherPath.isAbsolute())) {
- return true;
- }
- int len = segments.length;
- if (len > anotherPath.segmentCount()) {
- return false;
- }
- for (int i = 0; i < len; i++) {
- if (!segments[i].equals(anotherPath.segment(i)))
- return false;
- }
- return true;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isRoot
- */
- public boolean isRoot() {
- //must have no segments, a leading separator, and not be a UNC path.
- return this == ROOT || (segments.length == 0 && ((separators & ALL_SEPARATORS) == HAS_LEADING));
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isUNC
- */
- public boolean isUNC() {
- if (device != null)
- return false;
- return (separators & IS_UNC) != 0;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isValidPath(String)
- */
- public boolean isValidPath(String path) {
- Path test = new Path(path);
- for (int i = 0, max = test.segmentCount(); i < max; i++)
- if (!isValidSegment(test.segment(i)))
- return false;
- return true;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#isValidSegment(String)
- */
- public boolean isValidSegment(String segment) {
- int size = segment.length();
- if (size == 0)
- return false;
- for (int i = 0; i < size; i++) {
- char c = segment.charAt(i);
- if (c == '/')
- return false;
- if (WINDOWS && (c == '\\' || c == ':'))
- return false;
- }
- return true;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#lastSegment()
- */
- public String lastSegment() {
- int len = segments.length;
- return len == 0 ? null : segments[len - 1];
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#makeAbsolute()
- */
- public IPath makeAbsolute() {
- if (isAbsolute()) {
- return this;
- }
- Path result = new Path(device, segments, separators | HAS_LEADING);
- //may need canonicalizing if it has leading ".." or "." segments
- if (result.segmentCount() > 0) {
- String first = result.segment(0);
- if (first.equals("..") || first.equals(".")) { //$NON-NLS-1$ //$NON-NLS-2$
- result.canonicalize();
- }
- }
- return result;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#makeRelative()
- */
- public IPath makeRelative() {
- if (!isAbsolute()) {
- return this;
- }
- return new Path(device, segments, separators & HAS_TRAILING);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#makeUNC(boolean)
- */
- public IPath makeUNC(boolean toUNC) {
- // if we are already in the right form then just return
- if (!(toUNC ^ isUNC()))
- return this;
-
- int newSeparators = this.separators;
- if (toUNC) {
- newSeparators |= HAS_LEADING | IS_UNC;
- } else {
- //mask out the UNC bit
- newSeparators &= HAS_LEADING | HAS_TRAILING;
- }
- return new Path(toUNC ? null : device, segments, newSeparators);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#matchingFirstSegments(IPath)
- */
- public int matchingFirstSegments(IPath anotherPath) {
- Assert.isNotNull(anotherPath);
- int anotherPathLen = anotherPath.segmentCount();
- int max = Math.min(segments.length, anotherPathLen);
- int count = 0;
- for (int i = 0; i < max; i++) {
- if (!segments[i].equals(anotherPath.segment(i))) {
- return count;
- }
- count++;
- }
- return count;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#removeFileExtension()
- */
- public IPath removeFileExtension() {
- String extension = getFileExtension();
- if (extension == null || extension.equals("")) { //$NON-NLS-1$
- return this;
- }
- String lastSegment = lastSegment();
- int index = lastSegment.lastIndexOf(extension) - 1;
- return removeLastSegments(1).append(lastSegment.substring(0, index));
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#removeFirstSegments(int)
- */
- public IPath removeFirstSegments(int count) {
- if (count == 0)
- return this;
- if (count >= segments.length) {
- return new Path(device, NO_SEGMENTS, 0);
- }
- Assert.isLegal(count > 0);
- int newSize = segments.length - count;
- String[] newSegments = new String[newSize];
- System.arraycopy(this.segments, count, newSegments, 0, newSize);
-
- //result is always a relative path
- return new Path(device, newSegments, separators & HAS_TRAILING);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#removeLastSegments(int)
- */
- public IPath removeLastSegments(int count) {
- if (count == 0)
- return this;
- if (count >= segments.length) {
- //result will have no trailing separator
- return new Path(device, NO_SEGMENTS, separators & (HAS_LEADING | IS_UNC));
- }
- Assert.isLegal(count > 0);
- int newSize = segments.length - count;
- String[] newSegments = new String[newSize];
- System.arraycopy(this.segments, 0, newSegments, 0, newSize);
- return new Path(device, newSegments, separators);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#removeTrailingSeparator()
- */
- public IPath removeTrailingSeparator() {
- if (!hasTrailingSeparator()) {
- return this;
- }
- return new Path(device, segments, separators & (HAS_LEADING | IS_UNC));
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#segment(int)
- */
- public String segment(int index) {
- if (index >= segments.length)
- return null;
- return segments[index];
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#segmentCount()
- */
- public int segmentCount() {
- return segments.length;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#segments()
- */
- public String[] segments() {
- String[] segmentCopy = new String[segments.length];
- System.arraycopy(segments, 0, segmentCopy, 0, segments.length);
- return segmentCopy;
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#setDevice(String)
- */
- public IPath setDevice(String value) {
- if (value != null) {
- Assert.isTrue(value.indexOf(IPath.DEVICE_SEPARATOR) == (value.length() - 1), "Last character should be the device separator"); //$NON-NLS-1$
- }
- //return the receiver if the device is the same
- if (value == device || (value != null && value.equals(device)))
- return this;
-
- return new Path(value, segments, separators);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#toFile()
- */
- public File toFile() {
- return new File(toOSString());
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#toOSString()
- */
- public String toOSString() {
- //Note that this method is identical to toString except
- //it uses the OS file separator instead of the path separator
- int resultSize = computeLength();
- if (resultSize <= 0)
- return EMPTY_STRING;
- char FILE_SEPARATOR = File.separatorChar;
- char[] result = new char[resultSize];
- int offset = 0;
- if (device != null) {
- int size = device.length();
- device.getChars(0, size, result, offset);
- offset += size;
- }
- if ((separators & HAS_LEADING) != 0)
- result[offset++] = FILE_SEPARATOR;
- if ((separators & IS_UNC) != 0)
- result[offset++] = FILE_SEPARATOR;
- int len = segments.length - 1;
- if (len >= 0) {
- //append all but the last segment, with separators
- for (int i = 0; i < len; i++) {
- int size = segments[i].length();
- segments[i].getChars(0, size, result, offset);
- offset += size;
- result[offset++] = FILE_SEPARATOR;
- }
- //append the last segment
- int size = segments[len].length();
- segments[len].getChars(0, size, result, offset);
- offset += size;
- }
- if ((separators & HAS_TRAILING) != 0)
- result[offset++] = FILE_SEPARATOR;
- return new String(result);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#toPortableString()
- */
- public String toPortableString() {
- int resultSize = computeLength();
- if (resultSize <= 0)
- return EMPTY_STRING;
- StringBuffer result = new StringBuffer(resultSize);
- if (device != null)
- result.append(device);
- if ((separators & HAS_LEADING) != 0)
- result.append(SEPARATOR);
- if ((separators & IS_UNC) != 0)
- result.append(SEPARATOR);
- int len = segments.length;
- //append all segments with separators
- for (int i = 0; i < len; i++) {
- if (segments[i].indexOf(DEVICE_SEPARATOR) >= 0)
- encodeSegment(segments[i], result);
- else
- result.append(segments[i]);
- if (i < len-1 || (separators & HAS_TRAILING) != 0)
- result.append(SEPARATOR);
- }
- return result.toString();
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#toString()
- */
- public String toString() {
- int resultSize = computeLength();
- if (resultSize <= 0)
- return EMPTY_STRING;
- char[] result = new char[resultSize];
- int offset = 0;
- if (device != null) {
- int size = device.length();
- device.getChars(0, size, result, offset);
- offset += size;
- }
- if ((separators & HAS_LEADING) != 0)
- result[offset++] = SEPARATOR;
- if ((separators & IS_UNC) != 0)
- result[offset++] = SEPARATOR;
- int len = segments.length - 1;
- if (len >= 0) {
- //append all but the last segment, with separators
- for (int i = 0; i < len; i++) {
- int size = segments[i].length();
- segments[i].getChars(0, size, result, offset);
- offset += size;
- result[offset++] = SEPARATOR;
- }
- //append the last segment
- int size = segments[len].length();
- segments[len].getChars(0, size, result, offset);
- offset += size;
- }
- if ((separators & HAS_TRAILING) != 0)
- result[offset++] = SEPARATOR;
- return new String(result);
- }
-
- /* (Intentionally not included in javadoc)
- * @see IPath#uptoSegment(int)
- */
- public IPath uptoSegment(int count) {
- if (count == 0)
- return new Path(device, NO_SEGMENTS, separators & (HAS_LEADING | IS_UNC));
- if (count >= segments.length)
- return this;
- Assert.isTrue(count > 0, "Invalid parameter to Path.uptoSegment"); //$NON-NLS-1$
- String[] newSegments = new String[count];
- System.arraycopy(segments, 0, newSegments, 0, count);
- return new Path(device, newSegments, separators);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PlatformObject.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PlatformObject.java
deleted file mode 100644
index 4f993afea..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PlatformObject.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import org.eclipse.core.internal.runtime.AdapterManager;
-
-/**
- * An abstract superclass implementing the <code>IAdaptable</code>
- * interface. <code>getAdapter</code> invocations are directed
- * to the platform's adapter manager.
- * <p>
- * Note: In situations where it would be awkward to subclass this
- * class, the same affect can be achieved simply by implementing
- * the {@link IAdaptable} interface and explicitly forwarding
- * the <code>getAdapter</code> request to an implementation
- * of the {@link IAdapterManager} service. The method would look like:
- * <pre>
- * public Object getAdapter(Class adapter) {
- * IAdapterManager manager = ...;//lookup the IAdapterManager service
- * return manager.getAdapter(this, adapter);
- * }
- * </pre>
- * </p><p>
- * This class can be used without OSGi running.
- * </p><p>
- * Clients may subclass.
- * </p>
- *
- * @see IAdapterManager
- * @see IAdaptable
- */
-public abstract class PlatformObject implements IAdaptable {
- /**
- * Constructs a new platform object.
- */
- public PlatformObject() {
- super();
- }
-
- /**
- * Returns an object which is an instance of the given class
- * associated with this object. Returns <code>null</code> if
- * no such object can be found.
- * <p>
- * This implementation of the method declared by <code>IAdaptable</code>
- * passes the request along to the platform's adapter manager; roughly
- * <code>Platform.getAdapterManager().getAdapter(this, adapter)</code>.
- * Subclasses may override this method (however, if they do so, they
- * should invoke the method on their superclass to ensure that the
- * Platform's adapter manager is consulted).
- * </p>
- *
- * @param adapter the class to adapt to
- * @return the adapted object or <code>null</code>
- * @see IAdaptable#getAdapter(Class)
- */
- public Object getAdapter(Class adapter) {
- return AdapterManager.getDefault().getAdapter(this, adapter);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PluginVersionIdentifier.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PluginVersionIdentifier.java
deleted file mode 100644
index 44f05ee5c..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PluginVersionIdentifier.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import java.util.StringTokenizer;
-import java.util.Vector;
-import org.eclipse.core.internal.runtime.CommonMessages;
-import org.eclipse.core.internal.runtime.IRuntimeConstants;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Version;
-
-/**
- * <p>
- * Version identifier for a plug-in. In its string representation,
- * it consists of up to 4 tokens separated by a decimal point.
- * The first 3 tokens are positive integer numbers, the last token
- * is an uninterpreted string (no whitespace characters allowed).
- * For example, the following are valid version identifiers
- * (as strings):
- * <ul>
- * <li><code>0.0.0</code></li>
- * <li><code>1.0.127564</code></li>
- * <li><code>3.7.2.build-127J</code></li>
- * <li><code>1.9</code> (interpreted as <code>1.9.0</code>)</li>
- * <li><code>3</code> (interpreted as <code>3.0.0</code>)</li>
- * </ul>
- * </p>
- * <p>
- * The version identifier can be decomposed into a major, minor,
- * service level component and qualifier components. A difference
- * in the major component is interpreted as an incompatible version
- * change. A difference in the minor (and not the major) component
- * is interpreted as a compatible version change. The service
- * level component is interpreted as a cumulative and compatible
- * service update of the minor version component. The qualifier is
- * not interpreted, other than in version comparisons. The
- * qualifiers are compared using lexicographical string comparison.
- * </p>
- * <p>
- * Version identifiers can be matched as perfectly equal, equivalent,
- * compatible or greaterOrEqual.
- * </p><p>
- * This class can be used without OSGi running.
- * </p><p>
- * Clients may instantiate; not intended to be subclassed by clients.
- * </p>
- * @see java.lang.String#compareTo(java.lang.String)
- * @deprecated clients should use {@link org.osgi.framework.Version} instead
- */
-public final class PluginVersionIdentifier {
-
- private Version version;
-
- private static final String SEPARATOR = "."; //$NON-NLS-1$
-
- /**
- * Creates a plug-in version identifier from its components.
- *
- * @param major major component of the version identifier
- * @param minor minor component of the version identifier
- * @param service service update component of the version identifier
- */
- public PluginVersionIdentifier(int major, int minor, int service) {
- this(major, minor, service, null);
- }
-
- /**
- * Creates a plug-in version identifier from its components.
- *
- * @param major major component of the version identifier
- * @param minor minor component of the version identifier
- * @param service service update component of the version identifier
- * @param qualifier qualifier component of the version identifier.
- * Qualifier characters that are not a letter or a digit are replaced.
- */
- public PluginVersionIdentifier(int major, int minor, int service, String qualifier) {
- // Do the test outside of the assert so that they 'Policy.bind'
- // will not be evaluated each time (including cases when we would
- // have passed by the assert).
-
- if (major < 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_postiveMajor, major + SEPARATOR + minor + SEPARATOR + service + SEPARATOR + qualifier));
- if (minor < 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_postiveMinor, major + SEPARATOR + minor + SEPARATOR + service + SEPARATOR + qualifier));
- if (service < 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_postiveService, major + SEPARATOR + minor + SEPARATOR + service + SEPARATOR + qualifier));
-
- this.version = new Version(major, minor, service, qualifier);
- }
-
- /**
- * Creates a plug-in version identifier from the given string.
- * The string representation consists of up to 4 tokens
- * separated by decimal point.
- * For example, the following are valid version identifiers
- * (as strings):
- * <ul>
- * <li><code>0.0.0</code></li>
- * <li><code>1.0.127564</code></li>
- * <li><code>3.7.2.build-127J</code></li>
- * <li><code>1.9</code> (interpreted as <code>1.9.0</code>)</li>
- * <li><code>3</code> (interpreted as <code>3.0.0</code>)</li>
- * </ul>
- * </p>
- *
- * @param versionId string representation of the version identifier.
- * Qualifier characters that are not a letter or a digit are replaced.
- */
- public PluginVersionIdentifier(String versionId) {
- Object[] parts = parseVersion(versionId);
- version = new Version(((Integer) parts[0]).intValue(), ((Integer) parts[1]).intValue(), ((Integer) parts[2]).intValue(), (String) parts[3]);
- }
-
- /**
- * Validates the given string as a plug-in version identifier.
- *
- * @param version the string to validate
- * @return a status object with code <code>IStatus.OK</code> if
- * the given string is valid as a plug-in version identifier, otherwise a status
- * object indicating what is wrong with the string
- * @since 2.0
- */
- public static IStatus validateVersion(String version) {
- try {
- parseVersion(version);
- } catch (RuntimeException e) {
- return new Status(IStatus.ERROR, IRuntimeConstants.PI_RUNTIME, IStatus.ERROR, e.getMessage(), e);
- }
- return Status.OK_STATUS;
- }
-
- private static Object[] parseVersion(String versionId) {
-
- // Do the test outside of the assert so that they 'Policy.bind'
- // will not be evaluated each time (including cases when we would
- // have passed by the assert).
- if (versionId == null)
- Assert.isNotNull(null, CommonMessages.parse_emptyPluginVersion);
- String s = versionId.trim();
- if (s.equals("")) //$NON-NLS-1$
- Assert.isTrue(false, CommonMessages.parse_emptyPluginVersion);
- if (s.startsWith(SEPARATOR))
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_separatorStartVersion, s));
- if (s.endsWith(SEPARATOR))
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_separatorEndVersion, s));
- if (s.indexOf(SEPARATOR + SEPARATOR) != -1)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_doubleSeparatorVersion, s));
-
- StringTokenizer st = new StringTokenizer(s, SEPARATOR);
- Vector elements = new Vector(4);
-
- while (st.hasMoreTokens())
- elements.addElement(st.nextToken());
-
- int elementSize = elements.size();
-
- if (elementSize <= 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_oneElementPluginVersion, s));
- if (elementSize > 4)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_fourElementPluginVersion, s));
-
- int[] numbers = new int[3];
- try {
- numbers[0] = Integer.parseInt((String) elements.elementAt(0));
- if (numbers[0] < 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_postiveMajor, s));
- } catch (NumberFormatException nfe) {
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_numericMajorComponent, s));
- }
-
- try {
- if (elementSize >= 2) {
- numbers[1] = Integer.parseInt((String) elements.elementAt(1));
- if (numbers[1] < 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_postiveMinor, s));
- } else
- numbers[1] = 0;
- } catch (NumberFormatException nfe) {
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_numericMinorComponent, s));
- }
-
- try {
- if (elementSize >= 3) {
- numbers[2] = Integer.parseInt((String) elements.elementAt(2));
- if (numbers[2] < 0)
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_postiveService, s));
- } else
- numbers[2] = 0;
- } catch (NumberFormatException nfe) {
- Assert.isTrue(false, NLS.bind(CommonMessages.parse_numericServiceComponent, s));
- }
-
- // "result" is a 4-element array with the major, minor, service, and qualifier
- Object[] result = new Object[4];
- result[0] = new Integer(numbers[0]);
- result[1] = new Integer(numbers[1]);
- result[2] = new Integer(numbers[2]);
- if (elementSize >= 4)
- result[3] = (String) elements.elementAt(3);
- else
- result[3] = ""; //$NON-NLS-1$
- return result;
- }
-
- /**
- * Compare version identifiers for equality. Identifiers are
- * equal if all of their components are equal.
- *
- * @param object an object to compare
- * @return whether or not the two objects are equal
- */
- public boolean equals(Object object) {
- if (!(object instanceof PluginVersionIdentifier))
- return false;
- PluginVersionIdentifier v = (PluginVersionIdentifier) object;
- return version.equals(v.version);
- }
-
- /**
- * Returns a hash code value for the object.
- *
- * @return an integer which is a hash code value for this object.
- */
- public int hashCode() {
- return version.hashCode();
- }
-
- /**
- * Returns the major (incompatible) component of this
- * version identifier.
- *
- * @return the major version
- */
- public int getMajorComponent() {
- return version.getMajor();
- }
-
- /**
- * Returns the minor (compatible) component of this
- * version identifier.
- *
- * @return the minor version
- */
- public int getMinorComponent() {
- return version.getMinor();
- }
-
- /**
- * Returns the service level component of this
- * version identifier.
- *
- * @return the service level
- */
- public int getServiceComponent() {
- return version.getMicro();
- }
-
- /**
- * Returns the qualifier component of this
- * version identifier.
- *
- * @return the qualifier
- */
- public String getQualifierComponent() {
- return version.getQualifier();
- }
-
- /**
- * Compares two version identifiers to see if this one is
- * greater than or equal to the argument.
- * <p>
- * A version identifier is considered to be greater than or equal
- * if its major component is greater than the argument major
- * component, or the major components are equal and its minor component
- * is greater than the argument minor component, or the
- * major and minor components are equal and its service component is
- * greater than the argument service component, or the major, minor and
- * service components are equal and the qualifier component is
- * greater than the argument qualifier component (using lexicographic
- * string comparison), or all components are equal.
- * </p>
- *
- * @param id the other version identifier
- * @return <code>true</code> is this version identifier
- * is compatible with the given version identifier, and
- * <code>false</code> otherwise
- * @since 2.0
- */
- public boolean isGreaterOrEqualTo(PluginVersionIdentifier id) {
- if (id == null)
- return false;
- if (getMajorComponent() > id.getMajorComponent())
- return true;
- if ((getMajorComponent() == id.getMajorComponent()) && (getMinorComponent() > id.getMinorComponent()))
- return true;
- if ((getMajorComponent() == id.getMajorComponent()) && (getMinorComponent() == id.getMinorComponent()) && (getServiceComponent() > id.getServiceComponent()))
- return true;
- if ((getMajorComponent() == id.getMajorComponent()) && (getMinorComponent() == id.getMinorComponent()) && (getServiceComponent() == id.getServiceComponent()) && (getQualifierComponent().compareTo(id.getQualifierComponent()) >= 0))
- return true;
- else
- return false;
- }
-
- /**
- * Compares two version identifiers for compatibility.
- * <p>
- * A version identifier is considered to be compatible if its major
- * component equals to the argument major component, and its minor component
- * is greater than or equal to the argument minor component.
- * If the minor components are equal, than the service level of the
- * version identifier must be greater than or equal to the service level
- * of the argument identifier. If the service levels are equal, the two
- * version identifiers are considered to be equivalent if this qualifier is
- * greater or equal to the qualifier of the argument (using lexicographic
- * string comparison).
- * </p>
- *
- * @param id the other version identifier
- * @return <code>true</code> is this version identifier
- * is compatible with the given version identifier, and
- * <code>false</code> otherwise
- */
- public boolean isCompatibleWith(PluginVersionIdentifier id) {
- if (id == null)
- return false;
- if (getMajorComponent() != id.getMajorComponent())
- return false;
- if (getMinorComponent() > id.getMinorComponent())
- return true;
- if (getMinorComponent() < id.getMinorComponent())
- return false;
- if (getServiceComponent() > id.getServiceComponent())
- return true;
- if (getServiceComponent() < id.getServiceComponent())
- return false;
- if (getQualifierComponent().compareTo(id.getQualifierComponent()) >= 0)
- return true;
- else
- return false;
- }
-
- /**
- * Compares two version identifiers for equivalency.
- * <p>
- * Two version identifiers are considered to be equivalent if their major
- * and minor component equal and are at least at the same service level
- * as the argument. If the service levels are equal, the two version
- * identifiers are considered to be equivalent if this qualifier is
- * greater or equal to the qualifier of the argument (using lexicographic
- * string comparison).
- *
- * </p>
- *
- * @param id the other version identifier
- * @return <code>true</code> is this version identifier
- * is equivalent to the given version identifier, and
- * <code>false</code> otherwise
- */
- public boolean isEquivalentTo(PluginVersionIdentifier id) {
- if (id == null)
- return false;
- if (getMajorComponent() != id.getMajorComponent())
- return false;
- if (getMinorComponent() != id.getMinorComponent())
- return false;
- if (getServiceComponent() > id.getServiceComponent())
- return true;
- if (getServiceComponent() < id.getServiceComponent())
- return false;
- if (getQualifierComponent().compareTo(id.getQualifierComponent()) >= 0)
- return true;
- else
- return false;
- }
-
- /**
- * Compares two version identifiers for perfect equality.
- * <p>
- * Two version identifiers are considered to be perfectly equal if their
- * major, minor, service and qualifier components are equal
- * </p>
- *
- * @param id the other version identifier
- * @return <code>true</code> is this version identifier
- * is perfectly equal to the given version identifier, and
- * <code>false</code> otherwise
- * @since 2.0
- */
- public boolean isPerfect(PluginVersionIdentifier id) {
- if (id == null)
- return false;
- if ((getMajorComponent() != id.getMajorComponent()) || (getMinorComponent() != id.getMinorComponent()) || (getServiceComponent() != id.getServiceComponent()) || (!getQualifierComponent().equals(id.getQualifierComponent())))
- return false;
- else
- return true;
- }
-
- /**
- * Compares two version identifiers for order using multi-decimal
- * comparison.
- *
- * @param id the other version identifier
- * @return <code>true</code> is this version identifier
- * is greater than the given version identifier, and
- * <code>false</code> otherwise
- */
- public boolean isGreaterThan(PluginVersionIdentifier id) {
-
- if (id == null) {
- if (getMajorComponent() == 0 && getMinorComponent() == 0 && getServiceComponent() == 0 && getQualifierComponent().equals("")) //$NON-NLS-1$
- return false;
- else
- return true;
- }
-
- if (getMajorComponent() > id.getMajorComponent())
- return true;
- if (getMajorComponent() < id.getMajorComponent())
- return false;
- if (getMinorComponent() > id.getMinorComponent())
- return true;
- if (getMinorComponent() < id.getMinorComponent())
- return false;
- if (getServiceComponent() > id.getServiceComponent())
- return true;
- if (getServiceComponent() < id.getServiceComponent())
- return false;
- if (getQualifierComponent().compareTo(id.getQualifierComponent()) > 0)
- return true;
- else
- return false;
-
- }
-
- /**
- * Returns the string representation of this version identifier.
- * The result satisfies
- * <code>vi.equals(new PluginVersionIdentifier(vi.toString()))</code>.
- *
- * @return the string representation of this plug-in version identifier
- */
- public String toString() {
- return version.toString();
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ProgressMonitorWrapper.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ProgressMonitorWrapper.java
deleted file mode 100644
index f282e64bb..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ProgressMonitorWrapper.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * An abstract wrapper around a progress monitor which,
- * unless overridden, forwards <code>IProgressMonitor</code>
- * and <code>IProgressMonitorWithBlocking</code> methods to the wrapped progress monitor.
- * <p>
- * This class can be used without OSGi running.
- * </p><p>
- * Clients may subclass.
- * </p>
- */
-public abstract class ProgressMonitorWrapper implements IProgressMonitor, IProgressMonitorWithBlocking {
-
- /** The wrapped progress monitor. */
- private IProgressMonitor progressMonitor;
-
- /**
- * Creates a new wrapper around the given monitor.
- *
- * @param monitor the progress monitor to forward to
- */
- protected ProgressMonitorWrapper(IProgressMonitor monitor) {
- Assert.isNotNull(monitor);
- progressMonitor = monitor;
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#beginTask(String, int)
- */
- public void beginTask(String name, int totalWork) {
- progressMonitor.beginTask(name, totalWork);
- }
-
- /**
- * This implementation of a <code>IProgressMonitorWithBlocking</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitorWithBlocking#clearBlocked()
- * @since 3.0
- */
- public void clearBlocked() {
- if (progressMonitor instanceof IProgressMonitorWithBlocking)
- ((IProgressMonitorWithBlocking) progressMonitor).clearBlocked();
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#done()
- */
- public void done() {
- progressMonitor.done();
- }
-
- /**
- * Returns the wrapped progress monitor.
- *
- * @return the wrapped progress monitor
- */
- public IProgressMonitor getWrappedProgressMonitor() {
- return progressMonitor;
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#internalWorked(double)
- */
- public void internalWorked(double work) {
- progressMonitor.internalWorked(work);
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#isCanceled()
- */
- public boolean isCanceled() {
- return progressMonitor.isCanceled();
- }
-
- /**
- * This implementation of a <code>IProgressMonitorWithBlocking</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitorWithBlocking#setBlocked(IStatus)
- * @since 3.0
- */
- public void setBlocked(IStatus reason) {
- if (progressMonitor instanceof IProgressMonitorWithBlocking)
- ((IProgressMonitorWithBlocking) progressMonitor).setBlocked(reason);
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#setCanceled(boolean)
- */
- public void setCanceled(boolean b) {
- progressMonitor.setCanceled(b);
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#setTaskName(String)
- */
- public void setTaskName(String name) {
- progressMonitor.setTaskName(name);
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#subTask(String)
- */
- public void subTask(String name) {
- progressMonitor.subTask(name);
- }
-
- /**
- * This implementation of a <code>IProgressMonitor</code>
- * method forwards to the wrapped progress monitor.
- * Clients may override this method to do additional
- * processing.
- *
- * @see IProgressMonitor#worked(int)
- */
- public void worked(int work) {
- progressMonitor.worked(work);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/QualifiedName.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/QualifiedName.java
deleted file mode 100644
index e0a49dce8..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/QualifiedName.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * Qualified names are two-part names: qualifier and local name.
- * The qualifier must be in URI form (see RFC2396).
- * Note however that the qualifier may be <code>null</code> if
- * the default name space is being used. The empty string is not
- * a valid local name.
- * <p>
- * This class can be used without OSGi running.
- * </p><p>
- * This class is not intended to be subclassed by clients.
- * </p>
- */
-public final class QualifiedName {
-
- /** Qualifier part (potentially <code>null</code>). */
- /*package*/
- String qualifier = null;
-
- /** Local name part. */
- /*package*/
- String localName = null;
-
- /**
- * Creates and returns a new qualified name with the given qualifier
- * and local name. The local name must not be the empty string.
- * The qualifier may be <code>null</code>.
- * <p>
- * Clients may instantiate.
- * </p>
- * @param qualifier the qualifier string, or <code>null</code>
- * @param localName the local name string
- */
- public QualifiedName(String qualifier, String localName) {
- Assert.isLegal(localName != null && localName.length() != 0);
- this.qualifier = qualifier;
- this.localName = localName;
- }
-
- /**
- * Returns whether this qualified name is equivalent to the given object.
- * <p>
- * Qualified names are equal if and only if they have the same
- * qualified parts and local parts.
- * Qualified names are not equal to objects other than qualified names.
- * </p>
- *
- * @param obj the object to compare to
- * @return <code>true</code> if these are equivalent qualified
- * names, and <code>false</code> otherwise
- */
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof QualifiedName)) {
- return false;
- }
- QualifiedName qName = (QualifiedName) obj;
- /* There may or may not be a qualifier */
- if (qualifier == null && qName.getQualifier() != null) {
- return false;
- }
- if (qualifier != null && !qualifier.equals(qName.getQualifier())) {
- return false;
- }
- return localName.equals(qName.getLocalName());
- }
-
- /**
- * Returns the local part of this name.
- *
- * @return the local name string
- */
- public String getLocalName() {
- return localName;
- }
-
- /**
- * Returns the qualifier part for this qualified name, or <code>null</code>
- * if none.
- *
- * @return the qualifier string, or <code>null</code>
- */
- public String getQualifier() {
- return qualifier;
- }
-
- /* (Intentionally omitted from javadoc)
- * Implements the method <code>Object.hashCode</code>.
- *
- * Returns the hash code for this qualified name.
- */
- public int hashCode() {
- return (qualifier == null ? 0 : qualifier.hashCode()) + localName.hashCode();
- }
-
- /**
- * Converts this qualified name into a string, suitable for
- * debug purposes only.
- */
- public String toString() {
- return (getQualifier() == null ? "" : getQualifier() + ':') + getLocalName(); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java
deleted file mode 100644
index 7a38d23a4..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import org.eclipse.core.internal.runtime.*;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Runs the given ISafeRunnable in a protected mode: exceptions
- * thrown in the runnable are logged and passed to the runnable's
- * exception handler. Such exceptions are not rethrown by this method.
- * <p>
- * This class can be used without OSGi running.
- * </p>
- * @since org.eclipse.equinox.common 3.2
- */
-public final class SafeRunner {
-
- /**
- * Runs the given runnable in a protected mode. Exceptions
- * thrown in the runnable are logged and passed to the runnable's
- * exception handler. Such exceptions are not rethrown by this method.
- *
- * @param code the runnable to run
- */
- public static void run(ISafeRunnable code) {
- Assert.isNotNull(code);
- try {
- code.run();
- } catch (Exception e) {
- handleException(code, e);
- } catch (LinkageError e) {
- handleException(code, e);
- }
- }
-
- private static void handleException(ISafeRunnable code, Throwable e) {
- if (!(e instanceof OperationCanceledException)) {
- // try to obtain the correct plug-in id for the bundle providing the safe runnable
- Activator activator = Activator.getDefault();
- String pluginId = null;
- if (activator != null)
- pluginId = activator.getBundleId(code);
- if (pluginId == null)
- pluginId = IRuntimeConstants.PI_COMMON;
- String message = NLS.bind(CommonMessages.meta_pluginProblems, pluginId);
- IStatus status;
- if (e instanceof CoreException) {
- status = new MultiStatus(pluginId, IRuntimeConstants.PLUGIN_ERROR, message, e);
- ((MultiStatus) status).merge(((CoreException) e).getStatus());
- } else {
- status = new Status(IStatus.ERROR, pluginId, IRuntimeConstants.PLUGIN_ERROR, message, e);
- }
- // Make sure user sees the exception: if the log is empty, log the exceptions on stderr
- if (!RuntimeLog.isEmpty())
- RuntimeLog.log(status);
- else
- e.printStackTrace();
- }
- code.handleException(e);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Status.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Status.java
deleted file mode 100644
index 894b6876d..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Status.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-import org.eclipse.core.internal.runtime.IRuntimeConstants;
-import org.eclipse.core.internal.runtime.LocalizationUtils;
-
-/**
- * A concrete status implementation, suitable either for
- * instantiating or subclassing.
- * <p>
- * This class can be used without OSGi running.
- * </p>
- */
-public class Status implements IStatus {
-
- /**
- * A standard OK status with an "ok" message.
- *
- * @since 3.0
- */
- public static final IStatus OK_STATUS = new Status(OK, IRuntimeConstants.PI_RUNTIME, OK, LocalizationUtils.safeLocalize("ok"), null); //$NON-NLS-1$
- /**
- * A standard CANCEL status with no message.
- *
- * @since 3.0
- */
- public static final IStatus CANCEL_STATUS = new Status(CANCEL, IRuntimeConstants.PI_RUNTIME, 1, "", null); //$NON-NLS-1$
- /**
- * The severity. One of
- * <ul>
- * <li><code>CANCEL</code></li>
- * <li><code>ERROR</code></li>
- * <li><code>WARNING</code></li>
- * <li><code>INFO</code></li>
- * <li>or <code>OK</code> (0)</li>
- * </ul>
- */
- private int severity = OK;
-
- /** Unique identifier of plug-in.
- */
- private String pluginId;
-
- /** Plug-in-specific status code.
- */
- private int code;
-
- /** Message, localized to the current locale.
- */
- private String message;
-
- /** Wrapped exception, or <code>null</code> if none.
- */
- private Throwable exception = null;
-
- /** Constant to avoid generating garbage.
- */
- private static final IStatus[] theEmptyStatusArray = new IStatus[0];
-
- /**
- * Creates a new status object. The created status has no children.
- *
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @param pluginId the unique identifier of the relevant plug-in
- * @param code the plug-in-specific status code, or <code>OK</code>
- * @param message a human-readable message, localized to the
- * current locale
- * @param exception a low-level exception, or <code>null</code> if not
- * applicable
- */
- public Status(int severity, String pluginId, int code, String message, Throwable exception) {
- setSeverity(severity);
- setPlugin(pluginId);
- setCode(code);
- setMessage(message);
- setException(exception);
- }
-
- /**
- * Simplified constructor of a new status object; assumes that code is <code>OK</code>.
- * The created status has no children.
- *
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @param pluginId the unique identifier of the relevant plug-in
- * @param message a human-readable message, localized to the
- * current locale
- * @param exception a low-level exception, or <code>null</code> if not
- * applicable
- *
- * @since org.eclipse.equinox.common 3.3
- */
- public Status(int severity, String pluginId, String message, Throwable exception) {
- setSeverity(severity);
- setPlugin(pluginId);
- setMessage(message);
- setException(exception);
- setCode(OK);
- }
-
- /**
- * Simplified constructor of a new status object; assumes that code is <code>OK</code> and
- * exception is <code>null</code>. The created status has no children.
- *
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @param pluginId the unique identifier of the relevant plug-in
- * @param message a human-readable message, localized to the
- * current locale
- *
- * @since org.eclipse.equinox.common 3.3
- */
- public Status(int severity, String pluginId, String message) {
- setSeverity(severity);
- setPlugin(pluginId);
- setMessage(message);
- setCode(OK);
- setException(null);
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public IStatus[] getChildren() {
- return theEmptyStatusArray;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public int getCode() {
- return code;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public Throwable getException() {
- return exception;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public String getMessage() {
- return message;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public String getPlugin() {
- return pluginId;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public int getSeverity() {
- return severity;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public boolean isMultiStatus() {
- return false;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public boolean isOK() {
- return severity == OK;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the corresponding method on <code>IStatus</code>.
- */
- public boolean matches(int severityMask) {
- return (severity & severityMask) != 0;
- }
-
- /**
- * Sets the status code.
- *
- * @param code the plug-in-specific status code, or <code>OK</code>
- */
- protected void setCode(int code) {
- this.code = code;
- }
-
- /**
- * Sets the exception.
- *
- * @param exception a low-level exception, or <code>null</code> if not
- * applicable
- */
- protected void setException(Throwable exception) {
- this.exception = exception;
- }
-
- /**
- * Sets the message. If null is passed, message is set to an empty
- * string.
- *
- * @param message a human-readable message, localized to the
- * current locale
- */
- protected void setMessage(String message) {
- if (message == null)
- this.message = ""; //$NON-NLS-1$
- else
- this.message = message;
- }
-
- /**
- * Sets the plug-in id.
- *
- * @param pluginId the unique identifier of the relevant plug-in
- */
- protected void setPlugin(String pluginId) {
- Assert.isLegal(pluginId != null && pluginId.length() > 0);
- this.pluginId = pluginId;
- }
-
- /**
- * Sets the severity.
- *
- * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- */
- protected void setSeverity(int severity) {
- Assert.isLegal(severity == OK || severity == ERROR || severity == WARNING || severity == INFO || severity == CANCEL);
- this.severity = severity;
- }
-
- /**
- * Returns a string representation of the status, suitable
- * for debugging purposes only.
- */
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("Status "); //$NON-NLS-1$
- if (severity == OK) {
- buf.append("OK"); //$NON-NLS-1$
- } else if (severity == ERROR) {
- buf.append("ERROR"); //$NON-NLS-1$
- } else if (severity == WARNING) {
- buf.append("WARNING"); //$NON-NLS-1$
- } else if (severity == INFO) {
- buf.append("INFO"); //$NON-NLS-1$
- } else if (severity == CANCEL) {
- buf.append("CANCEL"); //$NON-NLS-1$
- } else {
- buf.append("severity="); //$NON-NLS-1$
- buf.append(severity);
- }
- buf.append(": "); //$NON-NLS-1$
- buf.append(pluginId);
- buf.append(" code="); //$NON-NLS-1$
- buf.append(code);
- buf.append(' ');
- buf.append(message);
- buf.append(' ');
- buf.append(exception);
- return buf.toString();
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java
deleted file mode 100644
index f8c766151..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java
+++ /dev/null
@@ -1,781 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * Stefan Xenos - initial API and implementation
- * Stefan Xenos - bug 174539 - add a 1-argument convert(...) method
- * Stefan Xenos - bug 174040 - SubMonitor#convert doesn't always set task name
- * Stefan Xenos - bug 206942 - updated javadoc to recommend better constants for infinite progress
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * <p>A progress monitor that uses a given amount of work ticks from a parent monitor. This is intended as a
- * safer, easier-to-use alternative to SubProgressMonitor. The main benefits of SubMonitor over
- * SubProgressMonitor are:</p>
- * <ul>
- * <li>It is not necessary to call beginTask() or done() on an instance of SubMonitor.</li>
- * <li>SubMonitor has a simpler syntax for creating nested monitors.</li>
- * <li>SubMonitor is more efficient for deep recursion chains.</li>
- * <li>SubMonitor has a setWorkRemining method that allows the remaining space on the monitor to be
- * redistributed without reporting any work.</li>
- * <li>SubMonitor protects the caller from common progress reporting bugs in a called method. For example,
- * if a called method fails to call done() on the given monitor or fails to consume all the ticks on
- * the given monitor, the parent will correct the problem after the method returns.</li>
- * </ul>
- * <p></p>
- * <p><b>USAGE:</b></p>
- *
- * <p>When implementing a method that accepts an IProgressMonitor:</p>
- * <ul>
- * <li>At the start of your method, use <code>SubMonitor.convert(...).</code> to convert the IProgressMonitor
- * into a SubMonitor. </li>
- * <li>Use <code>SubMonitor.newChild(...)</code> whenever you need to call another method that
- * accepts an IProgressMonitor.</li>
- * </ul>
- * <p></p>
- * <p><b>DEFAULT BEHAVIOR:</b></p>
- *
- * <p>When writing JavaDoc for a method that accepts an IProgressMonitor, you should assume the
- * following default behavior unless the method's JavaDoc says otherwise:</p>
- * <ul>
- * <li>It WILL call beginTask on the IProgressMonitor.</li>
- * <li>It WILL NOT accept a null argument.</li>
- * <li>It WILL call done on the IProgressMonitor.</li>
- * </ul>
- * <p></p>
- * <p><b>BEST PRACTISES:</b></p>
- *
- * <p>We recommend that newly-written methods follow the given contract:</p>
- * <ul>
- * <li>It WILL call beginTask on the IProgressMonitor.</li>
- * <li>It WILL accept a null argument, indicating that no progress should be reported and the operation cannot be cancelled.</li>
- * <li>It WILL NOT call done on the IProgressMonitor, leaving this responsibility up to the caller.</li>
- * </ul>
- * <p>If you wish to follow these conventions, you may copy and paste the following text into your method's JavaDoc:</p>
- *
- * <pre>@param monitor the progress monitor to use for reporting progress to the user. It is the caller's responsibility
- * to call done() on the given monitor. Accepts <code>null</code>, indicating that no progress should be
- * reported and that the operation cannot be cancelled.</pre>
- *
- * <p></p>
- * <p><b>Example: Recommended usage</b></p>
- *
- * <p>This example demonstrates how the recommended usage of <code>SubMonitor</code> makes it unnecessary to call
- * IProgressMonitor.done() in most situations.</p>
- *
- * <p>It is never necessary to call done() on a monitor obtained from <code>convert</code> or <code>progress.newChild()</code>.
- * In this example, there is no guarantee that <code>monitor</code> is an instance of <code>SubMonitor</code>, making it
- * necessary to call <code>monitor.done()</code>. The JavaDoc contract makes this the responsibility of the caller.</p>
- *
- * <pre>
- * // param monitor the progress monitor to use for reporting progress to the user. It is the caller's responsibility
- * // to call done() on the given monitor. Accepts <code>null</code>, indicating that no progress should be
- * // reported and that the operation cannot be cancelled.
- * //
- * void doSomething(IProgressMonitor monitor) {
- * // Convert the given monitor into a progress instance
- * SubMonitor progress = SubMonitor.convert(monitor, 100);
- *
- * // Use 30% of the progress to do some work
- * doSomeWork(progress.newChild(30));
- *
- * // Advance the monitor by another 30%
- * progress.worked(30);
- *
- * // Use the remaining 40% of the progress to do some more work
- * doSomeWork(progress.newChild(40));
- * }
- * </pre>
- *
- *
- * <p></p>
- * <p><b>Example: Default usage</b></p>
- *
- * <p>You will often need to implement a method that does not explicitly stipulate that calling done() is the responsibility
- * of the caller. In this case, you should use the following pattern:</p>
- *
- * <pre>
- * // param monitor the progress monitor to use for reporting progress to the user, or <code>null</code> indicating
- * // that no progress should be reported and the operation cannot be cancelled.
- * //
- * void doSomething(IProgressMonitor monitor) {
- * // Convert the given monitor into a progress instance
- * SubMonitor progress = SubMonitor.convert(monitor, 100);
- * try {
- * // Use 30% of the progress to do some work
- * doSomeWork(progress.newChild(30));
- *
- * // Advance the monitor by another 30%
- * progress.worked(30);
- *
- * // Use the remaining 40% of the progress to do some more work
- * doSomeWork(progress.newChild(40));
- *
- * } finally {
- * if (monitor != null) {
- * monitor.done();
- * }
- * }
- * }
- * </pre>
- *
- * <p></p>
- * <p><b>Example: Branches</b></p>
- *
- * <p>This example demonstrates how to smoothly report progress in situations where some of the work is optional.</p>
- *
- * <pre>
- * void doSomething(IProgressMonitor monitor) {
- * SubMonitor progress = SubMonitor.convert(monitor, 100);
- *
- * if (condition) {
- * // Use 50% of the progress to do some work
- * doSomeWork(progress.newChild(50));
- * }
- *
- * // Don't report any work, but ensure that we have 50 ticks remaining on the progress monitor.
- * // If we already consumed 50 ticks in the above branch, this is a no-op. Otherwise, the remaining
- * // space in the monitor is redistributed into 50 ticks.
- *
- * progress.setWorkRemaining(50);
- *
- * // Use the remainder of the progress monitor to do the rest of the work
- * doSomeWork(progress.newChild(50));
- * }
- * </pre>
- *
- * <p>Please beware of the following anti-pattern:</p>
- *
- * <pre>
- * if (condition) {
- * // Use 50% of the progress to do some work
- * doSomeWork(progress.newChild(50));
- * } else {
- * // Bad: Causes the progress monitor to appear to start at 50%, wasting half of the
- * // space in the monitor.
- * progress.worked(50);
- * }
- * </pre>
- *
- *
- * <p></p>
- * <p><b>Example: Loops</b></p>
- *
- * <p>This example demonstrates how to report progress in a loop.</p>
- *
- * <pre>
- * void doSomething(IProgressMonitor monitor, Collection someCollection) {
- * SubMonitor progress = SubMonitor.convert(monitor, 100);
- *
- * // Create a new progress monitor that uses 70% of the total progress and will allocate one tick
- * // for each element of the given collection.
- * SubMonitor loopProgress = progress.newChild(70).setWorkRemaining(someCollection.size());
- *
- * for (Iterator iter = someCollection.iterator(); iter.hasNext();) {
- * Object next = iter.next();
- *
- * doWorkOnElement(next, loopProgress.newChild(1));
- * }
- *
- * // Use the remaining 30% of the progress monitor to do some work outside the loop
- * doSomeWork(progress.newChild(30));
- * }
- * </pre>
- *
- *
- * <p></p>
- * <p><b>Example: Infinite progress</b></p>
- *
- * <p>This example demonstrates how to report logarithmic progress in situations where the number of ticks
- * cannot be easily computed in advance.</p>
- *
- * <pre>
- * void doSomething(IProgressMonitor monitor, LinkedListNode node) {
- * SubMonitor progress = SubMonitor.convert(monitor);
- *
- * while (node != null) {
- * // Regardless of the amount of progress reported so far,
- * // use 0.01% of the space remaining in the monitor to process the next node.
- * progress.setWorkRemaining(10000);
- *
- * doWorkOnElement(node, progress.newChild(1));
- *
- * node = node.next;
- * }
- * }
- * </pre>
- *
- * <p>
- * This class can be used without OSGi running.
- * </p>
- *
- * @since org.eclipse.equinox.common 3.3
- */
-public final class SubMonitor implements IProgressMonitorWithBlocking {
-
- /**
- * Minimum number of ticks to allocate when calling beginTask on an unknown IProgressMonitor.
- * Pick a number that is big enough such that, no matter where progress is being displayed,
- * the user would be unlikely to notice if progress were to be reported with higher accuracy.
- */
- private static final int MINIMUM_RESOLUTION = 1000;
-
- /**
- * The RootInfo struct holds information about the root progress monitor. A SubMonitor and
- * its active descendents share the same RootInfo struct.
- */
- private static final class RootInfo {
- private final IProgressMonitor root;
-
- /**
- * Remembers the last task name. Prevents us from setting the same task name multiple
- * times in a row.
- */
- private String taskName = null;
-
- /**
- * Remembers the last subtask name. Prevents the SubMonitor from setting the same
- * subtask string more than once in a row.
- */
- private String subTask = null;
-
- /**
- * Creates a RootInfo struct that delegates to the given progress
- * monitor.
- *
- * @param root progress monitor to delegate to
- */
- public RootInfo(IProgressMonitor root) {
- this.root = root;
- }
-
- public boolean isCanceled() {
- return root.isCanceled();
- }
-
- public void setCanceled(boolean value) {
- root.setCanceled(value);
- }
-
- public void setTaskName(String taskName) {
- if (eq(taskName, this.taskName)) {
- return;
- }
- this.taskName = taskName;
- root.setTaskName(taskName);
- }
-
- public void subTask(String name) {
- if (eq(subTask, name)) {
- return;
- }
-
- this.subTask = name;
- root.subTask(name);
- }
-
- public void worked(int i) {
- root.worked(i);
- }
-
- public void clearBlocked() {
- if (root instanceof IProgressMonitorWithBlocking)
- ((IProgressMonitorWithBlocking) root).clearBlocked();
- }
-
- public void setBlocked(IStatus reason) {
- if (root instanceof IProgressMonitorWithBlocking)
- ((IProgressMonitorWithBlocking) root).setBlocked(reason);
- }
-
- }
-
- /**
- * Total number of ticks that this progress monitor is permitted to consume
- * from the root.
- */
- private int totalParent;
-
- /**
- * Number of ticks that this progress monitor has already reported in the root.
- */
- private int usedForParent = 0;
-
- /**
- * Number of ticks that have been consumed by this instance's children.
- */
- private double usedForChildren = 0.0;
-
- /**
- * Number of ticks allocated for this instance's children. This is the total number
- * of ticks that may be passed into worked(int) or newChild(int).
- */
- private int totalForChildren;
-
- /**
- * Children created by newChild will be completed automatically the next time
- * the parent progress monitor is touched. This points to the last incomplete child
- * created with newChild.
- */
- private IProgressMonitor lastSubMonitor = null;
-
- /**
- * Used to communicate with the root of this progress monitor tree
- */
- private final RootInfo root;
-
- /**
- * A bitwise combination of the SUPPRESS_* flags.
- */
- private final int flags;
-
- /**
- * May be passed as a flag to newChild. Indicates that the calls
- * to subTask on the child should be ignored. Without this flag,
- * calling subTask on the child will result in a call to subTask
- * on its parent.
- */
- public static final int SUPPRESS_SUBTASK = 0x0001;
-
- /**
- * May be passed as a flag to newChild. Indicates that strings
- * passed into beginTask should be ignored. If this flag is
- * specified, then the progress monitor instance will accept null
- * as the first argument to beginTask. Without this flag, any
- * string passed to beginTask will result in a call to
- * setTaskName on the parent.
- */
- public static final int SUPPRESS_BEGINTASK = 0x0002;
-
- /**
- * May be passed as a flag to newChild. Indicates that strings
- * passed into setTaskName should be ignored. If this string
- * is omitted, then a call to setTaskName on the child will
- * result in a call to setTaskName on the parent.
- */
- public static final int SUPPRESS_SETTASKNAME = 0x0004;
-
- /**
- * May be passed as a flag to newChild. Indicates that strings
- * passed to setTaskName, subTask, and beginTask should all be ignored.
- */
- public static final int SUPPRESS_ALL_LABELS = SUPPRESS_SETTASKNAME | SUPPRESS_BEGINTASK | SUPPRESS_SUBTASK;
-
- /**
- * May be passed as a flag to newChild. Indicates that strings
- * passed to setTaskName, subTask, and beginTask should all be propogated
- * to the parent.
- */
- public static final int SUPPRESS_NONE = 0;
-
- /**
- * Creates a new SubMonitor that will report its progress via
- * the given RootInfo.
- * @param rootInfo the root of this progress monitor tree
- * @param totalWork total work to perform on the given progress monitor
- * @param availableToChildren number of ticks allocated for this instance's children
- * @param flags a bitwise combination of the SUPPRESS_* constants
- */
- private SubMonitor(RootInfo rootInfo, int totalWork, int availableToChildren, int flags) {
- root = rootInfo;
- totalParent = (totalWork > 0) ? totalWork : 0;
- this.totalForChildren = availableToChildren;
- this.flags = flags;
- }
-
- /**
- * <p>Converts an unknown (possibly null) IProgressMonitor into a SubMonitor. It is
- * not necessary to call done() on the result, but the caller is responsible for calling
- * done() on the argument. Calls beginTask on the argument.</p>
- *
- * <p>This method should generally be called at the beginning of a method that accepts
- * an IProgressMonitor in order to convert the IProgressMonitor into a SubMonitor.</p>
- *
- * @param monitor monitor to convert to a SubMonitor instance or null. Treats null
- * as a new instance of <code>NullProgressMonitor</code>.
- * @return a SubMonitor instance that adapts the argument
- */
- public static SubMonitor convert(IProgressMonitor monitor) {
- return convert(monitor, "", 0); //$NON-NLS-1$
- }
-
- /**
- * <p>Converts an unknown (possibly null) IProgressMonitor into a SubMonitor allocated
- * with the given number of ticks. It is not necessary to call done() on the result,
- * but the caller is responsible for calling done() on the argument. Calls beginTask
- * on the argument.</p>
- *
- * <p>This method should generally be called at the beginning of a method that accepts
- * an IProgressMonitor in order to convert the IProgressMonitor into a SubMonitor.</p>
- *
- * @param monitor monitor to convert to a SubMonitor instance or null. Treats null
- * as a new instance of <code>NullProgressMonitor</code>.
- * @param work number of ticks that will be available in the resulting monitor
- * @return a SubMonitor instance that adapts the argument
- */
- public static SubMonitor convert(IProgressMonitor monitor, int work) {
- return convert(monitor, "", work); //$NON-NLS-1$
- }
-
- /**
- * <p>Converts an unknown (possibly null) IProgressMonitor into a SubMonitor allocated
- * with the given number of ticks. It is not necessary to call done() on the result,
- * but the caller is responsible for calling done() on the argument. Calls beginTask
- * on the argument.</p>
- *
- * <p>This method should generally be called at the beginning of a method that accepts
- * an IProgressMonitor in order to convert the IProgressMonitor into a SubMonitor.</p>
- *
- * @param monitor to convert into a SubMonitor instance or null. If given a null argument,
- * the resulting SubMonitor will not report its progress anywhere.
- * @param taskName user readable name to pass to monitor.beginTask. Never null.
- * @param work initial number of ticks to allocate for children of the SubMonitor
- * @return a new SubMonitor instance that is a child of the given monitor
- */
- public static SubMonitor convert(IProgressMonitor monitor, String taskName, int work) {
- if (monitor == null)
- monitor = new NullProgressMonitor();
-
- // Optimization: if the given monitor already a SubMonitor, no conversion is necessary
- if (monitor instanceof SubMonitor) {
- monitor.beginTask(taskName, work);
- return (SubMonitor) monitor;
- }
-
- monitor.beginTask(taskName, MINIMUM_RESOLUTION);
- return new SubMonitor(new RootInfo(monitor), MINIMUM_RESOLUTION, work, SUPPRESS_NONE);
- }
-
- /**
- * <p>Sets the work remaining for this SubMonitor instance. This is the total number
- * of ticks that may be reported by all subsequent calls to worked(int), newChild(int), etc.
- * This may be called many times for the same SubMonitor instance. When this method
- * is called, the remaining space on the progress monitor is redistributed into the given
- * number of ticks.</p>
- *
- * <p>It doesn't matter how much progress has already been reported with this SubMonitor
- * instance. If you call setWorkRemaining(100), you will be able to report 100 more ticks of
- * work before the progress meter reaches 100%.</p>
- *
- * @param workRemaining total number of remaining ticks
- * @return the receiver
- */
- public SubMonitor setWorkRemaining(int workRemaining) {
- // Ensure we don't try to allocate negative ticks
- workRemaining = Math.max(0, workRemaining);
-
- // Ensure we don't cause division by zero
- if (totalForChildren > 0 && totalParent > usedForParent) {
- // Note: We want the following value to remain invariant after this method returns
- double remainForParent = totalParent * (1.0d - (usedForChildren / totalForChildren));
- usedForChildren = (workRemaining * (1.0d - remainForParent / (totalParent - usedForParent)));
- } else
- usedForChildren = 0.0d;
-
- totalParent = totalParent - usedForParent;
- usedForParent = 0;
- totalForChildren = workRemaining;
- return this;
- }
-
- /**
- * Consumes the given number of child ticks, given as a double. Must only
- * be called if the monitor is in floating-point mode.
- *
- * @param ticks the number of ticks to consume
- * @return ticks the number of ticks to be consumed from parent
- */
- private int consume(double ticks) {
- if (totalParent == 0 || totalForChildren == 0) // this monitor has no available work to report
- return 0;
-
- usedForChildren += ticks;
-
- if (usedForChildren > totalForChildren)
- usedForChildren = totalForChildren;
- else if (usedForChildren < 0.0)
- usedForChildren = 0.0;
-
- int parentPosition = (int) (totalParent * usedForChildren / totalForChildren);
- int delta = parentPosition - usedForParent;
-
- usedForParent = parentPosition;
- return delta;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled()
- */
- public boolean isCanceled() {
- return root.isCanceled();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String)
- */
- public void setTaskName(String name) {
- if ((flags & SUPPRESS_SETTASKNAME) == 0)
- root.setTaskName(name);
- }
-
- /**
- * Starts a new main task. The string argument is ignored
- * if and only if the SUPPRESS_BEGINTASK flag has been set on this SubMonitor
- * instance.
- *
- * <p>This method is equivalent calling setWorkRemaining(...) on the reciever. Unless
- * the SUPPRESS_BEGINTASK flag is set, this will also be equivalent to calling
- * setTaskName(...) on the parent.</p>
- *
- * @param name new main task name
- * @param totalWork number of ticks to allocate
- *
- * @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int)
- */
- public void beginTask(String name, int totalWork) {
- if ((flags & SUPPRESS_BEGINTASK) == 0 && name != null)
- root.setTaskName(name);
- setWorkRemaining(totalWork);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IProgressMonitor#done()
- */
- public void done() {
- cleanupActiveChild();
- int delta = totalParent - usedForParent;
- if (delta > 0)
- root.worked(delta);
-
- totalParent = 0;
- usedForParent = 0;
- totalForChildren = 0;
- usedForChildren = 0.0d;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double)
- */
- public void internalWorked(double work) {
- cleanupActiveChild();
-
- int delta = consume((work > 0.0d) ? work : 0.0d);
- if (delta != 0)
- root.worked(delta);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String)
- */
- public void subTask(String name) {
- if ((flags & SUPPRESS_SUBTASK) == 0)
- root.subTask(name);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IProgressMonitor#worked(int)
- */
- public void worked(int work) {
- internalWorked(work);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean)
- */
- public void setCanceled(boolean b) {
- root.setCanceled(b);
- }
-
- /**
- * <p>Creates a sub progress monitor that will consume the given number of ticks from the
- * receiver. It is not necessary to call <code>beginTask</code> or <code>done</code> on the
- * result. However, the resulting progress monitor will not report any work after the first
- * call to done() or before ticks are allocated. Ticks may be allocated by calling beginTask
- * or setWorkRemaining.</p>
- *
- * <p>Each SubMonitor only has one active child at a time. Each time newChild() is called, the
- * result becomes the new active child and any unused progress from the previously-active child is
- * consumed.</p>
- *
- * <p>This is property makes it unnecessary to call done() on a SubMonitor instance, since child
- * monitors are automatically cleaned up the next time the parent is touched.</p>
- *
- * <code><pre>
- * ////////////////////////////////////////////////////////////////////////////
- * // Example 1: Typical usage of newChild
- * void myMethod(IProgressMonitor parent) {
- * SubMonitor progress = SubMonitor.convert(parent, 100);
- * doSomething(progress.newChild(50));
- * doSomethingElse(progress.newChild(50));
- * }
- *
- * ////////////////////////////////////////////////////////////////////////////
- * // Example 2: Demonstrates the function of active children. Creating children
- * // is sufficient to smoothly report progress, even if worked(...) and done()
- * // are never called.
- * void myMethod(IProgressMonitor parent) {
- * SubMonitor progress = SubMonitor.convert(parent, 100);
- *
- * for (int i = 0; i < 100; i++) {
- * // Creating the next child monitor will clean up the previous one,
- * // causing progress to be reported smoothly even if we don't do anything
- * // with the monitors we create
- * progress.newChild(1);
- * }
- * }
- *
- * ////////////////////////////////////////////////////////////////////////////
- * // Example 3: Demonstrates a common anti-pattern
- * void wrongMethod(IProgressMonitor parent) {
- * SubMonitor progress = SubMonitor.convert(parent, 100);
- *
- * // WRONG WAY: Won't have the intended effect, as only one of these progress
- * // monitors may be active at a time and the other will report no progress.
- * callMethod(progress.newChild(50), computeValue(progress.newChild(50)));
- * }
- *
- * void rightMethod(IProgressMonitor parent) {
- * SubMonitor progress = SubMonitor.convert(parent, 100);
- *
- * // RIGHT WAY: Break up method calls so that only one SubMonitor is in use at a time.
- * Object someValue = computeValue(progress.newChild(50));
- * callMethod(progress.newChild(50), someValue);
- * }
- * </pre></code>
- *
- * @param totalWork number of ticks to consume from the reciever
- * @return new sub progress monitor that may be used in place of a new SubMonitor
- */
- public SubMonitor newChild(int totalWork) {
- return newChild(totalWork, SUPPRESS_BEGINTASK);
- }
-
- /**
- * <p>Creates a sub progress monitor that will consume the given number of ticks from the
- * receiver. It is not necessary to call <code>beginTask</code> or <code>done</code> on the
- * result. However, the resulting progress monitor will not report any work after the first
- * call to done() or before ticks are allocated. Ticks may be allocated by calling beginTask
- * or setWorkRemaining.</p>
- *
- * <p>Each SubMonitor only has one active child at a time. Each time newChild() is called, the
- * result becomes the new active child and any unused progress from the previously-active child is
- * consumed.</p>
- *
- * <p>This is property makes it unnecessary to call done() on a SubMonitor instance, since child
- * monitors are automatically cleaned up the next time the parent is touched.</p>
- *
- * <code><pre>
- * ////////////////////////////////////////////////////////////////////////////
- * // Example 1: Typical usage of newChild
- * void myMethod(IProgressMonitor parent) {
- * SubMonitor progress = SubMonitor.convert(parent, 100);
- * doSomething(progress.newChild(50));
- * doSomethingElse(progress.newChild(50));
- * }
- *
- * ////////////////////////////////////////////////////////////////////////////
- * // Example 2: Demonstrates the function of active children. Creating children
- * // is sufficient to smoothly report progress, even if worked(...) and done()
- * // are never called.
- * void myMethod(IProgressMonitor parent) {
- * SubMonitor progress = SubMonitor.convert(parent, 100);
- *
- * for (int i = 0; i < 100; i++) {
- * // Creating the next child monitor will clean up the previous one,
- * // causing progress to be reported smoothly even if we don't do anything
- * // with the monitors we create
- * progress.newChild(1);
- * }
- * }
- *
- * ////////////////////////////////////////////////////////////////////////////
- * // Example 3: Demonstrates a common anti-pattern
- * void wrongMethod(IProgressMonitor parent) {
- * SubMonitor progress = SubMonitor.convert(parent, 100);
- *
- * // WRONG WAY: Won't have the intended effect, as only one of these progress
- * // monitors may be active at a time and the other will report no progress.
- * callMethod(progress.newChild(50), computeValue(progress.newChild(50)));
- * }
- *
- * void rightMethod(IProgressMonitor parent) {
- * SubMonitor progress = SubMonitor.convert(parent, 100);
- *
- * // RIGHT WAY: Break up method calls so that only one SubMonitor is in use at a time.
- * Object someValue = computeValue(progress.newChild(50));
- * callMethod(progress.newChild(50), someValue);
- * }
- * </pre></code>
- *
- * @param totalWork number of ticks to consume from the reciever
- * @return new sub progress monitor that may be used in place of a new SubMonitor
- */
- public SubMonitor newChild(int totalWork, int suppressFlags) {
- double totalWorkDouble = (totalWork > 0) ? totalWork : 0.0d;
- totalWorkDouble = Math.min(totalWorkDouble, totalForChildren - usedForChildren);
- cleanupActiveChild();
-
- // Compute the flags for the child. We want the net effect to be as though the child is
- // delegating to its parent, even though it is actually talking directly to the root.
- // This means that we need to compute the flags such that - even if a label isn't
- // suppressed by the child - if that same label would have been suppressed when the
- // child delegated to its parent, the child must explicitly suppress the label.
- int childFlags = SUPPRESS_NONE;
-
- if ((flags & SUPPRESS_SETTASKNAME) != 0) {
- // If the parent was ignoring labels passed to setTaskName, then the child will ignore
- // labels passed to either beginTask or setTaskName - since both delegate to setTaskName
- // on the parent
- childFlags |= SUPPRESS_SETTASKNAME | SUPPRESS_BEGINTASK;
- }
-
- if ((flags & SUPPRESS_SUBTASK) != 0) {
- // If the parent was suppressing labels passed to subTask, so will the child.
- childFlags |= SUPPRESS_SUBTASK;
- }
-
- // Note: the SUPPRESS_BEGINTASK flag does not affect the child since there
- // is no method on the child that would delegate to beginTask on the parent.
- childFlags |= suppressFlags;
-
- SubMonitor result = new SubMonitor(root, consume(totalWorkDouble), 0, childFlags);
- lastSubMonitor = result;
- return result;
- }
-
- private void cleanupActiveChild() {
- if (lastSubMonitor == null)
- return;
-
- IProgressMonitor child = lastSubMonitor;
- lastSubMonitor = null;
- child.done();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#clearBlocked()
- */
- public void clearBlocked() {
- root.clearBlocked();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#setBlocked(org.eclipse.core.runtime.IStatus)
- */
- public void setBlocked(IStatus reason) {
- root.setBlocked(reason);
- }
-
- protected static boolean eq(Object o1, Object o2) {
- if (o1 == null)
- return (o2 == null);
- if (o2 == null)
- return false;
- return o1.equals(o2);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubProgressMonitor.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubProgressMonitor.java
deleted file mode 100644
index 1c9bc120c..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubProgressMonitor.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.runtime;
-
-/**
- * For new implementations consider using {@link SubMonitor}.
- *
- * A progress monitor that uses a given amount of work ticks
- * from a parent monitor. It can be used as follows:
- * <pre>
- * try {
- * pm.beginTask("Main Task", 100);
- * doSomeWork(pm, 30);
- * SubProgressMonitor subMonitor= new SubProgressMonitor(pm, 40);
- * try {
- * subMonitor.beginTask("", 300);
- * doSomeWork(subMonitor, 300);
- * } finally {
- * subMonitor.done();
- * }
- * doSomeWork(pm, 30);
- * } finally {
- * pm.done();
- * }
- * </pre>
- * <p>
- * This class can be used without OSGi running.
- * </p><p>
- * This class may be instantiated or subclassed by clients.
- * </p>
- *
- * @see SubMonitor
- */
-public class SubProgressMonitor extends ProgressMonitorWrapper {
-
- /**
- * Style constant indicating that calls to <code>subTask</code>
- * should not have any effect.
- *
- * @see #SubProgressMonitor(IProgressMonitor,int,int)
- */
- public static final int SUPPRESS_SUBTASK_LABEL = 1 << 1;
- /**
- * Style constant indicating that the main task label
- * should be prepended to the subtask label.
- *
- * @see #SubProgressMonitor(IProgressMonitor,int,int)
- */
- public static final int PREPEND_MAIN_LABEL_TO_SUBTASK = 1 << 2;
-
- private int parentTicks = 0;
- private double sentToParent = 0.0;
- private double scale = 0.0;
- private int nestedBeginTasks = 0;
- private boolean usedUp = false;
- private boolean hasSubTask = false;
- private int style;
- private String mainTaskLabel;
-
- /**
- * Creates a new sub-progress monitor for the given monitor. The sub
- * progress monitor uses the given number of work ticks from its
- * parent monitor.
- *
- * @param monitor the parent progress monitor
- * @param ticks the number of work ticks allocated from the
- * parent monitor
- */
- public SubProgressMonitor(IProgressMonitor monitor, int ticks) {
- this(monitor, ticks, 0);
- }
-
- /**
- * Creates a new sub-progress monitor for the given monitor. The sub
- * progress monitor uses the given number of work ticks from its
- * parent monitor.
- *
- * @param monitor the parent progress monitor
- * @param ticks the number of work ticks allocated from the
- * parent monitor
- * @param style one of
- * <ul>
- * <li> <code>SUPPRESS_SUBTASK_LABEL</code> </li>
- * <li> <code>PREPEND_MAIN_LABEL_TO_SUBTASK</code> </li>
- * </ul>
- * @see #SUPPRESS_SUBTASK_LABEL
- * @see #PREPEND_MAIN_LABEL_TO_SUBTASK
- */
- public SubProgressMonitor(IProgressMonitor monitor, int ticks, int style) {
- super(monitor);
- this.parentTicks = (ticks > 0) ? ticks : 0;
- this.style = style;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the method <code>IProgressMonitor.beginTask</code>.
- *
- * Starts a new main task. Since this progress monitor is a sub
- * progress monitor, the given name will NOT be used to update
- * the progress bar's main task label. That means the given
- * string will be ignored. If style <code>PREPEND_MAIN_LABEL_TO_SUBTASK
- * <code> is specified, then the given string will be prepended to
- * every string passed to <code>subTask(String)</code>.
- */
- public void beginTask(String name, int totalWork) {
- nestedBeginTasks++;
- // Ignore nested begin task calls.
- if (nestedBeginTasks > 1) {
- return;
- }
- // be safe: if the argument would cause math errors (zero or
- // negative), just use 0 as the scale. This disables progress for
- // this submonitor.
- scale = totalWork <= 0 ? 0 : (double) parentTicks / (double) totalWork;
- if ((style & PREPEND_MAIN_LABEL_TO_SUBTASK) != 0) {
- mainTaskLabel = name;
- }
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the method <code>IProgressMonitor.done</code>.
- */
- public void done() {
- // Ignore if more done calls than beginTask calls or if we are still
- // in some nested beginTasks
- if (nestedBeginTasks == 0 || --nestedBeginTasks > 0)
- return;
- // Send any remaining ticks and clear out the subtask text
- double remaining = parentTicks - sentToParent;
- if (remaining > 0)
- super.internalWorked(remaining);
- //clear the sub task if there was one
- if (hasSubTask)
- subTask(""); //$NON-NLS-1$
- sentToParent = 0;
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the internal method <code>IProgressMonitor.internalWorked</code>.
- */
- public void internalWorked(double work) {
- if (usedUp || nestedBeginTasks != 1) {
- return;
- }
-
- double realWork = (work > 0.0d) ? scale * work : 0.0d;
- super.internalWorked(realWork);
- sentToParent += realWork;
- if (sentToParent >= parentTicks) {
- usedUp = true;
- }
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the method <code>IProgressMonitor.subTask</code>.
- */
- public void subTask(String name) {
- if ((style & SUPPRESS_SUBTASK_LABEL) != 0) {
- return;
- }
- hasSubTask = true;
- String label = name;
- if ((style & PREPEND_MAIN_LABEL_TO_SUBTASK) != 0 && mainTaskLabel != null && mainTaskLabel.length() > 0) {
- label = mainTaskLabel + ' ' + label;
- }
- super.subTask(label);
- }
-
- /* (Intentionally not javadoc'd)
- * Implements the method <code>IProgressMonitor.worked</code>.
- */
- public void worked(int work) {
- internalWorked(work);
- }
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/package.html b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/package.html
deleted file mode 100644
index d81771f3d..000000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/package.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides support for the runtime platform, core utility methods and the extension registry.
-<h2>
-Package Specification</h2>
-This package contains three components:<ul>
-<li>APIs related to the runtime platform itself (provided by the <tt>org.eclipse.core.runtime</tt> plug-in)</li>
-<li>Various utility types such as <tt>Path</tt>, <tt>IPath</tt> and various flavours of progress monitors (provided by the <tt>org.eclipse.equinox.common</tt> plug-in)</li>
-<li>Extension registry mechanism (provided by the <tt>org.eclipse.equinox.registry</tt> plug-in)</li>
-</ul>
-</body>
-</html>

Back to the top