- * The corresponding value is a list of the extension point element records associated with that extension point.
- *
- *
- * Each root element record has synthetic attributes derived from the extension point:
- *
- *
- *
{@code point}
- *
The extension point ID itself.
- *
{@code symbolicName}
- *
The symbolic name of the bundle that contains the extension point.
- *
{@code location}
- *
- * The root location URI the bundle containing the extension point.
- * For example, {@code platform:/resource/org.example.plugin} for an extension point in the workspace,
- * {@code file:/folder/org.eclipse.plugin} for folder bundle in the target platform,
- * or {@code archive:file:/file/folder/org.example.plugin.jar!/} for a jarred bundle in the target platform.
- * This is useful for resolving a relative path in attribute value to its absolute path in the bundle.
- *
- *
- *
- * This method uses the Plug-in Development Environment (PDE) to compute the results.
- * It will include results for plug-ins in the workspace as well as for plug-ins in the target platform.
- * If PDE is not available, this information cannot be computed.
- *
- *
- * @param extensionPoints a set of extension points to query; if it's {@code null} or empty, all extension points will be queried.
- * @return a map of extension point data, or {@code null} if PDE is not available.
- * @since 2.14
- */
- public static Map> getTargetPlatformExtensionPoints(Set extensionPoints)
- {
- if (IS_ECLIPSE_RUNNING && PDEHelper.IS_PDE_BUNDLE_AVAILABLE)
- {
- return PDEHelper.computeModels(extensionPoints);
- }
- else
- {
- return null;
- }
- }
-
- /**
- * Computes a map from bundle symbolic name to the bundle's location URI.
- *
- * This method uses the Plug-in Development Environment (PDE) to compute the results.
- * It will include results for plug-ins in the workspace as well as for plug-ins in the target platform.
- * If PDE is not available, this information cannot be computed.
- *
- *
- * @return a map from bundle symbolic name to the bundle's location URI, or {@code null} if PDE is not available.
- * @since 2.14
- */
- public static Map getTargetPlatformBundleMappings()
- {
- if (IS_ECLIPSE_RUNNING && PDEHelper.IS_PDE_BUNDLE_AVAILABLE)
- {
- return PDEHelper.computeTargetPlatformBundleMappings();
- }
- else
- {
- return null;
- }
+ return Class.forName(className);
}
private static final Method COLLATOR_GET_INSTANCE_METHOD;
@@ -223,130 +110,6 @@ public Comparator getComparator(Locale locale)
return (Comparator)(Comparator>)Collator.getInstance(locale);
}
- /**
- * The actual implementation of the Eclipse Plugin.
- */
- public static class Implementation extends EclipsePlugin
- {
- /**
- * Creates an instance.
- */
- public Implementation()
- {
- super();
-
- // Remember the static instance.
- //
- plugin = this;
- }
-
- /**
- * Use the platform to convert to a local URI.
- */
- protected static URI asLocalURI(URI uri)
- {
- try
- {
- String fragment = uri.fragment();
- URL url = FileLocator.toFileURL(new URL(uri.trimFragment().toString()));
- return fix(url, fragment);
- }
- catch (IOException exception)
- {
- // Ignore the exception and return the original URI.
- }
- return uri;
- }
-
- /**
- * Use the platform to convert to a local URI.
- */
- protected static URI resolve(URI uri)
- {
- String fragment = uri.fragment();
- URI uriWithoutFragment = uri.trimFragment();
- String uriWithoutFragmentToString = uriWithoutFragment.toString();
-
- URL url = null;
- try
- {
- url = FileLocator.resolve(new URL(uriWithoutFragmentToString));
- }
- catch (IOException exception1)
- {
- // Platform.resolve() doesn't work if the project is encoded.
- //
- try
- {
- uriWithoutFragmentToString = URI.decode(uriWithoutFragmentToString);
- url = FileLocator.resolve(new URL(uriWithoutFragmentToString));
- }
- catch (IOException exception2)
- {
- // Continue with the unresolved URI.
- }
- }
- if (url != null)
- {
- try
- {
- return fix(url, fragment);
- }
- catch (IOException exception)
- {
- // Return the original URI.
- }
- }
-
- return uri;
- }
-
- protected static URI fix(URL url, String fragment) throws IOException
- {
- // Only file-scheme URIs will be re-encoded. If a URI was decoded in the workaround
- // above, and Platform.resolve() didn't return a file-scheme URI, then this will return
- // an decoded URI.
- //
- URI result =
- "file".equalsIgnoreCase(url.getProtocol()) ?
- URI.createFileURI(URI.decode(url.getFile())) :
- URI.createURI(url.toString());
- if (fragment != null)
- {
- result = result.appendFragment(fragment);
- }
- return result;
- }
-
- /**
- * Use the platform to load the named class using the right class loader.
- */
- public static Class> loadClass(String pluginID, String className) throws ClassNotFoundException
- {
- Bundle bundle = Platform.getBundle(pluginID);
- if (bundle == null)
- {
- throw new ClassNotFoundException(className + " cannot be loaded because because bundle " + pluginID + " cannot be resolved");
- }
- else
- {
- return bundle.loadClass(className);
- }
- }
-
- /**
- * @since 2.10
- */
- public static class Activator extends EMFPlugin.OSGiDelegatingBundleActivator
- {
- @Override
- protected BundleActivator createBundle()
- {
- return new Implementation();
- }
- }
- }
-
/**
* A specialized {@link HashMap} map that supports {@link #getTargetPlatformValues(String,String) computing} information from the target platform, if the PDE is available.
* It is abstract because the {@link #createKey(String)} method must be specialized to convert each attribute's string value to a value of the map's key type.
@@ -378,31 +141,7 @@ public SimpleTargetPlatformRegistryImpl()
*/
protected Set getTargetPlatformValues(String extensionPoint, String attributeName)
{
- Map> targetPlatformExtensionPoints = getTargetPlatformExtensionPoints(Collections.singleton(extensionPoint));
- if (targetPlatformExtensionPoints != null)
- {
- Set result = new LinkedHashSet();
- List extensionPointElementRecords = targetPlatformExtensionPoints.get(extensionPoint);
- if (extensionPointElementRecords != null)
- {
- for (CommonPlugin.ElementRecord extensionPointRecord : extensionPointElementRecords)
- {
- for (ElementRecord elementRecord : extensionPointRecord.getChildren())
- {
- String attribute = elementRecord.getAttributes().get(attributeName);
- if (attribute != null)
- {
- result.add(createKey(attribute));
- }
- }
- }
- }
- return result;
- }
- else
- {
- return new LinkedHashSet(keySet());
- }
+ return new LinkedHashSet(keySet());
}
/**
@@ -482,376 +221,4 @@ public String toString()
return "" + name + "attributes= " + attributes + " children=" + children;
}
}
-
- private static class PDEHelper
- {
- private static final Method PLUGIN_MODEL_BASE_GET_BUNDLE_DESCRIPTION_METHOD;
-
- private static final Method PLUGIN_MODEL_BASE_GET_UNDERLYING_RESOURCE_METHOD;
-
- private static final Method RESOURCE_GET_PROJECT_METHOD;
-
- private static final Method RESOURCE_GET_FULL_PATH_METHOD;
-
- private static final Method PLUGIN_MODEL_BASE_GET_INSTALL_LOCATION_METHOD;
-
- private static final Method PLUGIN_MODEL_BASE_GET_EXTENSIONS_METHOD;
-
- private static final Method PLUGIN_REGISTRY_GET_ACTIVE_MODELS_METHOD;
-
- private static final Method BUNDLE_DESCRIPTION_GET_SYMBOLIC_NAME_METHOD;
-
- private static final Method EXTENSIONS_GET_EXTENSIONS_METHOD;
-
- private static final Method PLUGIN_EXTENSION_GET_POINT_METHOD;
-
- private static final Method PLUGIN_EXTENSION_GET_CHILDREN_METHOD;
-
- private static final Class> PLUGIN_ELEMENT_CLASS;
-
- private static final Method PLUGIN_ELEMENT_GET_ATTRIBUTES_METHOD;
-
- private static final Method PLUGIN_OBJECT_GET_NAME_METHOD;
-
- private static final Method PLUGIN_ATTRIBUTE_GET_VALUE_METHOD;
-
- private static final boolean IS_PDE_BUNDLE_AVAILABLE;
-
- static
- {
- Method pluginModelBaseGetBundleDescriptionMethod = null;
- Method pluginModelBaseGetUnderlyingResourceMethod = null;
- Method resourceGetProjectMethod = null;
- Method resourceGetFullPathtMethod = null;
- Method pluginModelBaseGetInstallLocationMethod = null;
- Method pluginModelBaseGetExtensionsMethod = null;
- Method pluginRegistryGetActiveModelsMethod = null;
- Method bundleDescriptionGetSymbolicNameMethod = null;
- Method extensionsGetExtensionsMethod = null;
- Method pluginExtensionGetPointMethod = null;
- Method pluginExtensionGetChildrenMethod = null;
- Class> pluginElementClass = null;
- Method pluginElementGetAttributesMethod = null;
- Method pluginObjectGetNameMethod = null;
- Method pluginAttributeGetValueMethod = null;
- boolean isPDEBundleAvailable = false;
-
- try
- {
- Class> pluginModelBaseClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.pde.core.plugin.IPluginModelBase");
- pluginModelBaseGetBundleDescriptionMethod = pluginModelBaseClass.getMethod("getBundleDescription");
- pluginModelBaseGetUnderlyingResourceMethod = pluginModelBaseClass.getMethod("getUnderlyingResource");
- resourceGetProjectMethod = pluginModelBaseGetUnderlyingResourceMethod.getReturnType().getMethod("getProject");
- resourceGetFullPathtMethod = resourceGetProjectMethod.getReturnType().getMethod("getFullPath");
- pluginModelBaseGetInstallLocationMethod = pluginModelBaseClass.getMethod("getInstallLocation");
- pluginModelBaseGetExtensionsMethod = pluginModelBaseClass.getMethod("getExtensions");
- Class> pluginRegistryClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.pde.core.plugin.PluginRegistry");
- pluginRegistryGetActiveModelsMethod = pluginRegistryClass.getMethod("getActiveModels", boolean.class);
- Class> bundleDescriptionClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.osgi.service.resolver.BundleDescription");
- bundleDescriptionGetSymbolicNameMethod = bundleDescriptionClass.getMethod("getSymbolicName");
- Class> extensionsClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.pde.core.plugin.IExtensions");
- extensionsGetExtensionsMethod = extensionsClass.getMethod("getExtensions");
- Class> pluginExtensionClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.pde.core.plugin.IPluginExtension");
- pluginExtensionGetPointMethod = pluginExtensionClass.getMethod("getPoint");
- pluginExtensionGetChildrenMethod = pluginExtensionClass.getMethod("getChildren");
- pluginElementClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.pde.core.plugin.IPluginElement");
- pluginObjectGetNameMethod = pluginElementClass.getMethod("getName");
- pluginElementGetAttributesMethod = pluginElementClass.getMethod("getAttributes");
- Class> pluginAttributeClass = CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.pde.core.plugin.IPluginAttribute");
- pluginAttributeGetValueMethod = pluginAttributeClass.getMethod("getValue");
- isPDEBundleAvailable = true;
- }
- catch (Throwable exception)
- {
- // Ignore.
- }
-
- PLUGIN_MODEL_BASE_GET_BUNDLE_DESCRIPTION_METHOD = pluginModelBaseGetBundleDescriptionMethod;
- PLUGIN_MODEL_BASE_GET_UNDERLYING_RESOURCE_METHOD = pluginModelBaseGetUnderlyingResourceMethod;
- RESOURCE_GET_PROJECT_METHOD = resourceGetProjectMethod;
- RESOURCE_GET_FULL_PATH_METHOD = resourceGetFullPathtMethod;
- PLUGIN_MODEL_BASE_GET_INSTALL_LOCATION_METHOD = pluginModelBaseGetInstallLocationMethod;
- PLUGIN_MODEL_BASE_GET_EXTENSIONS_METHOD = pluginModelBaseGetExtensionsMethod;
- PLUGIN_REGISTRY_GET_ACTIVE_MODELS_METHOD = pluginRegistryGetActiveModelsMethod;
- BUNDLE_DESCRIPTION_GET_SYMBOLIC_NAME_METHOD = bundleDescriptionGetSymbolicNameMethod;
- EXTENSIONS_GET_EXTENSIONS_METHOD = extensionsGetExtensionsMethod;
- PLUGIN_EXTENSION_GET_POINT_METHOD = pluginExtensionGetPointMethod;
- PLUGIN_EXTENSION_GET_CHILDREN_METHOD = pluginExtensionGetChildrenMethod;
- PLUGIN_ELEMENT_CLASS = pluginElementClass;
- PLUGIN_OBJECT_GET_NAME_METHOD = pluginObjectGetNameMethod;
- PLUGIN_ELEMENT_GET_ATTRIBUTES_METHOD = pluginElementGetAttributesMethod;
- PLUGIN_ATTRIBUTE_GET_VALUE_METHOD = pluginAttributeGetValueMethod;
- IS_PDE_BUNDLE_AVAILABLE = isPDEBundleAvailable && !"true".equals(System.getProperty("org.eclipse.emf.common.CommonPlugin.doNotUsePDE"));
- }
-
- @SuppressWarnings("unchecked")
- private static T invoke(Object object, Method method, Object... arguments)
- {
- try
- {
- return (T)method.invoke(object, arguments);
- }
- catch (Exception exception)
- {
- return null;
- }
- }
-
- private static Map computeTargetPlatformBundleMappings()
- {
- Map result = new TreeMap();
-
- // Iterate over all the active models in the workspace and target platform.
- //
- // IPluginModelBase[] activeModels = PluginRegistry.getActiveModels(false);
- //
- Object[] activeModels = invoke(null, PLUGIN_REGISTRY_GET_ACTIVE_MODELS_METHOD, Boolean.FALSE);
- for (Object activeModel : activeModels)
- {
- // Determine the symbolic name, underlying resource, if any, and the install location.
- //
- // BundleDescription bundleDescription = activeModel.getBundleDescription();
- // String symbolicName = bundleDescription.getSymbolicName();
- // IResource underlyingResource = activeModel.getUnderlyingResource();
- // String installLocation = activeModel.getInstallLocation();
- //
- Object bundleDescription = invoke(activeModel, PLUGIN_MODEL_BASE_GET_BUNDLE_DESCRIPTION_METHOD);
- String symbolicName = (String)invoke(bundleDescription, BUNDLE_DESCRIPTION_GET_SYMBOLIC_NAME_METHOD);
- Object underlyingResource = invoke(activeModel, PLUGIN_MODEL_BASE_GET_UNDERLYING_RESOURCE_METHOD);
- String installLocation = (String)invoke(activeModel, PLUGIN_MODEL_BASE_GET_INSTALL_LOCATION_METHOD);
-
- // The URI for the location is determined from the underlying resource or the install location, with preference to the former if available.
- //
- URI location;
- if (underlyingResource != null)
- {
- // If there is an underlying resource, use the platform resource URI referencing the project in the workspace as the location.
- // underlyingResource.getProject()
- //
- Object project = invoke(underlyingResource, RESOURCE_GET_PROJECT_METHOD);
- IPath fullPath = invoke(project, RESOURCE_GET_FULL_PATH_METHOD);
- location = URI.createPlatformResourceURI(fullPath.toString(), true);
- }
- else if (installLocation != null)
- {
- // Otherwise, the install location in the file system is used...
- //
- File file = new File(installLocation);
- if (file.isDirectory())
- {
- // If the file is a directory, create a file URI for that directory.
- //
- location = URI.createFileURI(installLocation);
- }
- else
- {
- // Otherwise, the location must be an archive, create an archive URI for the file URI of the jar.
- //
- location = URI.createURI("archive:" + URI.createFileURI(installLocation) + "!/");
- }
- }
- else
- {
- location = null;
- }
-
- if (symbolicName != null && location != null)
- {
- result.put(symbolicName, location);
- }
- }
-
- return result;
- }
-
- private static Map> computeModels(Set extensionPoints)
- {
- Map> result = new TreeMap>();
-
- // Iterate over all the active models in the workspace and target platform.
- //
- // IPluginModelBase[] activeModels = PluginRegistry.getActiveModels(false);
- //
- Object[] activeModels = invoke(null, PLUGIN_REGISTRY_GET_ACTIVE_MODELS_METHOD, Boolean.FALSE);
- for (Object activeModel : activeModels)
- {
- // Iterate over the plugin's extensions...
- //
- // IExtensions extensions = activeModel.getExtensions();
- // IPluginExtension[] pluginExtensions = extensions.getExtensions();
- //
- Object extensions = invoke(activeModel, PLUGIN_MODEL_BASE_GET_EXTENSIONS_METHOD);
- Object[] pluginExtensions = invoke(extensions, EXTENSIONS_GET_EXTENSIONS_METHOD);
- for (Object pluginExtension : pluginExtensions)
- {
- // String point = pluginExtension.getPoint();
- //
- String point = invoke(pluginExtension, PLUGIN_EXTENSION_GET_POINT_METHOD);
-
- // Process all or the specified extension pointers.
- //
- if (extensionPoints == null || extensionPoints.isEmpty() || extensionPoints.contains(point))
- {
- // Determine the symbolic name, underlying resource, if any, and the install location.
- //
- // BundleDescription bundleDescription = activeModel.getBundleDescription();
- // String symbolicName = bundleDescription.getSymbolicName();
- // IResource underlyingResource = activeModel.getUnderlyingResource();
- // String installLocation = activeModel.getInstallLocation();
- //
- Object bundleDescription = invoke(activeModel, PLUGIN_MODEL_BASE_GET_BUNDLE_DESCRIPTION_METHOD);
- String symbolicName = (String)invoke(bundleDescription, BUNDLE_DESCRIPTION_GET_SYMBOLIC_NAME_METHOD);
- Object underlyingResource = invoke(activeModel, PLUGIN_MODEL_BASE_GET_UNDERLYING_RESOURCE_METHOD);
- String installLocation = (String)invoke(activeModel, PLUGIN_MODEL_BASE_GET_INSTALL_LOCATION_METHOD);
-
- // The URI for the location is determined from the underlying resource or the install location, with preference to the former if available.
- //
- URI location;
- if (underlyingResource != null)
- {
- // If there is an underlying resource, use the platform resource URI referencing the project in the workspace as the location.
- // underlyingResource.getProject()
- //
- Object project = invoke(underlyingResource, RESOURCE_GET_PROJECT_METHOD);
- IPath fullPath = invoke(project, RESOURCE_GET_FULL_PATH_METHOD);
- location = URI.createPlatformResourceURI(fullPath.toString(), true);
- }
- else if (installLocation != null)
- {
- // Otherwise, the install location in the file system is used...
- //
- File file = new File(installLocation);
- if (file.isDirectory())
- {
- // If the file is a directory, create a file URI for that directory.
- //
- location = URI.createFileURI(installLocation);
- }
- else
- {
- // Otherwise, the location must be an archive, create an archive URI for the file URI of the jar.
- //
- location = URI.createURI("archive:" + URI.createFileURI(installLocation) + "!/");
- }
- }
- else
- {
- location = null;
- }
-
- List elementRecords = result.get(point);
- if (elementRecords == null)
- {
- elementRecords = new ArrayList();
- result.put(point, elementRecords);
- }
-
- ElementRecord elementRecord = visitElement(pluginExtension);
- if (location != null)
- {
- elementRecord.attributes.put("point", point);
- elementRecord.attributes.put("symbolicName", symbolicName);
- elementRecord.attributes.put("location", location.toString());
- }
- elementRecords.add(elementRecord);
- }
- }
- }
-
- // dump(result);
- return result;
- }
-
- private static void visitElement(Object[] children, List elementRecords)
- {
- // Visit the children.
- //
- for (Object child : children)
- {
- // if (child instanceof IPluginElement)
- //
- if (PLUGIN_ELEMENT_CLASS.isInstance(child))
- {
- elementRecords.add(visitElement(child));
- }
- }
- }
-
- private static ElementRecord visitElement(Object child)
- {
- ElementRecord elementRecord;
- if (PLUGIN_ELEMENT_CLASS.isInstance(child))
- {
- // child.getName();
- //
- String elementName = invoke(child, PLUGIN_OBJECT_GET_NAME_METHOD);
-
- // Record it by name.
- //
- elementRecord = new ElementRecord(elementName);
-
- // child.getAttributes()
- Object[] attributes = invoke(child, PLUGIN_ELEMENT_GET_ATTRIBUTES_METHOD);
- for (Object attribute : attributes)
- {
- // attribute.getName() and attribute.getValue()
- //
- String attributeName = invoke(attribute, PLUGIN_OBJECT_GET_NAME_METHOD);
- String attributeValue = invoke(attribute, PLUGIN_ATTRIBUTE_GET_VALUE_METHOD);
-
- // Record in the map.
- //
- elementRecord.attributes.put(attributeName, attributeValue);
- }
- }
- else
- {
- elementRecord = new ElementRecord("extension");
- }
-
- // Visit the child elements recursively.
- //
- Object[] elements = invoke(child, PLUGIN_EXTENSION_GET_CHILDREN_METHOD);
- if (elements.length != 0)
- {
- visitElement(elements, elementRecord.children);
- }
-
- return elementRecord;
- }
-
-// private static void dump(Map> data)
-// {
-// for (Map.Entry> entry : data.entrySet())
-// {
-// System.out.println(entry.getKey());
-// dump(entry.getValue(), " ");
-// }
-// }
-//
-// private static void dump(List data, String indent)
-// {
-// for (ElementRecord elementRecord : data)
-// {
-// System.out.print(indent + "<" + elementRecord.getName());
-// for (Map.Entry attribute : elementRecord.getAttributes().entrySet())
-// {
-// System.out.println();
-// System.out.print(indent + " " + attribute.getKey() + "='" + attribute.getValue() + "'");
-// }
-// List children = elementRecord.getChildren();
-// if (children.isEmpty())
-// {
-// System.out.println("/>");
-// }
-// else
-// {
-// System.out.println(">");
-// dump(children, indent + " ");
-// System.out.print(indent + "" + elementRecord.getName() + ">");
-// }
-// }
-// }
-
- }
}
diff --git a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/EMFPlugin.java b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/EMFPlugin.java
index e856195..45e3ac8 100644
--- a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/EMFPlugin.java
+++ b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/EMFPlugin.java
@@ -13,29 +13,13 @@
import java.io.IOException;
import java.io.InputStream;
-import java.net.MalformedURLException;
import java.net.URL;
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
import java.util.jar.Manifest;
-import org.eclipse.core.runtime.ILog;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.util.DelegatingResourceLocator;
import org.eclipse.emf.common.util.Logger;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.common.util.WrappedException;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.FrameworkUtil;
/**
@@ -57,57 +41,9 @@
*/
public abstract class EMFPlugin extends DelegatingResourceLocator implements ResourceLocator, Logger
{
- /**
- * @since 2.27
- */
- public static final boolean IS_OSGI_RUNNING;
- static
- {
- boolean result = false;
- try
- {
- result = FrameworkUtil.getBundle(EMFPlugin.class) != null;
- }
- catch (Throwable exception)
- {
- // Assume that we aren't running.
- }
- IS_OSGI_RUNNING = result;
- }
+ public static final boolean IS_ECLIPSE_RUNNING = false;
- public static final boolean IS_ECLIPSE_RUNNING;
- static
- {
- boolean result = false;
- try
- {
- result = Platform.isRunning();
- }
- catch (Throwable exception)
- {
- // Assume that we aren't running.
- }
- IS_ECLIPSE_RUNNING = result;
- }
-
- public static final boolean IS_RESOURCES_BUNDLE_AVAILABLE;
- static
- {
- boolean result = false;
- if (IS_ECLIPSE_RUNNING)
- {
- try
- {
- Bundle resourcesBundle = Platform.getBundle("org.eclipse.core.resources");
- result = resourcesBundle != null && (resourcesBundle.getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.RESOLVED)) != 0;
- }
- catch (Throwable exception)
- {
- // Assume that it's not available.
- }
- }
- IS_RESOURCES_BUNDLE_AVAILABLE = result;
- }
+ public static final boolean IS_RESOURCES_BUNDLE_AVAILABLE = false;
protected ResourceLocator [] delegateResourceLocators;
@@ -116,16 +52,10 @@ public EMFPlugin(ResourceLocator [] delegateResourceLocators)
this.delegateResourceLocators = delegateResourceLocators;
}
- /**
- * Returns an Eclipse plugin implementation of a resource locator.
- * @return an Eclipse plugin implementation of a resource locator.
- */
- public abstract ResourceLocator getPluginResourceLocator();
-
@Override
final protected ResourceLocator getPrimaryResourceLocator()
{
- return getPluginResourceLocator();
+ return null;
}
@Override
@@ -134,27 +64,10 @@ protected ResourceLocator[] getDelegateResourceLocators()
return delegateResourceLocators;
}
- /**
- * Returns an Eclipse plugin implementation of a logger.
- * @return an Eclipse plugin implementation of a logger.
- */
- public Logger getPluginLogger()
- {
- return (Logger)getPluginResourceLocator();
- }
-
public String getSymbolicName()
{
- ResourceLocator resourceLocator = getPluginResourceLocator();
- if (resourceLocator instanceof InternalEclipsePlugin)
- {
- return ((InternalEclipsePlugin)resourceLocator).getSymbolicName();
- }
- else
- {
- String result = getClass().getName();
- return result.substring(0, result.lastIndexOf('.'));
- }
+ String result = getClass().getName();
+ return result.substring(0, result.lastIndexOf('.'));
}
/*
@@ -162,168 +75,13 @@ public String getSymbolicName()
*/
public void log(Object logEntry)
{
- Logger logger = getPluginLogger();
- if (logger == null)
+ if (logEntry instanceof Throwable)
{
- if (logEntry instanceof Throwable)
- {
- ((Throwable)logEntry).printStackTrace(System.err);
- }
- else
- {
- System.err.println(logEntry);
- }
+ ((Throwable)logEntry).printStackTrace(System.err);
}
else
{
- logger.log(logEntry);
- }
- }
-
- /**
- * This is just a bundle activator wrapper for delegating to another bundle activator.
- * It provides a {@link #createBundle() create} method for creating the delegate.
- * Any exception thrown during creation of the delegate is ignored,
- * in which case this activator does nothing for {@link #start(BundleContext) start} and {@link #stop(BundleContext) stop}.
- * The idea is to provide a bundle activator that can delegate to an Equinox-dependent bundle activator,
- * but behaves gracefully in a non-Equinox OSGi implementation.
- *
- * @since 2.10
- */
- public static abstract class OSGiDelegatingBundleActivator implements BundleActivator
- {
- private final BundleActivator bundle;
-
- public OSGiDelegatingBundleActivator()
- {
- bundle = createBundleHelper();
- }
-
- private BundleActivator createBundleHelper()
- {
- try
- {
- return createBundle();
- }
- catch (Throwable throwable)
- {
- return null;
- }
- }
-
- protected abstract BundleActivator createBundle();
-
- public final void start(BundleContext context) throws Exception
- {
- if (bundle != null)
- {
- bundle.start(context);
- }
- }
-
- public final void stop(BundleContext context) throws Exception
- {
- if (bundle != null)
- {
- bundle.stop(context);
- }
- }
- }
-
- /**
- * The actual implementation of an Eclipse Plugin.
- */
- public static abstract class EclipsePlugin extends Plugin implements ResourceLocator, Logger, InternalEclipsePlugin
- {
- /**
- * The EMF plug-in APIs are all delegated to this helper, so that code can be shared by plug-in
- * implementations with a different platform base class (e.g. AbstractUIPlugin).
- */
- protected InternalHelper helper;
-
- /**
- * Creates an instance.
- */
- public EclipsePlugin()
- {
- super();
- helper = new InternalHelper(this);
- }
-
- /**
- * Return the plugin ID.
- */
- public String getSymbolicName()
- {
- return helper.getSymbolicName();
- }
-
- /*
- * Javadoc copied from interface.
- */
- public URL getBaseURL()
- {
- return helper.getBaseURL();
- }
-
- /*
- * Javadoc copied from interface.
- */
- public Object getImage(String key)
- {
- try
- {
- return doGetImage(key);
- }
- catch (MalformedURLException exception)
- {
- throw new WrappedException(exception);
- }
- catch (IOException exception)
- {
- throw
- new MissingResourceException
- (CommonPlugin.INSTANCE.getString("_UI_StringResourceNotFound_exception", new Object [] { key }),
- getClass().getName(),
- key);
- }
- }
-
- /**
- * Does the work of fetching the image associated with the key.
- * It ensures that the image exists.
- * @param key the key of the image to fetch.
- * @exception IOException if an image doesn't exist.
- * @return the description of the image associated with the key.
- */
- protected Object doGetImage(String key) throws IOException
- {
- return helper.getImage(key);
- }
-
- public String getString(String key)
- {
- return helper.getString(key, true);
- }
-
- public String getString(String key, boolean translate)
- {
- return helper.getString(key, translate);
- }
-
- public String getString(String key, Object [] substitutions)
- {
- return helper.getString(key, substitutions, true);
- }
-
- public String getString(String key, Object [] substitutions, boolean translate)
- {
- return helper.getString(key, substitutions, translate);
- }
-
- public void log(Object logEntry)
- {
- helper.log(logEntry);
+ System.err.println(logEntry);
}
}
@@ -335,141 +93,6 @@ public static interface InternalEclipsePlugin
{
String getSymbolicName();
}
-
- /**
- * This just provides a common delegate for non-UI and UI plug-in classes.
- * It is not considered API and should not be used by clients.
- */
- public static class InternalHelper
- {
- protected Plugin plugin;
- protected ResourceBundle resourceBundle;
- protected ResourceBundle untranslatedResourceBundle;
-
- public InternalHelper(Plugin plugin)
- {
- this.plugin = plugin;
- }
-
- protected Bundle getBundle()
- {
- return plugin.getBundle();
- }
-
- protected ILog getLog()
- {
- return plugin.getLog();
- }
-
- /**
- * Return the plugin ID.
- */
- public String getSymbolicName()
- {
- return getBundle().getSymbolicName();
- }
-
- public URL getBaseURL()
- {
- return getBundle().getEntry("/");
- }
-
- /**
- * Fetches the image associated with the given key. It ensures that the image exists.
- * @param key the key of the image to fetch.
- * @exception IOException if an image doesn't exist.
- * @return the description of the image associated with the key.
- */
- public Object getImage(String key) throws IOException
- {
- URL url = new URL(getBaseURL() + "icons/" + key + extensionFor(key));
- InputStream inputStream = url.openStream();
- inputStream.close();
- return url;
- }
-
- public String getString(String key, boolean translate)
- {
- ResourceBundle bundle = translate ? resourceBundle : untranslatedResourceBundle;
- if (bundle == null)
- {
- if (translate)
- {
- bundle = resourceBundle = Platform.getResourceBundle(getBundle());
- }
- else
- {
- String bundleLocalization = (String)getBundle().getHeaders().get(Constants.BUNDLE_LOCALIZATION);
- String propertiesPath = bundleLocalization != null ? bundleLocalization + ".properties" : "plugin.properties";
- String resourceName = getBaseURL().toString() + propertiesPath;
- try
- {
- InputStream inputStream = new URL(resourceName).openStream();
- bundle = untranslatedResourceBundle = new PropertyResourceBundle(inputStream);
- inputStream.close();
- }
- catch (IOException ioException)
- {
- throw new MissingResourceException("Missing properties: " + resourceName, getClass().getName(), propertiesPath);
- }
- }
- }
- return bundle.getString(key);
- }
-
- public String getString(String key, Object [] substitutions, boolean translate)
- {
- return MessageFormat.format(getString(key, translate), substitutions);
- }
-
- public void log(Object logEntry)
- {
- IStatus status;
- if (logEntry instanceof IStatus)
- {
- status = (IStatus)logEntry;
- getLog().log(status);
- }
- else
- {
- if (logEntry == null)
- {
- logEntry = new RuntimeException(getString("_UI_NullLogEntry_exception", true)).fillInStackTrace();
- }
-
- if (logEntry instanceof Throwable)
- {
- Throwable throwable = (Throwable)logEntry;
-
- // System.err.println("Logged throwable: --------------------");
- // throwable.printStackTrace();
-
- String message = throwable.getLocalizedMessage();
- if (message == null)
- {
- Throwable cause = throwable.getCause();
- if (cause != null)
- {
- message = cause.getLocalizedMessage();
- }
- if (message == null)
- {
- message = "";
- }
- }
-
- getLog().log(new Status(IStatus.WARNING, getBundle().getSymbolicName(), 0, message, throwable));
- }
- else
- {
- // System.err.println("Logged throwable: --------------------");
- // throwable.printStackTrace();
-
- getLog().log (new Status (IStatus.WARNING, getBundle().getSymbolicName(), 0, logEntry.toString(), null));
- }
- }
- }
- }
public static void main(String[] args)
{
diff --git a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/BasicDiagnostic.java b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/BasicDiagnostic.java
index 787dedc..50d057b 100644
--- a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/BasicDiagnostic.java
+++ b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/BasicDiagnostic.java
@@ -10,14 +10,9 @@
*/
package org.eclipse.emf.common.util;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.emf.common.EMFPlugin;
-
/**
* A basic implementation of a diagnostic that that also acts as a chain.
@@ -295,219 +290,6 @@ public String toString()
return result.toString();
}
- private static class StatusWrapper implements IStatus
- {
- protected static final IStatus [] EMPTY_CHILDREN = new IStatus [0];
-
- protected Throwable throwable;
- protected Diagnostic diagnostic;
- protected IStatus [] wrappedChildren;
-
- public StatusWrapper(Diagnostic diagnostic)
- {
- this.diagnostic = diagnostic;
- }
-
- public StatusWrapper(DiagnosticException diagnosticException)
- {
- throwable = diagnosticException;
- diagnostic = diagnosticException.getDiagnostic();
- }
-
- public IStatus[] getChildren()
- {
- if (wrappedChildren == null)
- {
- List children = diagnostic.getChildren();
- if (children.isEmpty())
- {
- wrappedChildren = EMPTY_CHILDREN;
- }
- else
- {
- wrappedChildren = new IStatus [children.size()];
- for (int i = 0; i < wrappedChildren.length; ++i)
- {
- wrappedChildren[i] = toIStatus(children.get(i));
- }
- }
- }
- return wrappedChildren;
- }
-
- public int getCode()
- {
- return diagnostic.getCode();
- }
-
- public Throwable getException()
- {
- return throwable != null ? throwable : diagnostic.getException();
- }
-
- public String getMessage()
- {
- return diagnostic.getMessage();
- }
-
- public String getPlugin()
- {
- return diagnostic.getSource();
- }
-
- public int getSeverity()
- {
- return diagnostic.getSeverity();
- }
-
- public boolean isMultiStatus()
- {
- return !diagnostic.getChildren().isEmpty();
- }
-
- public boolean isOK()
- {
- return diagnostic.getSeverity() == OK;
- }
-
- public boolean matches(int severityMask)
- {
- return (diagnostic.getSeverity() & severityMask ) != 0;
- }
-
- @Override
- public String toString()
- {
- return diagnostic.toString();
- }
-
- public static IStatus convert(Diagnostic diagnostic)
- {
- return
- diagnostic instanceof DiagnosticWrapper ?
- ((DiagnosticWrapper)diagnostic).status :
- new StatusWrapper(diagnostic);
- }
-
- public static IStatus create(DiagnosticException diagnosticException)
- {
- return new StatusWrapper(diagnosticException);
- }
- }
-
- /**
- * Returns the diagnostic viewed as an {@link IStatus}.
- */
- public static IStatus toIStatus(Diagnostic diagnostic)
- {
- return StatusWrapper.convert(diagnostic);
- }
-
- /**
- * Returns the diagnostic exception viewed as an {@link IStatus}.
- */
- public static IStatus toIStatus(DiagnosticException diagnosticException)
- {
- return StatusWrapper.create(diagnosticException);
- }
-
- private static class DiagnosticWrapper implements Diagnostic
- {
- protected IStatus status;
- protected List wrappedChildren;
- protected List unmodifiableWrappedChildren;
- protected List
- * @param arguments an array of "command line" options.
- * @return the arguments stripped of those recognized as platform resource options.
- */
- public static String [] handlePlatformResourceOptions(String [] arguments)
- {
- getPlatformResourceMap();
-
- for (int i = 0; i < arguments.length; ++i)
- {
- if (arguments[i].equalsIgnoreCase("-platformResource"))
- {
- int start = i;
- while (++i < arguments.length && !arguments[i].startsWith("-"))
- {
- String rootContainerName = arguments[i];
- if (++i < arguments.length)
- {
- String rootContainerLocation = arguments[i];
-
- // This let's us test whether the string exists as a file.
- // If not, we try as a URI.
- //
- URI uri;
- File file = new File(rootContainerLocation);
- if (file.isDirectory() || !file.exists() && file.getParent() != null && file.getParentFile().isDirectory())
- {
- try
- {
- file = file.getCanonicalFile();
- }
- catch (IOException exception)
- {
- throw new WrappedException(exception);
- }
- uri = URI.createFileURI(file.toString() + "/");
- }
- else
- {
- uri = URI.createURI(rootContainerLocation);
- }
-
- platformResourceMap.put(rootContainerName, uri);
- }
- }
-
- String [] remainingArguments = new String [arguments.length - (i - start)];
- System.arraycopy(arguments, 0, remainingArguments, 0, start);
- System.arraycopy(arguments, i, remainingArguments, start, arguments.length - i);
- return remainingArguments;
- }
- }
-
- return arguments;
- }
-
/**
* Returns a map from {@link EPackage#getNsURI() package namespace URI} (represented as a String)
* to the location of the GenModel containing a GenPackage for the package (represented as a {@link URI URI}).
@@ -263,846 +73,24 @@ public static Map getEPackageNsURIToGenModelLocationMap()
*/
public static Map getEPackageNsURIToGenModelLocationMap(boolean targetPlatform)
{
- if (!targetPlatform || !IS_RESOURCES_BUNDLE_AVAILABLE || !PDEHelper.IS_PDE_BUNDLE_AVAILABLE)
- {
- if (ePackageNsURIToGenModelLocationMap == null)
- {
- ePackageNsURIToGenModelLocationMap = new HashMap();
- }
- return ePackageNsURIToGenModelLocationMap;
- }
- else
- {
- Map nsURIMap = new HashMap();
- try
- {
- PDEHelper.computeModels(null, nsURIMap);
- }
- catch (Exception exception)
- {
- INSTANCE.log(exception);
- }
- return nsURIMap;
- }
- }
-
- /**
- * Computes a map from platform:/resource/<plugin-location>/ {@link URI} to
- * platform:/plugin/<plugin-id>/ URI
- * for each URI in the collection of the form platform:/plugin/<plugin-id>/....
- * This allows each plugin to be {@link org.eclipse.emf.ecore.resource.URIConverter#getURIMap() treated}
- * as if it were a project in the workspace.
- * If the workspace or {@link #getPlatformResourceMap() platform resource map} already contains a project for the plugin location, no such mapping is produced.
- * In addition, when running stand alone and after invoking {@link ExtensionProcessor#process(ClassLoader) extension processing},
- * mappings from platform:/plugin/<plugin-id>/ to the physical location of the plugin's archive or root folder are produced.
- * This allows the URIs to be loaded from their proper physical location.
- * @param uris a collections of {@link URI}s.
- * @return a map from platform resource URI to platform plugin URI.
- */
- public static Map computePlatformResourceToPlatformPluginMap(Collection uris)
- {
- Map result = new HashMap();
- IWorkspaceRoot root = getWorkspaceRoot();
- if (root != null)
+ if (ePackageNsURIToGenModelLocationMap == null)
{
- for (URI uri : uris)
- {
- if (uri.isPlatformPlugin())
- {
- String pluginID = uri.segment(1);
- if (!root.getProject(pluginID).isOpen())
- {
- result.put(URI.createPlatformResourceURI(pluginID + "/", false), URI.createPlatformPluginURI(pluginID + "/", false));
- }
- }
- }
+ ePackageNsURIToGenModelLocationMap = new HashMap();
}
- else if (platformResourceMap != null || ExtensionProcessor.platformPluginToLocationURIMap != null)
- {
- for (URI uri : uris)
- {
- if (uri.isPlatformPlugin())
- {
- String pluginID = uri.segment(1);
- if (platformResourceMap == null || !platformResourceMap.containsKey(pluginID))
- {
- URI platformPluginURI = uri.trimSegments(uri.segmentCount() - 2).appendSegment("");
- URI platformResourceURI = URI.createPlatformResourceURI(platformPluginURI.segment(1), false).appendSegment("");
- result.put(platformResourceURI, platformPluginURI);
-
- if (ExtensionProcessor.platformPluginToLocationURIMap != null)
- {
- URI locationURI = ExtensionProcessor.platformPluginToLocationURIMap.get(platformPluginURI);
- if (locationURI != null)
- {
- result.put(platformPluginURI, locationURI);
- }
- }
- }
- }
- }
- }
- return result;
- }
-
- private static Pattern bundleSymbolNamePattern;
- private static byte [] NO_BYTES = new byte [0];
-
- /**
- * Computes a map from platform:/plugin/<plugin-id>/ {@link URI} to
- * platform:/resource/<plugin-location>/ URI
- * for each plugin project in the workspace or {@link #getPlatformResourceMap() platform resource map}.
- * This allows each plugin from the runtime to be {@link org.eclipse.emf.ecore.resource.URIConverter#getURIMap() redirected}
- * to its active version in the workspace or platform resource map.
- * @return a map from plugin URIs to resource URIs.
- * @see org.eclipse.emf.ecore.resource.URIConverter#getURIMap()
- * @see URI
- */
- public static Map computePlatformPluginToPlatformResourceMap()
- {
- Map result = new HashMap();
- IWorkspaceRoot root = getWorkspaceRoot();
- if (root != null)
- {
- IProject [] projects = root.getProjects();
- if (projects != null)
- {
- String pluginID = null;
-
- class Handler extends DefaultHandler
- {
- public String pluginID;
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
- {
- if ("".equals(uri) && "plugin".equals(localName))
- {
- pluginID = attributes.getValue("id");
- }
- throw new SAXException("Done");
- }
- }
- Handler handler = new Handler();
-
- SAXParserFactory parserFactory= SAXParserFactory.newInstance();
- parserFactory.setNamespaceAware(true);
- SAXParser parser = null;
-
- try
- {
- parser = parserFactory.newSAXParser();
- }
- catch (Exception exception)
- {
- INSTANCE.log(exception);
- }
-
- if (bundleSymbolNamePattern == null)
- {
- bundleSymbolNamePattern = Pattern.compile("^\\s*Bundle-SymbolicName\\s*:\\s*([^\\s;]*)\\s*(;.*)?$", Pattern.MULTILINE);
- }
-
- byte [] bytes = NO_BYTES;
-
- for (int i = 0, size = projects.length; i < size; ++i)
- {
- IProject project = projects[i];
- if (project.isOpen())
- {
- pluginID = null;
- IFile manifest = project.getFile("META-INF/MANIFEST.MF");
- if (manifest.exists())
- {
- InputStream inputStream = null;
- try
- {
- inputStream = manifest.getContents(true);
- int available = inputStream.available();
- if (bytes.length < available)
- {
- bytes = new byte [available];
- }
- inputStream.read(bytes);
- String contents = new String(bytes, "UTF-8");
- Matcher matcher = bundleSymbolNamePattern.matcher(contents);
- if (matcher.find())
- {
- pluginID = matcher.group(1);
- }
- }
- catch (Exception exception)
- {
- INSTANCE.log(exception);
- }
- finally
- {
- if (inputStream != null)
- {
- try
- {
- inputStream.close();
- }
- catch (IOException exception)
- {
- INSTANCE.log(exception);
- }
- }
- }
- }
- else if (parser != null)
- {
- final IFile plugin = project.getFile("plugin.xml");
- if (plugin.exists())
- {
- try
- {
- parser.parse(new InputSource(plugin.getContents(true)), handler);
- }
- catch (Exception exception)
- {
- if (handler.pluginID != null)
- {
- pluginID = handler.pluginID;
- }
- else
- {
- INSTANCE.log(exception);
- }
- }
- }
- }
-
- if (pluginID != null)
- {
- URI platformPluginURI = URI.createPlatformPluginURI(pluginID + "/", false);
- URI platformResourceURI = URI.createPlatformResourceURI(project.getName() + "/", true);
- result.put(platformPluginURI, platformResourceURI);
- }
- }
- }
- }
- }
- else if (platformResourceMap != null)
- {
- for (Map.Entry entry : platformResourceMap.entrySet())
- {
- String pluginID = entry.getKey();
- URI platformPluginURI = URI.createPlatformPluginURI(pluginID, true).appendSegment("");
- URI platformResourceURI = URI.createPlatformResourceURI(pluginID, true).appendSegment("");
- result.put(platformPluginURI, platformResourceURI);
- }
- }
-
- return result;
- }
-
- /**
- * Computes a map so that plugins in the workspace will override those in the target platform or the environment
- * and so that plugins with Ecore and GenModels in the target platform or the environment will look like projects in the workspace.
- * It's implemented like this:
- *
- * return computePlatformURIMap(false);
- *
- * @deprecated since 2.9;
- * use {@link #computePlatformURIMap(boolean) computePlatformURIMap(true)}
- * to get the mappings for the target platform,
- * or use {@link #computePlatformURIMap(boolean) computePlatformURIMap(false)} to get the legacy behavior, i.e., the mappings for the installed environment.
- * It's generally expected that all clients, will migrate to use the target platform.
- * @return computes a map so that plugins in the workspace will override those in the environment
- * and so that plugins with Ecore and GenModels will look like projects in the workspace.
- * @see org.eclipse.emf.ecore.resource.URIConverter#getURIMap()
- * @see #computePlatformPluginToPlatformResourceMap()
- * @see #computePlatformResourceToPlatformPluginMap(Collection)
- */
- @Deprecated
- public static Map computePlatformURIMap()
- {
- return computePlatformURIMap(false);
+ return ePackageNsURIToGenModelLocationMap;
}
- /**
- * Computes a map so that plugins in the workspace will override those in the target platform or the environment
- * and so that plugins with Ecore and GenModels in the target platform or the environment will look like projects in the workspace,
- * i.e., so that each plugin can be accessed via a logical platform:/resource URI
- * equivalent to what would be used if the plugin were actually imported into the workspace.
- * If there is no target platform, i.e., if the PDE is not installed, it defaults back to the environment
- * as if targetPlatform were false.
- *
- * If targetPlatform is false, it's computed from the environment like this:
- *
- * If targetPlatform is true, it does essentially the same logical thing,
- * however, it uses the PDE's target platform to determine the available plugins rather than the environment.
- * The essential difference being that it produces results based on the physical location of all the non-workspace plugins in the PDE's target platform,
- * rather than based on platform:/plugin URIs
- * that always refer to plugins in the running environment.
- * For example, suppose there is a jarred plugin with ID org.example.model in the target platform but not in the workspace
- * that registers a generated model's GenModel at location model/Example.genmodel,
- * the mapping from platform:/resource/org.example.model/ to archive:file:/<location-of-plugin-jar>!/
- * is produced.
- * If instead that same plugin were actually in the workspace,
- * the mapping from platform:/plugin/org.example.model/ to platform/resource/org.example.model/
- * would be produced.
- *
- *
- * The expected usage of this API is to initialize a resource set's URI converter's {@link URIConverter#getURIMap()} as follows:
- *
- * This is particularly important when working with Ecore and GenModel resources because they often have references to models in the environment.
- *
- * @param targetPlatform whether to compute locations for the target platform or for the environment itself; the former is preferred.
- * @return computes a map so that plugins in the workspace will override those in the target platform of the environment
- * and so that plugins in the target platform or environment with Ecore and GenModels will look like projects in the workspace.
- * @see org.eclipse.emf.ecore.resource.URIConverter#getURIMap()
- * @see #computePlatformPluginToPlatformResourceMap()
- * @see #computePlatformResourceToPlatformPluginMap(Collection)
- * @see #getEPackageNsURIToGenModelLocationMap(boolean)
- * @since 2.9
- */
- public static Map computePlatformURIMap(boolean targetPlatform)
- {
- Map result = new HashMap();
- if (!targetPlatform || !IS_RESOURCES_BUNDLE_AVAILABLE || !PDEHelper.IS_PDE_BUNDLE_AVAILABLE)
- {
- result.putAll(computePlatformPluginToPlatformResourceMap());
- result.putAll(computePlatformResourceToPlatformPluginMap(new HashSet(EcorePlugin.getEPackageNsURIToGenModelLocationMap(false).values())));
- }
- else
- {
- try
- {
- PDEHelper.computeModels(result, null);
- }
- catch (Exception e)
- {
- INSTANCE.log(e);
- }
- }
- return result;
- }
-
- /**
- * The platform resource map.
- * @see #getPlatformResourceMap
- */
- private static Map platformResourceMap;
-
/**
* The map from package namespace URIs to the location of the GenModel for that package.
* @see #getPlatformResourceMap
*/
private static Map ePackageNsURIToGenModelLocationMap;
- /**
- * A plugin implementation that handles Ecore plugin registration.
- * @see #startup()
- */
- static public class Implementation extends EclipsePlugin
- {
- /**
- * Creates the singleton instance.
- */
- public Implementation()
- {
- super();
- plugin = this;
- }
-
- /**
- * Starts up this plugin by reading some extensions and populating the relevant registries.
- *
- * The {@link org.eclipse.emf.ecore.EPackage.Registry#INSTANCE global} package registry
- * is populated by plugin registration of the form:
- *
- *
- * @throws Exception if there is a show stopping problem.
- */
- @Override
- public void start(BundleContext context) throws Exception
- {
- super.start(context);
- ExtensionProcessor.internalProcessExtensions();
-
- }
-
- /**
- * @since 2.10
- */
- public static final class Activator extends EMFPlugin.OSGiDelegatingBundleActivator
- {
- @Override
- protected BundleActivator createBundle()
- {
- return new Implementation();
- }
- }
- }
-
- /**
- * A class containing a single utility method for processing extensions.
- * @see ExtensionProcessor#process(ClassLoader)
- * @since 2.9
- */
- public static class ExtensionProcessor
- {
- private static Map platformPluginToLocationURIMap;
-
-
- /**
- * This explicitly triggers processing of all plugin.xml registered extensions.
- * It does nothing if invoked in the context of an Eclipse application as processing of extensions happens implicitly during {@link Implementation#start(BundleContext) bundle activation}.
- * As such this method is useful only in non-Eclipse applications to ensure that plugin.xml registrations are processed just as they are in an Eclipse application.
- * The exploit this mechanism, the classpath of the application must minimally include org.eclipse.equinox.common, org.eclipse.equinox.registry, and org.eclipse.osgi
- *
- * This method creates a registry if {@link RegistryFactory#getRegistry() one does not already exist}.
- * It will first consider all entries on the classpath as provided by {@link System#getProperty(String) System.getProperty("java.class.path")}
- * to determine if there are any folder entries whose parent folder contains a plugin.xml;
- * such entries are common when launching a Java application from Eclipse at development time.
- * In that case, the class loader is not used and only registrations for entries of the classpath are considered.
- * Otherwise, the class loader is used to find all plugin.xml resources and only those entries are considered.
- *
- *
- *
- * @param classLoader the class loader used to locate plugin.xml resources; it may be null in which class the {@link Thread#getContextClassLoader() current thread's context class loader} is used, if necessary.
- * @since 2.9
- */
- public static synchronized void process(ClassLoader classLoader)
- {
- // Ensure processing only happens once and only when not running an Eclipse application.
- //
- if (platformPluginToLocationURIMap == null && !IS_ECLIPSE_RUNNING)
- {
- platformPluginToLocationURIMap = new HashMap();
-
- // If there isn't already a registry...
- //
- IExtensionRegistry registry = RegistryFactory.getRegistry();
- if (registry == null)
- {
- // Create a new registry.
- //
- final IExtensionRegistry newRegistry =
- RegistryFactory.createRegistry
- (new RegistryStrategy(null, null)
- {
- @Override
- public void log(IStatus status)
- {
- INSTANCE.log(status);
- }
-
- @Override
- public String translate(String key, ResourceBundle resources)
- {
- try
- {
- // The org.eclipse.core.resources bundle has keys that aren't translated, so avoid exception propagation.
- //
- return super.translate(key, resources);
- }
- catch (Throwable throwable)
- {
- return key;
- }
- }
- },
- null,
- null);
-
- // Make the new registry the default.
- //
- try
- {
- RegistryFactory.setDefaultRegistryProvider
- (new IRegistryProvider()
- {
- public IExtensionRegistry getRegistry()
- {
- return newRegistry;
- }
- });
- }
- catch (CoreException exception)
- {
- INSTANCE.log(exception);
- }
-
- registry = newRegistry;
- }
-
- // If there is no class loader provided, use the thread's context class loader.
- //
- if (classLoader == null)
- {
- classLoader = Thread.currentThread().getContextClassLoader();
- }
-
- // Process all the URIs for plugin.xml files from the class path or the class loader.
- //
- for (URI pluginXMLURI : getPluginXMLs(classLoader))
- {
- // Construct the URI for the manifest and check that it exists...
- //
- URI pluginLocation = pluginXMLURI.trimSegments(1);
- URI manifestURI = pluginLocation.appendSegments(new String[] { "META-INF", "MANIFEST.MF" });
- if (URIConverter.INSTANCE.exists(manifestURI, null))
- {
- InputStream manifestInputStream = null;
- try
- {
- // Read the manifest.
- //
- manifestInputStream = URIConverter.INSTANCE.createInputStream(manifestURI);
- Manifest manifest = new Manifest(manifestInputStream);
- java.util.jar.Attributes mainAttributes = manifest.getMainAttributes();
-
- // Determine the bundle's name
- //
- String bundleSymbolicName = mainAttributes.getValue("Bundle-SymbolicName");
- if (bundleSymbolicName != null)
- {
- // Split out the OSGi noise.
- //
- bundleSymbolicName = bundleSymbolicName.split(";")[0].trim();
-
- // Compute the map entry from platform:/plugin// to the location URI's root.
- //
- URI logicalPlatformPluginURI = URI.createPlatformPluginURI(bundleSymbolicName, true).appendSegment("");
- URI pluginLocationURI = pluginLocation.isArchive() ? pluginLocation : pluginLocation.appendSegment("");
- platformPluginToLocationURIMap.put(logicalPlatformPluginURI, pluginLocationURI);
-
- // Also create a global URI mapping so that any uses of platform:/plugin/ will map to the physical location of that plugin.
- // This ensures that registered URI mappings that use a relative URI into the plugin will work correctly.
- //
- URIConverter.URI_MAP.put(logicalPlatformPluginURI, pluginLocationURI);
-
- // Find the localization resource bundle, if there is one.
- //
- String bundleLocalization = mainAttributes.getValue("Bundle-Localization");
- ResourceBundle resourceBundle = null;
- if (bundleLocalization != null)
- {
- bundleLocalization += ".properties";
- InputStream bundleLocalizationInputStream = URIConverter.INSTANCE.createInputStream(pluginLocation.appendSegment(bundleLocalization));
- resourceBundle = new PropertyResourceBundle(bundleLocalizationInputStream);
- bundleLocalizationInputStream.close();
- }
-
- // Add the contribution.
- //
- InputStream pluginXMLInputStream = URIConverter.INSTANCE.createInputStream(pluginXMLURI);
- IContributor contributor = ContributorFactorySimple.createContributor(bundleSymbolicName);
- registry.addContribution(pluginXMLInputStream, contributor, false, bundleSymbolicName, resourceBundle, null);
- }
- }
- catch (IOException exception)
- {
- INSTANCE.log(exception);
- }
- }
- }
-
- // Process the extension for the registry.
- //
- ExtensionProcessor.internalProcessExtensions();
- }
- }
-
- /**
- * Read all the registered extensions for Ecore's extension points.
- */
- private static void internalProcessExtensions()
- {
- new RegistryReader
- (RegistryFactory.getRegistry(),
- EcorePlugin.INSTANCE.getSymbolicName(),
- PACKAGE_REGISTRY_IMPLEMENTATION_PPID)
- {
- IConfigurationElement previous;
-
- @Override
- protected boolean readElement(IConfigurationElement element)
- {
- if (element.getName().equals("registry"))
- {
- String implementationClass = element.getAttribute("class");
- if (implementationClass == null)
- {
- logMissingAttribute(element, "class");
- }
- else
- {
- if (defaultRegistryImplementation != null)
- {
- if (previous != null)
- {
- INSTANCE.log("Both '" + previous.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package registry implementation");
- }
- if (defaultRegistryImplementation instanceof EPackageRegistryImpl.Delegator)
- {
- return false;
- }
- }
- try
- {
- defaultRegistryImplementation = (EPackage.Registry)element.createExecutableExtension("class");
- previous = element;
- }
- catch (CoreException exception)
- {
- INSTANCE.log(exception);
- }
- return true;
- }
- }
- return false;
- }
-
- }.readRegistry();
-
- new GeneratedPackageRegistryReader(getEPackageNsURIToGenModelLocationMap(false)).readRegistry();
- new DynamicPackageRegistryReader().readRegistry();
- new FactoryOverrideRegistryReader().readRegistry();
- new ExtensionParserRegistryReader().readRegistry();
- new ProtocolParserRegistryReader().readRegistry();
- new ContentParserRegistryReader().readRegistry();
- new ContentHandlerRegistryReader().readRegistry();
- new URIMappingRegistryReader().readRegistry();
- new ValidationDelegateRegistryReader().readRegistry();
- new SettingDelegateFactoryRegistryReader().readRegistry();
- new InvocationDelegateFactoryRegistryReader().readRegistry();
- new QueryDelegateFactoryRegistryReader().readRegistry();
- new ConversionDelegateFactoryRegistryReader().readRegistry();
- new AnnotationValidatorRegistryReader().readRegistry();
- }
- }
-
- /**
- * Determine all the available plugin.xml resources.
- */
- private static List getPluginXMLs(ClassLoader classLoader)
- {
- List result = new ArrayList();
-
- String classpath = null;
- try
- {
- // Try to get the classpath from the class loader.
- //
- Method method = classLoader.getClass().getMethod("getClassPath");
- if (method != null)
- {
- classpath = (String) method.invoke(classLoader);
- }
- }
- catch (Throwable throwable)
- {
- // Failing that, get it from the system properties.
- //
- classpath = System.getProperty("java.class.path");
- }
-
- // Keep track of whether we find any plugin.xml in the parent of a folder on the classpath, i.e., whether we're in development mode with bin folders on the classpath.
- //
- boolean nonClasspathXML = false;
-
- // If we have a classpath to use...
- //
- if (classpath != null)
- {
- // Split out the entries on the classpath.
- //
- for (String classpathEntry: classpath.split(File.pathSeparator))
- {
- classpathEntry = classpathEntry.trim();
-
- // Determine if the entry is a folder or an archive file.
- //
- File file = new File(classpathEntry);
- if (file.isDirectory())
- {
- // Determine if there is a plugin.xml at the root of the folder.
- //
- File pluginXML = new File(file, "plugin.xml");
- if (!pluginXML.exists())
- {
- // If not, check if there is one in the parent folder.
- //
- File parentFile = file.getParentFile();
- pluginXML = new File(parentFile, "plugin.xml");
- if (pluginXML.isFile())
- {
- // If there is, then we have plugin.xml files that aren't on the classpath.
- //
- nonClasspathXML = true;
- }
- else if (parentFile != null)
- {
- // The parent has a parent, check if there is one in the parent's parent folder.
- //
- pluginXML = new File(parentFile.getParentFile(), "plugin.xml");
- if (pluginXML.isFile())
- {
- // If there is, then we have plugin.xml files that aren't on the classpath.
- //
- nonClasspathXML = true;
- }
- else
- {
- // Otherwise this is bogus too.
- //
- pluginXML = null;
- }
- }
- else
- {
- // Otherwise this is bogus too.
- //
- pluginXML = null;
- }
- }
-
- // If we found a plugin.xml, create a URI for it.
- //
- if (pluginXML != null)
- {
- result.add(URI.createFileURI(pluginXML.getPath()));
- }
- }
- else if (file.isFile())
- {
- // The file must be a jar...
- //
- JarFile jarFile = null;
- try
- {
- // Look for a plugin.xml entry...
- //
- jarFile = new JarFile(classpathEntry);
- ZipEntry entry = jarFile.getEntry("plugin.xml");
- if (entry != null)
- {
- // If we find one, create a URI for it.
- //
- result.add(URI.createURI("archive:" + URI.createFileURI(classpathEntry) + "!/" + entry));
- }
- }
- catch (IOException exception)
- {
- // Ignore.
- }
- finally
- {
- if (jarFile != null)
- {
- try
- {
- jarFile.close();
- }
- catch (IOException exception)
- {
- INSTANCE.log(exception);
- }
- }
- }
- }
- }
- }
-
- // If we didn't find any non-classpath plugin.xml files, use the class loader to enumerate all the plugin.xml files.
- // This is more reliable given the possibility of specialized class loader behavior.
- //
- if (!nonClasspathXML)
- {
- result.clear();
- try
- {
- for (Enumeration resources = classLoader.getResources("plugin.xml"); resources.hasMoreElements(); )
- {
- // Create a URI for each plugin.xml found by the class loader.
- //
- URL url = resources.nextElement();
- result.add(URI.createURI(url.toURI().toString()));
- }
- }
- catch (IOException exception)
- {
- INSTANCE.log(exception);
- }
- catch (URISyntaxException exception)
- {
- INSTANCE.log(exception);
- }
- }
-
- return result;
- }
-
@Override
public String getSymbolicName()
{
- ResourceLocator resourceLocator = getPluginResourceLocator();
- if (resourceLocator instanceof InternalEclipsePlugin)
- {
- return ((InternalEclipsePlugin)resourceLocator).getSymbolicName();
- }
- else
- {
- return "org.eclipse.emf.ecore";
- }
- }
+ return "org.eclipse.emf.ecore";
+ }
/**
* The default registry implementation singleton.
@@ -1118,184 +106,6 @@ public static EPackage.Registry getDefaultRegistryImplementation()
return defaultRegistryImplementation;
}
- /**
- * Returns the Eclipse plugin singleton.
- * @return the plugin singleton.
- */
- public static Implementation getPlugin()
- {
- return plugin;
- }
-
- /**
- * The plugin singleton
- */
- private static Implementation plugin;
-
- /**
- * The workspace root.
- * @see #getWorkspaceRoot
- */
- private static IWorkspaceRoot workspaceRoot;
-
- /**
- * Returns the workspace root, or null, if the runtime environment is stand-alone.
- * @return the workspace root, or null.
- */
- public static IWorkspaceRoot getWorkspaceRoot()
- {
- if (workspaceRoot == null && IS_RESOURCES_BUNDLE_AVAILABLE && System.getProperty("org.eclipse.emf.ecore.plugin.EcorePlugin.doNotLoadResourcesPlugin") == null)
- {
- workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- }
- return workspaceRoot;
- }
-
- private static class PDEHelper
- {
- private static final boolean IS_PDE_BUNDLE_AVAILABLE;
-
- static
- {
- boolean isPDEBundleAvailable = false;
-
- try
- {
- CommonPlugin.loadClass("org.eclipse.pde.core", "org.eclipse.pde.core.plugin.IPluginModelBase");
- isPDEBundleAvailable = true;
- }
- catch (Throwable exception)
- {
- // Ignore.
- }
- IS_PDE_BUNDLE_AVAILABLE = isPDEBundleAvailable && !"true".equals(System.getProperty("org.eclipse.emf.common.CommonPlugin.doNotUsePDE"));
- }
-
- private static void computeModels(Map pluginMap, Map nsURIMap)
- {
- // Cache the workspace for use in the loop.
- //
- IWorkspaceRoot root = getWorkspaceRoot();
-
- Map> targetPlatformExtensionPoints = CommonPlugin.getTargetPlatformExtensionPoints(
- new HashSet(Arrays.asList("org.eclipse.emf.ecore.generated_package", "org.eclipse.emf.ecore.dynamic_package")));
-
- for (Map.Entry> entry : targetPlatformExtensionPoints.entrySet())
- {
- String extensionPoint = entry.getKey();
- boolean isGenerated = "org.eclipse.emf.ecore.generated_package".equals(extensionPoint);
- List extensionPoints = entry.getValue();
- LOOP: for (CommonPlugin.ElementRecord extensionPointRecord : extensionPoints)
- {
- String locationValue = extensionPointRecord.getAttributes().get("location");
- String symbolicName = extensionPointRecord.getAttributes().get("symbolicName");
- if (locationValue != null)
- {
- // The logical URI will be computed when we need it to deal with generated package extension points.
- //
- URI logicalLocation = null;
-
- URI location = URI.createURI(locationValue);
-
- for (CommonPlugin.ElementRecord elementRecord : extensionPointRecord.getChildren())
- {
- Map attributes = elementRecord.getAttributes();
- String uri = attributes.get("uri");
- String modelLocation = attributes.get(isGenerated ? "genModel" : "location");
- if (uri != null && modelLocation != null)
- {
- // We need the logical location of the plugin, so if we haven't computed it already, do so now..
- // This creates folder mappings as a side-effect.
- //
- if (logicalLocation == null)
- {
- // We'll always want to redirect the platform plugin URI to the platform resource URI for this plugin...
- //
- URI platformPluginURI = URI.createPlatformPluginURI(symbolicName, true).appendSegment("");
- if (location.isPlatformResource())
- {
- // If we're computing the plugin map and the physical location is in the workspace, map the platform plugin URI to the platform resource URI of the workspace project.
- //
- if (pluginMap != null)
- {
- pluginMap.put(platformPluginURI, location.appendSegment(""));
- }
-
- // The physical location is also the logical location.
- //
- logicalLocation = location;
- }
- else
- {
- // The logical location will be a platform resource URI as if the external plugin were in the workspace.
- //
- logicalLocation = URI.createPlatformResourceURI(symbolicName, true);
-
- // We'll create a folder mapping for this logical location...
- //
- URI resourceURI = logicalLocation.appendSegment("");
-
- // But only if an actual project doesn't already exist in the workspace.
- //
- boolean exists = root.getProject(symbolicName).isAccessible();
-
- // If we're computing the plugin map...
- //
- if (pluginMap != null)
- {
- // If the physical location is an external folder...
- //
- if (location.isFile())
- {
- // If the physical location is an external folder, map the platform plugin URI to file URI of that external folder.
- //
- pluginMap.put(platformPluginURI, location.appendSegment(""));
- if (!exists)
- {
- // If there is no corresponding project physically present in the workspace, also map the platform resource URI of the plugin to the file URI of the external folder.
- //
- pluginMap.put(resourceURI, location.appendSegment(""));
- }
- }
- else
- {
- // If the physical location is an external jar, map the platform plugin URI to the archive URI of that external jar.
- //
- pluginMap.put(platformPluginURI, location);
- if (!exists)
- {
- // If there is no corresponding project physically present in the workspace, also map the platform resource URI of the plugin to the archive URI of that external jar.
- //
- pluginMap.put(resourceURI, location);
- }
- }
- }
- }
- }
-
- // If we're not computing the nsURI map, we're done with this plugin.
- //
- if (nsURIMap == null)
- {
- continue LOOP;
- }
-
- // Map the nsURI to the logical location URI of the registered GenModel, if we're dealing with a generated package extension point.
- //
- // nsURIMap.put(uri.getValue(), logicalLocation.appendSegments(new Path(genModel.getValue()).segments()));
- //
- if (isGenerated)
- {
- nsURIMap.put(uri, logicalLocation.appendSegments(new Path(modelLocation).segments()));
- }
- }
- }
- }
- }
- }
- }
- }
-
public static final String DYNAMIC_PACKAGE_PPID = "dynamic_package";
public static final String GENERATED_PACKAGE_PPID = "generated_package";
public static final String FACTORY_OVERRIDE_PPID = "factory_override";
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ExtensionParserRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ExtensionParserRegistryReader.java
deleted file mode 100644
index 4bbf25d..0000000
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ExtensionParserRegistryReader.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Copyright (c) 2002-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 v2.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v20.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- */
-package org.eclipse.emf.ecore.plugin;
-
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.RegistryFactory;
-
-import org.eclipse.emf.ecore.resource.Resource;
-
-
-/**
- * A plugin extension reader that populates the
- * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#INSTANCE global} resource factory's
- * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getExtensionToFactoryMap() extension} map.
- * Clients are not expected to use this class directly.
- */
-class ExtensionParserRegistryReader extends RegistryReader
-{
- static final String TAG_PARSER = "parser";
- static final String ATT_TYPE = "type";
- static final String ATT_CLASS = "class";
-
- public ExtensionParserRegistryReader()
- {
- super
- (RegistryFactory.getRegistry(),
- EcorePlugin.INSTANCE.getSymbolicName(),
- EcorePlugin.EXTENSION_PARSER_PPID);
- }
-
- @Override
- protected boolean readElement(IConfigurationElement element, boolean add)
- {
- if (element.getName().equals(TAG_PARSER))
- {
- String type = element.getAttribute(ATT_TYPE);
- if (type == null)
- {
- logMissingAttribute(element, ATT_TYPE);
- }
- else if (element.getAttribute(ATT_CLASS) == null)
- {
- logMissingAttribute(element, ATT_CLASS);
- }
- else if (add)
- {
- Object previous = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS));
- if (previous instanceof ResourceFactoryDescriptor)
- {
- ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
- EcorePlugin.INSTANCE.log
- ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register an extension parser for '" + type + "'");
- }
- return true;
- }
- else
- {
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type);
- return true;
- }
- }
- return false;
- }
-}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/FactoryOverrideRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/FactoryOverrideRegistryReader.java
deleted file mode 100644
index 65c6cf2..0000000
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/FactoryOverrideRegistryReader.java
+++ /dev/null
@@ -1,197 +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 v2.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v20.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- */
-package org.eclipse.emf.ecore.plugin;
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.RegistryFactory;
-
-import org.eclipse.emf.ecore.EPackage;
-
-
-/**
- * A plugin extension reader that populates the
- * {@link org.eclipse.emf.ecore.EPackage.Registry#INSTANCE global} package registry.
- * Clients are not expected to use this class directly.
- */
-class FactoryOverrideRegistryReader extends RegistryReader
-{
- static final String TAG_FACTORY = "factory";
- static final String ATT_URI = "uri";
- static final String ATT_CLASS = "class";
- static final String ATT_PREDECESSOR = "predecessor";
-
- private static final Comparator CONFIGURATION_ELEMENT_COMPARATOR = new Comparator()
- {
- public int compare(IConfigurationElement element1, IConfigurationElement element2)
- {
- String class1 = element1.getAttribute(ATT_CLASS);
- String class2 = element2.getAttribute(ATT_CLASS);
- boolean element1Succeeds = getPredecessors(element1).contains(class2);
- boolean element2Succeeds = getPredecessors(element2).contains(class1);
- if (element1Succeeds == element2Succeeds)
- {
- return 0;
- }
-
- if (element1Succeeds)
- {
- return -1;
- }
-
- return 1;
- }
- };
-
- public FactoryOverrideRegistryReader()
- {
- super
- (RegistryFactory.getRegistry(),
- EcorePlugin.INSTANCE.getSymbolicName(),
- EcorePlugin.FACTORY_OVERRIDE_PPID);
- }
-
- /**
- * Removes all elements with a 'class' attribute that is specified in the 'predecessor' list of any other element.
- * @since 2.16
- */
- @Override
- protected IConfigurationElement[] getFilteredConfigurationElements(IConfigurationElement[] elements)
- {
- List result = new ArrayList();
- Map> uriToElements = new HashMap>();
-
- for (IConfigurationElement element : elements)
- {
- if (element.getName().equals(TAG_FACTORY))
- {
- String packageURI = element.getAttribute(ATT_URI);
- if (packageURI == null || element.getAttribute(ATT_CLASS) == null)
- {
- // Elements without a 'uri' or 'class' attribute will be handled later in readElement().
- result.add(element);
- }
- else
- {
- List list = uriToElements.get(packageURI);
- if (list == null)
- {
- list = new ArrayList();
- uriToElements.put(packageURI, list);
- }
-
- list.add(element);
- }
- }
- }
-
- for (Map.Entry> entry : uriToElements.entrySet())
- {
- List list = entry.getValue();
- Collections.sort(list, CONFIGURATION_ELEMENT_COMPARATOR);
-
- IConfigurationElement firstElement = list.get(0);
- for (int i = 1, size = list.size(); i < size; i++)
- {
- IConfigurationElement element = list.get(i);
- if (CONFIGURATION_ELEMENT_COMPARATOR.compare(firstElement, element) == 0)
- {
- EcorePlugin.INSTANCE.log
- ("Both '" + firstElement.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a factory override for '" + entry.getKey() + "'");
- }
- else
- {
- break;
- }
- }
-
- result.add(firstElement);
- }
-
- return result.toArray(new IConfigurationElement[result.size()]);
- }
-
- @Override
- protected boolean readElement(IConfigurationElement element, boolean add)
- {
- if (element.getName().equals(TAG_FACTORY))
- {
- String packageURI = element.getAttribute(ATT_URI);
- if (packageURI == null)
- {
- logMissingAttribute(element, ATT_URI);
- }
- else if (element.getAttribute(ATT_CLASS) == null)
- {
- logMissingAttribute(element, ATT_CLASS);
- }
- else if (add)
- {
- Object ePackageDescriptor = EPackage.Registry.INSTANCE.get(packageURI);
- if (ePackageDescriptor instanceof EPackage.Descriptor)
- {
- EPackage.Registry.INSTANCE.put(packageURI, new EFactoryDescriptor(element, ATT_CLASS, (EPackage.Descriptor)ePackageDescriptor));
- if (ePackageDescriptor instanceof EFactoryDescriptor)
- {
- EFactoryDescriptor descriptor = (EFactoryDescriptor)ePackageDescriptor;
- EcorePlugin.INSTANCE.log
- ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a factory override for '" + packageURI + "'");
- }
- }
- return true;
- }
- else
- {
- Object ePackageDescriptor = EPackage.Registry.INSTANCE.get(packageURI);
- if (ePackageDescriptor instanceof EFactoryDescriptor)
- {
- EPackage.Registry.INSTANCE.put(packageURI, ((EFactoryDescriptor)ePackageDescriptor).getOverridenDescriptor());
- }
- return true;
- }
- }
-
- return false;
- }
-
- private static Set getPredecessors(IConfigurationElement element)
- {
- String value = element.getAttribute(ATT_PREDECESSOR);
- if (value == null)
- {
- return Collections.emptySet();
- }
-
- Set predecessors = new HashSet();
- StringTokenizer tokenizer = new StringTokenizer(value, " ");
-
- while (tokenizer.hasMoreTokens())
- {
- String predecessor = tokenizer.nextToken().trim();
- if (predecessor.length() != 0)
- {
- predecessors.add(predecessor);
- }
- }
-
- return predecessors;
- }
-}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/GeneratedPackageRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/GeneratedPackageRegistryReader.java
deleted file mode 100644
index 5712b66..0000000
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/GeneratedPackageRegistryReader.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * Copyright (c) 2002-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 v2.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v20.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- */
-package org.eclipse.emf.ecore.plugin;
-
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.RegistryFactory;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EPackage;
-
-/**
- * A plugin extension reader that populates the
- * {@link org.eclipse.emf.ecore.EPackage.Registry#INSTANCE global} package registry.
- * Clients are not expected to use this class directly.
- */
-class GeneratedPackageRegistryReader extends RegistryReader
-{
- static final String TAG_PACKAGE = "package";
- static final String ATT_URI = "uri";
- static final String ATT_CLASS = "class";
- static final String ATT_GEN_MODEL = "genModel";
-
- protected Map ePackageNsURIToGenModelLocationMap;
-
- public GeneratedPackageRegistryReader()
- {
- super
- (RegistryFactory.getRegistry(),
- EcorePlugin.INSTANCE.getSymbolicName(),
- EcorePlugin.GENERATED_PACKAGE_PPID);
- }
-
- public GeneratedPackageRegistryReader(Map ePackageNsURIToGenModelLocationMap)
- {
- this();
- this.ePackageNsURIToGenModelLocationMap = ePackageNsURIToGenModelLocationMap;
- }
-
- @Override
- protected boolean readElement(IConfigurationElement element, boolean add)
- {
- if (element.getName().equals(TAG_PACKAGE))
- {
- String packageURI = element.getAttribute(ATT_URI);
- if (packageURI == null)
- {
- logMissingAttribute(element, ATT_URI);
- }
- else if (element.getAttribute(ATT_CLASS) == null)
- {
- logMissingAttribute(element, ATT_CLASS);
- }
- else if (add)
- {
- Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor(element, ATT_CLASS));
- if (previous instanceof PluginClassDescriptor)
- {
- PluginClassDescriptor descriptor = (PluginClassDescriptor)previous;
- EcorePlugin.INSTANCE.log
- ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package for '" + packageURI + "'");
- }
-
- if (ePackageNsURIToGenModelLocationMap != null)
- {
- String genModel = element.getAttribute(ATT_GEN_MODEL);
- if (genModel != null)
- {
- URI genModelURI = URI.createURI(genModel);
- if (genModelURI.isRelative())
- {
- genModelURI = URI.createPlatformPluginURI(element.getDeclaringExtension().getContributor().getName() + "/" + genModel, true);
- }
- ePackageNsURIToGenModelLocationMap.put(packageURI, genModelURI);
- }
- }
- return true;
- }
- else
- {
- EPackage.Registry.INSTANCE.remove(packageURI);
- if (ePackageNsURIToGenModelLocationMap != null)
- {
- ePackageNsURIToGenModelLocationMap.remove(packageURI);
- }
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/InvocationDelegateFactoryRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/InvocationDelegateFactoryRegistryReader.java
deleted file mode 100644
index 39eb2ba..0000000
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/InvocationDelegateFactoryRegistryReader.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Copyright (c) 2009 Kenn Hussey and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v2.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v20.html
- *
- * Contributors:
- * Kenn Hussey - Initial API and implementation
- */
-package org.eclipse.emf.ecore.plugin;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.RegistryFactory;
-
-import org.eclipse.emf.ecore.EOperation;
-
-
-/**
- * A plugin extension reader that populates the
- * {@link org.eclipse.emf.ecore.EOperation.Internal.InvocationDelegate.Factory.Registry#INSTANCE global} operation delegate factory registry.
- * Clients are not expected to use this class directly.
- */
-class InvocationDelegateFactoryRegistryReader extends RegistryReader
-{
- static class InvocationDelegateFactoryDescriptor extends PluginClassDescriptor implements EOperation.Internal.InvocationDelegate.Factory.Descriptor
- {
- protected EOperation.Internal.InvocationDelegate.Factory factory;
-
- public InvocationDelegateFactoryDescriptor(IConfigurationElement e, String attrName)
- {
- super(e, attrName);
- }
-
- public EOperation.Internal.InvocationDelegate.Factory getFactory()
- {
- if (factory == null)
- {
- factory = (EOperation.Internal.InvocationDelegate.Factory)createInstance();
- }
- return factory;
- }
- }
-
- static final String TAG_FACTORY = "factory";
- static final String ATT_URI = "uri";
- static final String ATT_CLASS = "class";
-
- public InvocationDelegateFactoryRegistryReader()
- {
- super(RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.INVOCATION_DELEGATE_PPID);
- }
-
- @Override
- protected boolean readElement(IConfigurationElement element, boolean add)
- {
- if (element.getName().equals(TAG_FACTORY))
- {
- String uri = element.getAttribute(ATT_URI);
- if (uri == null)
- {
- logMissingAttribute(element, ATT_URI);
- }
- else if (element.getAttribute(ATT_CLASS) == null)
- {
- logMissingAttribute(element, ATT_CLASS);
- }
- else if (add)
- {
- Object previous = EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.put(uri, new InvocationDelegateFactoryDescriptor(element, ATT_CLASS));
- if (previous instanceof InvocationDelegateFactoryDescriptor)
- {
- InvocationDelegateFactoryDescriptor descriptor = (InvocationDelegateFactoryDescriptor)previous;
- EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register an invocation delegate factory for '" + uri + "'");
- }
- return true;
- }
- else
- {
- EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.remove(uri);
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ProtocolParserRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ProtocolParserRegistryReader.java
deleted file mode 100644
index bbf1522..0000000
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ProtocolParserRegistryReader.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Copyright (c) 2002-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 v2.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v20.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- */
-package org.eclipse.emf.ecore.plugin;
-
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.RegistryFactory;
-
-import org.eclipse.emf.ecore.resource.Resource;
-
-
-/**
- * A plugin extension reader that populates the
- * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#INSTANCE global} resource factory's
- * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getProtocolToFactoryMap() protocol} map.
- * Clients are not expected to use this class directly.
- */
-class ProtocolParserRegistryReader extends RegistryReader
-{
- static final String TAG_PARSER = "parser";
- static final String ATT_PROTOCOLNAME = "protocolName";
- static final String ATT_CLASS = "class";
-
- public ProtocolParserRegistryReader()
- {
- super
- (RegistryFactory.getRegistry(),
- EcorePlugin.INSTANCE.getSymbolicName(),
- EcorePlugin.PROTOCOL_PARSER_PPID);
- }
-
- @Override
- protected boolean readElement(IConfigurationElement element, boolean add)
- {
- if (element.getName().equals(TAG_PARSER))
- {
- String protocolName = element.getAttribute(ATT_PROTOCOLNAME);
- if (protocolName == null)
- {
- logMissingAttribute(element, ATT_PROTOCOLNAME);
- }
- else if (element.getAttribute(ATT_CLASS) == null)
- {
- logMissingAttribute(element, ATT_CLASS);
- }
- else if (add)
- {
- Object previous = Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName, new ResourceFactoryDescriptor(element, ATT_CLASS));
- if (previous instanceof ResourceFactoryDescriptor)
- {
- ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
- EcorePlugin.INSTANCE.log
- ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a protocol parser for '" + protocolName + "'");
- }
- return true;
- }
- else
- {
- Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().remove(protocolName);
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/QueryDelegateFactoryRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/QueryDelegateFactoryRegistryReader.java
deleted file mode 100644
index bd5af88..0000000
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/QueryDelegateFactoryRegistryReader.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Copyright (c) 2010 Kenn Hussey and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v2.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v20.html
- *
- * Contributors:
- * Kenn Hussey - Initial API and implementation
- */
-package org.eclipse.emf.ecore.plugin;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.RegistryFactory;
-import org.eclipse.emf.ecore.util.QueryDelegate;
-
-
-/**
- * A plugin extension reader that populates the
- * {@link org.eclipse.emf.ecore.util.QueryDelegate.Factory.Registry#INSTANCE global} query delegate factory registry.
- * Clients are not expected to use this class directly.
- */
-class QueryDelegateFactoryRegistryReader extends RegistryReader
-{
- static class QueryDelegateFactoryDescriptor extends PluginClassDescriptor implements QueryDelegate.Factory.Descriptor
- {
- protected QueryDelegate.Factory factory;
-
- public QueryDelegateFactoryDescriptor(IConfigurationElement e, String attrName)
- {
- super(e, attrName);
- }
-
- public QueryDelegate.Factory getFactory()
- {
- if (factory == null)
- {
- factory = (QueryDelegate.Factory)createInstance();
- }
- return factory;
- }
- }
-
- static final String TAG_FACTORY = "factory";
- static final String ATT_URI = "uri";
- static final String ATT_CLASS = "class";
-
- public QueryDelegateFactoryRegistryReader()
- {
- super(RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.QUERY_DELEGATE_PPID);
- }
-
- @Override
- protected boolean readElement(IConfigurationElement element, boolean add)
- {
- if (element.getName().equals(TAG_FACTORY))
- {
- String uri = element.getAttribute(ATT_URI);
- if (uri == null)
- {
- logMissingAttribute(element, ATT_URI);
- }
- else if (element.getAttribute(ATT_CLASS) == null)
- {
- logMissingAttribute(element, ATT_CLASS);
- }
- else if (add)
- {
- Object previous = QueryDelegate.Factory.Registry.INSTANCE.put(uri, new QueryDelegateFactoryDescriptor(element, ATT_CLASS));
- if (previous instanceof QueryDelegateFactoryDescriptor)
- {
- QueryDelegateFactoryDescriptor descriptor = (QueryDelegateFactoryDescriptor)previous;
- EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a query delegate factory for '" + uri + "'");
- }
- return true;
- }
- else
- {
- QueryDelegate.Factory.Registry.INSTANCE.remove(uri);
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/RegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/RegistryReader.java
deleted file mode 100644
index 6dd9afe..0000000
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/RegistryReader.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/**
- * Copyright (c) 2002-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 v2.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v20.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- */
-package org.eclipse.emf.ecore.plugin;
-
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionDelta;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IRegistryChangeEvent;
-import org.eclipse.core.runtime.IRegistryChangeListener;
-import org.eclipse.emf.common.CommonPlugin;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.common.util.WrappedException;
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.impl.EPackageImpl;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-
-public abstract class RegistryReader
-{
- protected static final String TAG_DESCRIPTION = "description";
-
- protected IExtensionRegistry pluginRegistry;
- String pluginID;
- String extensionPointID;
- String qualifiedExtensionPointID;
-
- public RegistryReader(IExtensionRegistry pluginRegistry, String pluginID, String extensionPointID)
- {
- super();
- this.pluginRegistry = pluginRegistry;
- this.pluginID = pluginID;
- this.extensionPointID = extensionPointID;
- qualifiedExtensionPointID = pluginID + "." + extensionPointID;
- }
-
- /**
- * Implement this method to read element attributes.
- * If this element has child elements, the reader will recursively cycle through them
- * and will call this method, so don't do it here.
- * If you want to support removing entries, override {@link #readElement(IConfigurationElement, boolean)} instead.
- */
- protected boolean readElement(IConfigurationElement element)
- {
- return false;
- }
-
- /**
- * Implement this method to read element attributes for the purpose of adding or removing their registrations.
- * If this element has child elements, the reader will recursively cycle through them
- * and will call this method, so don't do it here.
- */
- protected boolean readElement(IConfigurationElement element, boolean add)
- {
- return add && readElement(element);
- }
-
- /**
- * Reads from the plugin registry and parses it.
- */
- public void readRegistry()
- {
- final IExtensionPoint point = pluginRegistry.getExtensionPoint(pluginID, extensionPointID);
- if (point != null)
- {
- IConfigurationElement[] elements = point.getConfigurationElements();
- elements = getFilteredConfigurationElements(elements);
- for (int i = 0; i < elements.length; i++)
- {
- internalReadElement(elements[i], true);
- }
-
- pluginRegistry.addRegistryChangeListener
- (new IRegistryChangeListener()
- {
- public void registryChanged(IRegistryChangeEvent event)
- {
- IExtensionDelta[] deltas = event.getExtensionDeltas();
- for (int i = 0; i < deltas.length; ++i)
- {
- IExtensionDelta delta = deltas[i];
- if (point.equals(delta.getExtensionPoint()))
- {
- boolean add = delta.getKind() == IExtensionDelta.ADDED;
- IExtension extension = delta.getExtension();
- IConfigurationElement[] configurationElement = extension.getConfigurationElements();
- for (int j = 0; j < configurationElement.length; ++j)
- {
- internalReadElement(configurationElement[j], add);
- }
- }
- }
- }
- });
- }
- }
-
- /**
- * Returns the filtered configuration elements.
- * @since 2.16
- */
- protected IConfigurationElement[] getFilteredConfigurationElements(IConfigurationElement[] elements)
- {
- return elements;
- }
-
- private void internalReadElement(IConfigurationElement element, boolean add)
- {
- boolean recognized = readElement(element, add);
- if (recognized)
- {
- IConfigurationElement[] children = element.getChildren();
- for (int i = 0; i < children.length; ++i)
- {
- internalReadElement(children[i], add);
- }
- }
- else
- {
- logError(element, "Error processing extension: " + element);
- }
- }
-
- /**
- * Logs the error in the desktop log using the provided
- * text and the information in the configuration element.
- */
- protected void logError(IConfigurationElement element, String text)
- {
- IExtension extension = element.getDeclaringExtension();
- System.err.println("Plugin " + extension.getContributor().getName() + ", extension " + extension.getExtensionPointUniqueIdentifier());
- System.err.println(text);
- }
-
- /**
- * Logs a very common registry error when a required attribute is missing.
- */
- protected void logMissingAttribute(IConfigurationElement element, String attributeName)
- {
- logError(element, "The required attribute '" + attributeName + "' not defined");
- }
-
- public static class PluginClassDescriptor
- {
- protected IConfigurationElement element;
- protected String attributeName;
-
- public PluginClassDescriptor(IConfigurationElement element, String attributeName)
- {
- this.element = element;
- this.attributeName = attributeName;
- }
-
- public Object createInstance()
- {
- try
- {
- return element.createExecutableExtension(attributeName);
- }
- catch (CoreException e)
- {
- throw new WrappedException(e);
- }
- }
- }
-
- static class ResourceFactoryDescriptor extends PluginClassDescriptor implements Resource.Factory.Descriptor
- {
- protected Resource.Factory factoryInstance;
-
- public ResourceFactoryDescriptor(IConfigurationElement e, String attrName)
- {
- super(e, attrName);
- }
-
- public Resource.Factory createFactory()
- {
- if (factoryInstance == null)
- {
- factoryInstance = (Resource.Factory)createInstance();
- }
- return factoryInstance;
- }
- }
-
- static class EPackageDescriptor extends PluginClassDescriptor implements EPackage.Descriptor
- {
- static class Dynamic extends EPackageDescriptor
- {
- protected static ResourceSet resourceSet =
- new ResourceSetImpl()
- {
- protected Set uris = new HashSet();
-
- @Override
- protected Resource delegatedGetResource(URI uri, boolean loadOnDemand)
- {
- try
- {
- return uris.add(uri) ? super.delegatedGetResource(uri, loadOnDemand) : null;
- }
- finally
- {
- uris.remove(uri);
- }
- }
- };
-
- public Dynamic(IConfigurationElement element, String attributeName)
- {
- super(element, attributeName);
- }
-
- @Override
- public synchronized EPackage getEPackage()
- {
- try
- {
- String location = element.getAttribute(attributeName);
- if (location != null)
- {
- URI locationURI = URI.createURI(location);
- if (locationURI.isRelative())
- {
- String fragment = locationURI.fragment();
- locationURI = URI.createPlatformPluginURI(element.getDeclaringExtension().getContributor().getName() + "/" + locationURI.trimFragment().toString(), true);
- if (fragment != null)
- {
- locationURI = locationURI.appendFragment(fragment);
- }
- }
-
- EPackage ePackage;
- if (locationURI.hasFragment())
- {
- ePackage = (EPackage)resourceSet.getEObject(locationURI, true);
- }
- else
- {
- ePackage = (EPackage) EcoreUtil.getObjectByType(resourceSet.getResource(locationURI, true).getContents(), EcorePackage.Literals.EPACKAGE);
- }
- if (ePackage instanceof EPackageImpl)
- {
- String schemaLocation = EcoreUtil.getAnnotation(ePackage, EcorePackage.eNS_URI, "schemaLocation");
- if (schemaLocation != null)
- {
- URI schemaLocationURI = URI.createURI(schemaLocation);
- Resource resource = ePackage.eResource();
- URI resourceURI = resource.getURI();
- resourceSet.getURIConverter().getURIMap().put(resourceURI, schemaLocationURI);
- ((EPackageImpl)ePackage).freeze();
- resource.setURI(schemaLocationURI);
-
- }
- }
- return ePackage;
- }
- else
- {
- throw new RuntimeException("No location attribute was specified.");
- }
- }
- catch (Exception e)
- {
- throw new WrappedException(e);
- }
- }
- }
-
- public EPackageDescriptor(IConfigurationElement element, String attributeName)
- {
- super(element, attributeName);
- }
-
- public EPackage getEPackage()
- {
- // First try to see if this class has an eInstance
- //
- try
- {
- Class> javaClass = CommonPlugin.loadClass(element.getDeclaringExtension().getContributor().getName(), element.getAttribute(attributeName));
- Field field = javaClass.getField("eINSTANCE");
- Object result = field.get(null);
- return (EPackage)result;
- }
- catch (ClassNotFoundException e)
- {
- throw new WrappedException(e);
- }
- catch (IllegalAccessException e)
- {
- throw new WrappedException(e);
- }
- catch (NoSuchFieldException e)
- {
- throw new WrappedException(e);
- }
- }
-
- public EFactory getEFactory()
- {
- return null;
- }
- }
-
- static class EFactoryDescriptor extends PluginClassDescriptor implements EPackage.Descriptor
- {
- protected EPackage.Descriptor overridenDescriptor;
-
- public EFactoryDescriptor(IConfigurationElement element, String attributeName, EPackage.Descriptor overridenDescriptor)
- {
- super(element, attributeName);
- this.overridenDescriptor = overridenDescriptor;
- }
-
- public EPackage getEPackage()
- {
- return overridenDescriptor.getEPackage();
- }
-
- public EFactory getEFactory()
- {
- // First try to see if this class has an eInstance
- //
- try
- {
- Class> javaClass = CommonPlugin.loadClass(element.getDeclaringExtension().getContributor().getName(), element.getAttribute(attributeName));
- return (EFactory) javaClass.getDeclaredConstructor().newInstance();
- }
- catch (ClassNotFoundException e)
- {
- throw new WrappedException(e);
- }
- catch (IllegalAccessException e)
- {
- throw new WrappedException(e);
- }
- catch (InstantiationException e)
- {
- throw new WrappedException(e);
- }
- catch (IllegalArgumentException e)
- {
- throw new WrappedException(e);
- }
- catch (InvocationTargetException e)
- {
- throw new WrappedException(e);
- }
- catch (NoSuchMethodException e)
- {
- throw new WrappedException(e);
- }
- catch (SecurityException e)
- {
- throw new WrappedException(e);
- }
- }
-
- public EPackage.Descriptor getOverridenDescriptor()
- {
- return overridenDescriptor;
- }
- }
-}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/SettingDelegateFactoryRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/SettingDelegateFactoryRegistryReader.java
deleted file mode 100644
index 4d47d9c..0000000
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/SettingDelegateFactoryRegistryReader.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Copyright (c) 2009 Kenn Hussey and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v2.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v20.html
- *
- * Contributors:
- * Kenn Hussey - Initial API and implementation
- */
-package org.eclipse.emf.ecore.plugin;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.RegistryFactory;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-
-/**
- * A plugin extension reader that populates the
- * {@link org.eclipse.emf.ecore.EStructuralFeature.Internal.SettingDelegate.Factory.Registry#INSTANCE global} setting delegate factory registry.
- * Clients are not expected to use this class directly.
- */
-class SettingDelegateFactoryRegistryReader extends RegistryReader
-{
- static class SettingDelegateFactoryDescriptor extends PluginClassDescriptor implements EStructuralFeature.Internal.SettingDelegate.Factory.Descriptor
- {
- protected EStructuralFeature.Internal.SettingDelegate.Factory factory;
-
- public SettingDelegateFactoryDescriptor(IConfigurationElement e, String attrName)
- {
- super(e, attrName);
- }
-
- public EStructuralFeature.Internal.SettingDelegate.Factory getFactory()
- {
- if (factory == null)
- {
- factory = (EStructuralFeature.Internal.SettingDelegate.Factory)createInstance();
- }
- return factory;
- }
- }
-
- static final String TAG_FACTORY = "factory";
- static final String ATT_URI = "uri";
- static final String ATT_CLASS = "class";
-
- public SettingDelegateFactoryRegistryReader()
- {
- super(RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.SETTING_DELEGATE_PPID);
- }
-
- @Override
- protected boolean readElement(IConfigurationElement element, boolean add)
- {
- if (element.getName().equals(TAG_FACTORY))
- {
- String uri = element.getAttribute(ATT_URI);
- if (uri == null)
- {
- logMissingAttribute(element, ATT_URI);
- }
- else if (element.getAttribute(ATT_CLASS) == null)
- {
- logMissingAttribute(element, ATT_CLASS);
- }
- else if (add)
- {
- Object previous = EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put(uri, new SettingDelegateFactoryDescriptor(element, ATT_CLASS));
- if (previous instanceof SettingDelegateFactoryDescriptor)
- {
- SettingDelegateFactoryDescriptor descriptor = (SettingDelegateFactoryDescriptor)previous;
- EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a setting delegate factory for '" + uri + "'");
- }
- return true;
- }
- else
- {
- EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.remove(uri);
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/URIMappingRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/URIMappingRegistryReader.java
deleted file mode 100644
index b5c72e1..0000000
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/URIMappingRegistryReader.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Copyright (c) 2002-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 v2.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v20.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- */
-package org.eclipse.emf.ecore.plugin;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.RegistryFactory;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.URIConverter;
-
-
-/**
- * A plugin extension reader that populates the
- * {@link org.eclipse.emf.ecore.resource.URIConverter#URI_MAP global} mapping registry.
- * Clients are not expected to use this class directly.
- */
-class URIMappingRegistryReader extends RegistryReader
-{
- static final String TAG_MAPPING = "mapping";
- static final String ATT_SOURCE = "source";
- static final String ATT_TARGET = "target";
-
- protected Map map = new HashMap();
-
- public URIMappingRegistryReader()
- {
- super
- (RegistryFactory.getRegistry(),
- EcorePlugin.INSTANCE.getSymbolicName(),
- EcorePlugin.URI_MAPPING_PPID);
- }
-
- @Override
- protected boolean readElement(IConfigurationElement element, boolean add)
- {
- if (element.getName().equals(TAG_MAPPING))
- {
- String sourceURIValue = element.getAttribute(ATT_SOURCE);
- if (sourceURIValue == null)
- {
- logMissingAttribute(element, ATT_SOURCE);
- }
- else
- {
- String targetURIValue = element.getAttribute(ATT_TARGET);
- if (targetURIValue == null)
- {
- logMissingAttribute(element, ATT_TARGET);
- }
- else if (add)
- {
- URI sourceURI = URI.createURI(sourceURIValue);
- URI targetURI = URI.createURI(targetURIValue);
- if (targetURI.isRelative() && targetURI.hasRelativePath())
- {
- targetURI =
- targetURI.resolve
- (URI.createPlatformPluginURI(element.getDeclaringExtension().getContributor().getName() + "/", true));
- }
- URIConverter.URI_MAP.put(sourceURI, targetURI);
- IConfigurationElement previous = map.put(sourceURI, element);
- if (previous != null)
- {
- EcorePlugin.INSTANCE.log
- ("Both '" + previous.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a URI mapping for '" + sourceURI + "'");
- }
- return true;
- }
- else
- {
- URI sourceURI = URI.createURI(sourceURIValue);
- URIConverter.URI_MAP.remove(sourceURI);
- map.remove(sourceURI);
- return true;
- }
- }
- }
- return false;
- }
-}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ValidationDelegateRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ValidationDelegateRegistryReader.java
deleted file mode 100644
index fbaec0d..0000000
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ValidationDelegateRegistryReader.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Copyright (c) 2009 Kenn Hussey and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v2.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v20.html
- *
- * Contributors:
- * Kenn Hussey - Initial API and implementation
- */
-package org.eclipse.emf.ecore.plugin;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.RegistryFactory;
-
-import org.eclipse.emf.ecore.EValidator;
-
-
-/**
- * A plugin extension reader that populates the
- * {@link org.eclipse.emf.ecore.EValidator.ValidationDelegate.Registry#INSTANCE global} validation delegate registry.
- * Clients are not expected to use this class directly.
- */
-class ValidationDelegateRegistryReader extends RegistryReader
-{
- static class ValidationDelegateDescriptor extends PluginClassDescriptor implements EValidator.ValidationDelegate.Descriptor
- {
- protected EValidator.ValidationDelegate validationDelegate;
-
- public ValidationDelegateDescriptor(IConfigurationElement e, String attrName)
- {
- super(e, attrName);
- }
-
- public EValidator.ValidationDelegate getValidationDelegate()
- {
- if (validationDelegate == null)
- {
- validationDelegate = (EValidator.ValidationDelegate)createInstance();
- }
- return validationDelegate;
- }
- }
-
- static final String TAG_DELEGATE = "delegate";
- static final String ATT_URI = "uri";
- static final String ATT_CLASS = "class";
-
- public ValidationDelegateRegistryReader()
- {
- super(RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.VALIDATION_DELEGATE_PPID);
- }
-
- @Override
- protected boolean readElement(IConfigurationElement element, boolean add)
- {
- if (element.getName().equals(TAG_DELEGATE))
- {
- String uri = element.getAttribute(ATT_URI);
- if (uri == null)
- {
- logMissingAttribute(element, ATT_URI);
- }
- else if (element.getAttribute(ATT_CLASS) == null)
- {
- logMissingAttribute(element, ATT_CLASS);
- }
- else if (add)
- {
- Object previous = EValidator.ValidationDelegate.Registry.INSTANCE.put(uri, new ValidationDelegateDescriptor(element, ATT_CLASS));
- if (previous instanceof ValidationDelegateDescriptor)
- {
- ValidationDelegateDescriptor descriptor = (ValidationDelegateDescriptor)previous;
- EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a validation delegate for '" + uri + "'");
- }
- return true;
- }
- else
- {
- EValidator.ValidationDelegate.Registry.INSTANCE.remove(uri);
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/ContentHandler.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/ContentHandler.java
index 1ae8337..8b3e007 100644
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/ContentHandler.java
+++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/ContentHandler.java
@@ -15,12 +15,8 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.SortedMap;
-import org.eclipse.core.runtime.content.IContentDescriber;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.impl.ContentHandlerRegistryImpl;
@@ -240,18 +236,9 @@ public byte[] bytes()
byte [] utf8Bytes;
byte [] utf16BEBytes;
byte [] utf16LEBytes;
- try
- {
- utf8Bytes = org.eclipse.core.runtime.content.IContentDescription.BOM_UTF_8;
- utf16BEBytes = org.eclipse.core.runtime.content.IContentDescription.BOM_UTF_16BE;
- utf16LEBytes = org.eclipse.core.runtime.content.IContentDescription.BOM_UTF_16LE;
- }
- catch (Throwable throwable)
- {
- utf8Bytes = new byte [] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF};
- utf16BEBytes = new byte [] {(byte) 0xFE, (byte) 0xFF};
- utf16LEBytes = new byte [] {(byte) 0xFF, (byte) 0xFE};
- }
+ utf8Bytes = new byte [] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF};
+ utf16BEBytes = new byte [] {(byte) 0xFE, (byte) 0xFF};
+ utf16LEBytes = new byte [] {(byte) 0xFF, (byte) 0xFE};
UTF_8_BYTES = utf8Bytes;
UTF_16BE_BYTES = utf16BEBytes;
UTF_16LE_BYTES = utf16LEBytes;
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/URIConverter.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/URIConverter.java
index ebf3f4d..4b18ec2 100644
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/URIConverter.java
+++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/URIConverter.java
@@ -22,9 +22,7 @@
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
-import java.net.SocketTimeoutException;
import java.util.Map;
-import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -264,7 +262,7 @@ class ReadableInputStream extends InputStream implements Readable
public static String getEncoding(String xmlString)
{
- Matcher matcher = XML_HEADER.matcher(xmlString);
+ final Matcher matcher = XML_HEADER.matcher(xmlString);
return
matcher.lookingAt() ?
matcher.group(1) :
@@ -279,11 +277,11 @@ public static String getEncoding(Reader xmlReader)
try
{
xmlReader.mark(100);
- char [] buffer = new char[100];
- int length = xmlReader.read(buffer);
+ final char [] buffer = new char[100];
+ final int length = xmlReader.read(buffer);
if (length > -1)
{
- Matcher matcher = XML_HEADER.matcher(new String(buffer, 0, length));
+ final Matcher matcher = XML_HEADER.matcher(new String(buffer, 0, length));
return
matcher.lookingAt() ?
matcher.group(1) :
@@ -294,7 +292,7 @@ public static String getEncoding(Reader xmlReader)
return null;
}
}
- catch (IOException exception)
+ catch (final IOException exception)
{
return null;
}
@@ -304,7 +302,7 @@ public static String getEncoding(Reader xmlReader)
{
xmlReader.reset();
}
- catch (IOException exception)
+ catch (final IOException exception)
{
// Ignore.
}
@@ -353,12 +351,14 @@ public int read() throws IOException
return buffer.read();
}
- public Reader asReader()
+ @Override
+ public Reader asReader()
{
return reader;
}
- public String getEncoding()
+ @Override
+ public String getEncoding()
{
return encoding;
}
@@ -401,7 +401,7 @@ public int read() throws IOException
index = 0;
reset();
- int readCount = reader.read(characters);
+ final int readCount = reader.read(characters);
if (readCount < 0)
{
return -1;
@@ -505,12 +505,14 @@ public void write(int b) throws IOException
buffer.write(b);
}
- public Writer asWriter()
+ @Override
+ public Writer asWriter()
{
return writer;
}
- public String getEncoding()
+ @Override
+ public String getEncoding()
{
return encoding;
}
@@ -551,7 +553,7 @@ public void write(int b) throws IOException
}
else
{
- int readCount = reader.read(characters);
+ final int readCount = reader.read(characters);
if (readCount > 0)
{
writer.write(characters, 0, readCount);
@@ -565,7 +567,7 @@ public void write(int b) throws IOException
public void flush() throws IOException
{
- int readCount = reader.read(characters);
+ final int readCount = reader.read(characters);
if (readCount > 0)
{
writer.write(characters, 0, readCount);
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/URIHandler.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/URIHandler.java
index aa54c5f..8c2d9c4 100644
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/URIHandler.java
+++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/URIHandler.java
@@ -22,7 +22,6 @@
import org.eclipse.emf.ecore.resource.impl.ArchiveURIHandlerImpl;
import org.eclipse.emf.ecore.resource.impl.EFSURIHandlerImpl;
import org.eclipse.emf.ecore.resource.impl.FileURIHandlerImpl;
-import org.eclipse.emf.ecore.resource.impl.PlatformResourceURIHandlerImpl;
import org.eclipse.emf.ecore.resource.impl.URIHandlerImpl;
/**
@@ -48,7 +47,6 @@ public interface URIHandler
(Arrays.asList
(new URIHandler []
{
- new PlatformResourceURIHandlerImpl(),
new FileURIHandlerImpl(),
new EFSURIHandlerImpl(),
new ArchiveURIHandlerImpl(),
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/BinaryResourceImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/BinaryResourceImpl.java
index 127b74c..0160a73 100644
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/BinaryResourceImpl.java
+++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/BinaryResourceImpl.java
@@ -35,7 +35,6 @@
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.URIConverter;
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/ContentHandlerImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/ContentHandlerImpl.java
index be81a2c..a58c98b 100644
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/ContentHandlerImpl.java
+++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/ContentHandlerImpl.java
@@ -15,22 +15,12 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
-import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.content.IContentDescriber;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.content.ITextContentDescriber;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.ContentHandler;
-import org.eclipse.emf.ecore.resource.URIConverter;
/**
@@ -256,174 +246,4 @@ protected ByteOrderMark getByteOrderMark(URI uri, InputStream inputStream, Map
}
return result;
}
-
- /**
- * An implementation of a describer that delegates to a {@link ContentHandler}.
- */
- public static class Describer implements IContentDescriber, ITextContentDescriber, IExecutableExtension
- {
- /**
- * An property that, in addition to {@link IContentDescription#CHARSET} and {@link IContentDescription#BYTE_ORDER_MARK}, is supported by all EMF's content describers.
- * @since 2.9
- */
- public static final QualifiedName LINE_DELIMITER = new QualifiedName(LINE_DELIMITER_PROPERTY.substring(0, LINE_DELIMITER_PROPERTY.indexOf(':')), LINE_DELIMITER_PROPERTY.substring(LINE_DELIMITER_PROPERTY.indexOf(':') + 1)) ;
-
- /**
- * The content handler delegate.
- */
- protected ContentHandler contentHandler;
-
- /**
- * Returns the qualified names of the supported options.
- * This base implementation supports only {@link #LINE_DELIMITER}, {@link IContentDescription#CHARSET}, and {@link IContentDescription#BYTE_ORDER_MARK}.
- * @return the qualified names of the supported options.
- */
- public QualifiedName[] getSupportedOptions()
- {
- return SUPPORTED_OPTIONS;
- }
-
- /**
- * This base implementation supports only {@link #LINE_DELIMITER}, {@link IContentDescription#CHARSET}, and {@link IContentDescription#BYTE_ORDER_MARK}.
- */
- private static final QualifiedName [] SUPPORTED_OPTIONS =
- {
- IContentDescription.CHARSET,
- IContentDescription.BYTE_ORDER_MARK,
- LINE_DELIMITER
- };
-
- /**
- * Returns the qualified name converted to the corresponding property string.
- * @param qualifiedName the qualified name to convert.
- * @return the qualified name converted to the corresponding property string.
- */
- protected String getProperty(QualifiedName qualifiedName)
- {
- return qualifiedName.toString();
- }
-
- /**
- * Returns the given property's basic EMF value converted to the corresponding Eclipse value.
- * @param qualifiedName the name of the property for which this value applies.
- * @param value the value to convert.
- * @return the given property's basic EMF value converted to the corresponding Eclipse value.
- */
- protected Object getDescriptionValue(QualifiedName qualifiedName, Object value)
- {
- if (value == null)
- {
- return null;
- }
- else if (IContentDescription.BYTE_ORDER_MARK.equals(qualifiedName))
- {
- return ((ContentHandler.ByteOrderMark)value).bytes();
- }
- else
- {
- return value;
- }
- }
-
- public int describe(InputStream inputStream, IContentDescription description) throws IOException
- {
- Map options = new HashMap();
- Map result;
- if (description != null)
- {
- Map requestedPropertyToQualifiedNameMap = new HashMap();
- Set requestedProperties = new HashSet();
- for (QualifiedName qualifiedName : getSupportedOptions())
- {
- if (description.isRequested(qualifiedName))
- {
- String property = getProperty(qualifiedName);
- if (property != null)
- {
- requestedPropertyToQualifiedNameMap.put(property, qualifiedName);
- requestedProperties.add(property);
- }
- }
- }
- options.put(ContentHandler.OPTION_REQUESTED_PROPERTIES, requestedProperties);
- result = contentHandler.contentDescription(URI.createURI("*"), inputStream, options, new HashMap());
- for (Map.Entry property : result.entrySet())
- {
- QualifiedName qualifiedName = requestedPropertyToQualifiedNameMap.get(property.getKey());
- if (qualifiedName != null)
- {
- Object value = getDescriptionValue(qualifiedName, property.getValue());
- if (value != null)
- {
- description.setProperty(qualifiedName, value);
- }
- }
- }
- }
- else
- {
- options.put(ContentHandler.OPTION_REQUESTED_PROPERTIES, Collections.emptySet());
- result = contentHandler.contentDescription(URI.createURI("*"), inputStream, options, new HashMap());
- }
- return ((ContentHandler.Validity)result.get(ContentHandler.VALIDITY_PROPERTY)).ordinal();
- }
-
- public int describe(Reader reader, IContentDescription description) throws IOException
- {
- return describe(new URIConverter.ReadableInputStream(reader), description);
- }
-
- public void setInitializationData(IConfigurationElement configurationElement, String propertyName, Object data) throws CoreException
- {
- Map parameters = getParameters(configurationElement, propertyName, data);
- contentHandler = createContentHandler(parameters);
- }
-
- /**
- * Returns the new content handler for the given parameters that were supplied by the registration of the Eclipse content type.
- * @param parameters the parameter for configuring the content handler.
- * @return the next content handler.
- */
- protected ContentHandler createContentHandler(Map parameters)
- {
- return null;
- }
-
- /**
- * The key in the {@link #getParameters(IConfigurationElement, String, Object) parameters map} representing the content type identifier String.
- */
- protected static final String CONTENT_TYPE_ID = "contentTypeID";
-
- /**
- * The key in the {@link #getParameters(IConfigurationElement, String, Object) parameters map} representing the extensions,
- * which are encoded as a space separate list of suffixes.
- */
- protected static final String EXTENSIONS = "extensions";
-
- /**
- * Returns the map of parameters as fetched from the given configuration element's information.
- * This implementation populates the {@link #CONTENT_TYPE_ID content type identifier} and the {@link #EXTENSIONS extensions}.
- * @param configurationElement the configuration element of the content type.
- * @param propertyName the property for this particular for this instance.
- * @param data the data associated with this instance.
- * @return the map of parameters as fetched from the given configuration element's information.
- */
- protected Map getParameters(IConfigurationElement configurationElement, String propertyName, Object data)
- {
- Map parameters = new HashMap();
- if (data != null)
- {
- @SuppressWarnings("unchecked")
- Map dataMap = (Map)data;
- parameters.putAll(dataMap);
- parameters.put(CONTENT_TYPE_ID, configurationElement.getAttribute("id"));
- String fileExtensions = configurationElement.getAttribute("file-extensions");
- if (fileExtensions != null)
- {
- parameters.put(EXTENSIONS, fileExtensions.replace(',', ' '));
- }
- }
- return parameters;
- }
- }
}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/EFSURIHandlerImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/EFSURIHandlerImpl.java
index 0fa3034..ddcd3ec 100644
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/EFSURIHandlerImpl.java
+++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/EFSURIHandlerImpl.java
@@ -22,7 +22,6 @@
import java.util.Map;
import java.util.Set;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.CommonPlugin;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
@@ -70,12 +69,12 @@ public class EFSURIHandlerImpl extends URIHandlerImpl
efsGetStoreMethod = efsClass.getMethod("getStore", java.net.URI.class);
efsGetFileSystemMethod = efsClass.getMethod("getFileSystem", String.class);
Class > fileStoreClass = efsGetStoreMethod.getReturnType();
- fileStoreOpenInputStreamMethod = fileStoreClass.getMethod("openInputStream", Integer.TYPE, IProgressMonitor.class);
- fileStoreOpenOutputStreamMethod = fileStoreClass.getMethod("openOutputStream", Integer.TYPE, IProgressMonitor.class);
- fileStoreDeleteMethod = fileStoreClass.getMethod("delete", Integer.TYPE, IProgressMonitor.class);
+ fileStoreOpenInputStreamMethod = fileStoreClass.getMethod("openInputStream", Integer.TYPE, null);
+ fileStoreOpenOutputStreamMethod = fileStoreClass.getMethod("openOutputStream", Integer.TYPE, null);
+ fileStoreDeleteMethod = fileStoreClass.getMethod("delete", Integer.TYPE, null);
fileStoreFetchInfoMethod = fileStoreClass.getMethod("fetchInfo");
Class > fileInfoClass = fileStoreFetchInfoMethod.getReturnType();
- fileStorePutInfoMethod = fileStoreClass.getMethod("putInfo", fileInfoClass, Integer.TYPE, IProgressMonitor.class);
+ fileStorePutInfoMethod = fileStoreClass.getMethod("putInfo", fileInfoClass, Integer.TYPE, null);
fileInfoExistsMethod = fileInfoClass.getMethod("exists");
fileInfoIsDirectoryMethod = fileInfoClass.getMethod("isDirectory");
fileInfoGetLengthMethod = fileInfoClass.getMethod("getLength");
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/ExtensibleURIConverterImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/ExtensibleURIConverterImpl.java
index c42fe2c..f5a2632 100644
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/ExtensibleURIConverterImpl.java
+++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/ExtensibleURIConverterImpl.java
@@ -408,23 +408,13 @@ public URI normalize(URI uri)
String scheme = result.scheme();
if (scheme == null)
{
- if (PlatformResourceURIHandlerImpl.getWorkspaceRoot() != null)
+ if (result.hasAbsolutePath())
{
- if (result.hasAbsolutePath())
- {
- result = URI.createPlatformResourceURI(result.toString(), false);
- }
+ result = URI.createURI("file:" + result);
}
else
{
- if (result.hasAbsolutePath())
- {
- result = URI.createURI("file:" + result);
- }
- else
- {
- result = URI.createFileURI(new File(result.toString()).getAbsolutePath());
- }
+ result = URI.createFileURI(new File(result.toString()).getAbsolutePath());
}
}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/PlatformContentHandlerImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/PlatformContentHandlerImpl.java
deleted file mode 100644
index e683ffe..0000000
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/PlatformContentHandlerImpl.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/**
- * Copyright (c) 2007-2012 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v2.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v20.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- */
-package org.eclipse.emf.ecore.resource.impl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.ContentHandler;
-
-public class PlatformContentHandlerImpl extends ContentHandlerImpl
-{
- private static final Map PROPERTY_CACHE = new HashMap();
-
- /**
- * Returns the property name converted to a qualified name.
- * @param property the property to convert.
- * @return the property name converted to a qualified name.
- */
- protected QualifiedName getQualifiedName(String property)
- {
- QualifiedName result = PROPERTY_CACHE.get(property);
- if (result == null)
- {
- int index = property.lastIndexOf(":");
- if (index == -1)
- {
- result = new QualifiedName(null, property);
- }
- else
- {
- result = new QualifiedName(property.substring(0, index), property.substring(index + 1));
- }
- PROPERTY_CACHE.put(property, result);
- }
- return result;
- }
-
- /**
- * Returns the given property's Eclipse value converted to EMF's corresponding basic value.
- * @param qualifiedName the name of the property for which this value applies.
- * @param value the value to convert.
- * @return the given property's Eclipse value converted to EMF's corresponding basic value.
- */
- protected Object getDescriptionValue(QualifiedName qualifiedName, Object value)
- {
- if (value == null)
- {
- return null;
- }
- else if (IContentDescription.BYTE_ORDER_MARK.equals(qualifiedName))
- {
- for (ByteOrderMark byteOrderMarker : ContentHandler.ByteOrderMark.values())
- {
- if (value == byteOrderMarker.bytes())
- {
- return byteOrderMarker;
- }
- }
- return null;
- }
- else
- {
- return value;
- }
- }
-
- /**
- * This implementation delegates to the platform's content description support,
- */
- @Override
- public Map contentDescription(URI uri, InputStream inputStream, Map, ?> options, Map context) throws IOException
- {
- IContentDescription contentDescription;
- try
- {
- if (uri.isPlatformResource() && PlatformResourceURIHandlerImpl.getWorkspaceRoot() != null)
- {
- contentDescription = PlatformResourceURIHandlerImpl.WorkbenchHelper.getContentDescription(uri.toPlatformString(true), options);
- }
- else
- {
- contentDescription = Platform.getContentTypeManager().getDescriptionFor(inputStream, uri.lastSegment(), IContentDescription.ALL);
- }
- }
- catch (Throwable exception)
- {
- return super.contentDescription(uri, inputStream, options, context);
- }
-
- if (contentDescription == null)
- {
- return INVALID_CONTENT_DESCRIPTION;
- }
- else
- {
- Map result = createContentDescription(ContentHandler.Validity.VALID);
- result.put(ContentHandler.CONTENT_TYPE_PROPERTY, contentDescription.getContentType().getId());
- Set requestedProperties = getRequestedProperties(options);
- if (requestedProperties == null)
- {
- Object bom = getDescriptionValue(IContentDescription.BYTE_ORDER_MARK, contentDescription.getProperty(IContentDescription.BYTE_ORDER_MARK));
- if (bom != null)
- {
- result.put(ContentHandler.BYTE_ORDER_MARK_PROPERTY, bom);
- }
- Object charset = getDescriptionValue(IContentDescription.CHARSET, contentDescription.getProperty(IContentDescription.CHARSET));
- if (charset != null)
- {
- result.put(ContentHandler.CHARSET_PROPERTY, charset);
- }
- Object lineDelimiter = getDescriptionValue(Describer.LINE_DELIMITER, contentDescription.getProperty(Describer.LINE_DELIMITER));
- if (lineDelimiter == null)
- {
- lineDelimiter = getLineDelimiter(uri, inputStream, options, context);
- }
- if (lineDelimiter != null)
- {
- result.put(ContentHandler.LINE_DELIMITER_PROPERTY, lineDelimiter);
- }
- }
- else
- {
- for (String property : requestedProperties)
- {
- if (ContentHandler.LINE_DELIMITER_PROPERTY.equals(property))
- {
- Object lineDelimiter = getDescriptionValue(Describer.LINE_DELIMITER, contentDescription.getProperty(Describer.LINE_DELIMITER));
- if (lineDelimiter == null)
- {
- lineDelimiter = getLineDelimiter(uri, inputStream, options, context);
- }
- if (lineDelimiter != null)
- {
- result.put(property, lineDelimiter);
- }
- }
- else
- {
- QualifiedName qualifiedName = getQualifiedName(property);
- if (qualifiedName != null)
- {
- Object value = getDescriptionValue(qualifiedName, contentDescription.getProperty(qualifiedName));
- if (value != null)
- {
- result.put(property, value);
- }
- }
- }
- }
- }
- return result;
- }
- }
-
- /**
- * This implementation only gets called when platform's content describer throws an exception, i.e., when the resource doesn't exist.
- * For {@link URI#isPlatformResource() platform resource URIs}, it determines the character set from the workspace.
- * @since 2.9
- */
- @Override
- protected String getCharset(URI uri, InputStream inputStream, Map, ?> options, Map context) throws IOException
- {
- if (uri.isPlatformResource() && PlatformResourceURIHandlerImpl.getWorkspaceRoot() != null)
- {
- return PlatformResourceURIHandlerImpl.WorkbenchHelper.getCharset(uri.toPlatformString(true), options);
- }
- else
- {
- return super.getCharset(uri, inputStream, options, context);
- }
- }
-
- /**
- * This implementation only gets called when platform's content describer throws an exception, i.e., when the resource doesn't exist.
- * For {@link URI#isPlatformResource() platform resource URIs}, it determines the line delimiter from the project/workspace preferences.
- * @since 2.9
- */
- @Override
- protected String getLineDelimiter(URI uri, InputStream inputStream, Map, ?> options, Map context) throws IOException
- {
- if (uri.isPlatformResource() && PlatformResourceURIHandlerImpl.getWorkspaceRoot() != null)
- {
- return PlatformResourceURIHandlerImpl.WorkbenchHelper.getLineDelimiter(uri.toPlatformString(true), options);
- }
- else
- {
- return super.getCharset(uri, inputStream, options, context);
- }
- }
-}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/PlatformResourceURIHandlerImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/PlatformResourceURIHandlerImpl.java
deleted file mode 100644
index 2881a51..0000000
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/PlatformResourceURIHandlerImpl.java
+++ /dev/null
@@ -1,661 +0,0 @@
-/**
- * Copyright (c) 2007-2012 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v2.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v20.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- */
-package org.eclipse.emf.ecore.resource.impl;
-
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.resources.ResourceAttributes;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.emf.common.EMFPlugin;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.plugin.EcorePlugin;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.URIConverter;
-import org.osgi.framework.Bundle;
-
-
-public class PlatformResourceURIHandlerImpl extends URIHandlerImpl
-{
- /**
- * An output stream that transfers its contents to an {@link IFile} upon closing.
- */
- public static class PlatformResourceOutputStream extends ByteArrayOutputStream
- {
- protected IFile file;
- protected boolean force;
- protected boolean keepHistory;
- protected IProgressMonitor progressMonitor;
- protected boolean previouslyFlushed;
-
- public PlatformResourceOutputStream(IFile file, boolean force, boolean keepHistory, IProgressMonitor progressMonitor)
- {
- this.file = file;
- this.force = force;
- this.keepHistory = keepHistory;
- this.progressMonitor = progressMonitor;
- }
-
- protected void createContainer(IContainer container) throws IOException
- {
- if (!container.exists())
- {
- if (container.getType() == IResource.FOLDER)
- {
- createContainer(container.getParent());
- try
- {
- ((IFolder)container).create(force, keepHistory, progressMonitor);
- }
- catch (CoreException exception)
- {
- throw new ResourceImpl.IOWrappedException(exception);
- }
- }
- }
- }
-
- @Override
- public void close() throws IOException
- {
- flush();
- super.close();
- }
-
- @Override
- public void flush() throws IOException
- {
- super.flush();
-
- if (previouslyFlushed)
- {
- if (count == 0)
- {
- return;
- }
- }
- else
- {
- createContainer(file.getParent());
- }
-
- byte[] contents = toByteArray();
- InputStream inputStream = new ByteArrayInputStream(contents, 0, contents.length);
-
- try
- {
- if (previouslyFlushed)
- {
- file.appendContents(inputStream, force, false, progressMonitor);
- }
- else
- {
- if (!file.isSynchronized(IResource.DEPTH_ONE))
- {
- file.refreshLocal(IResource.DEPTH_ONE, progressMonitor);
- }
-
- if (!file.exists())
- {
- file.create(inputStream, false, null);
- previouslyFlushed = true;
- }
- else
- {
- file.setContents(inputStream, force, keepHistory, progressMonitor);
- previouslyFlushed = true;
- }
- }
- reset();
- }
- catch (CoreException exception)
- {
- throw new Resource.IOWrappedException(exception);
- }
- }
- }
-
- /**
- * Isolated Eclipse workbench utilities.
- */
- public static class WorkbenchHelper
- {
- /**
- * Creates an output stream for the given {@link IFile} path.
- *
- * This implementation uses a {@link PlatformResourceURIHandlerImpl.PlatformResourceOutputStream}.
- *
- * @return an open output stream.
- * @exception IOException if there is a problem obtaining an open output stream.
- * @see IWorkspaceRoot#getFile(org.eclipse.core.runtime.IPath)
- * @see PlatformResourceURIHandlerImpl.PlatformResourceOutputStream
- * @see IFile#setContents(InputStream, boolean, boolean, IProgressMonitor)
- */
- public static OutputStream createPlatformResourceOutputStream(String platformResourcePath, Map, ?> options) throws IOException
- {
- IFile file = getWorkspaceRoot().getFile(new Path(platformResourcePath));
- @SuppressWarnings("unchecked")
- final Map response = options == null ? null : (Map)options.get(URIConverter.OPTION_RESPONSE);
- return
- new PlatformResourceOutputStream(file, false, true, null)
- {
- @Override
- public void close() throws IOException
- {
- try
- {
- super.close();
- }
- finally
- {
- if (response != null)
- {
- response.put(URIConverter.RESPONSE_TIME_STAMP_PROPERTY, file.getLocalTimeStamp());
- }
- }
- }
- };
- }
-
- /**
- * Creates an input stream for the given {@link IFile} path.
- *
- * This implementation uses {@link IFile#getContents() IFile.getContents}.
- *
- * @return an open input stream.
- * @see IWorkspaceRoot#getFile(org.eclipse.core.runtime.IPath)
- * @see IFile#getContents()
- * @exception IOException if there is a problem obtaining an open input stream.
- */
- public static InputStream createPlatformResourceInputStream(String platformResourcePath, Map, ?> options) throws IOException
- {
- IFile file = getWorkspaceRoot().getFile(new Path(platformResourcePath));
- try
- {
- if (!file.isSynchronized(IResource.DEPTH_ONE))
- {
- file.refreshLocal(IResource.DEPTH_ONE, null);
- }
- InputStream result = file.getContents();
- if (options != null)
- {
- @SuppressWarnings("unchecked")
- Map response = (Map)options.get(URIConverter.OPTION_RESPONSE);
- if (response != null)
- {
- response.put(URIConverter.RESPONSE_TIME_STAMP_PROPERTY, file.getLocalTimeStamp());
- }
- }
- return result;
- }
- catch (CoreException exception)
- {
- throw new Resource.IOWrappedException(exception);
- }
- }
-
- public static void delete(String platformResourcePath, Map, ?> options) throws IOException
- {
- IFile file = getWorkspaceRoot().getFile(new Path(platformResourcePath));
- try
- {
- file.delete(true, null);
- }
- catch (CoreException exception)
- {
- throw new Resource.IOWrappedException(exception);
- }
- }
-
- public static boolean exists(String platformResourcePath, Map, ?> options)
- {
- IResource resource = getWorkspaceRoot().findMember(new Path(platformResourcePath));
- return resource != null && resource.getResourceAttributes() != null;
- }
-
- public static Map attributes(String platformResourcePath, Map, ?> options)
- {
- IResource resource = getWorkspaceRoot().findMember(new Path(platformResourcePath));
- Map result = new HashMap();
- if (resource != null)
- {
- @SuppressWarnings("unchecked")
- Set requestedAttributes = options == null ? null : (Set)options.get(URIConverter.OPTION_REQUESTED_ATTRIBUTES);
-
- if (requestedAttributes == null || requestedAttributes.contains(URIConverter.ATTRIBUTE_TIME_STAMP))
- {
- result.put(URIConverter.ATTRIBUTE_TIME_STAMP, resource.getLocalTimeStamp());
- }
- ResourceAttributes resourceAttributes = null;
- if (requestedAttributes == null || requestedAttributes.contains(URIConverter.ATTRIBUTE_READ_ONLY))
- {
- resourceAttributes = resource.getResourceAttributes();
- if (resourceAttributes == null)
- {
- return result;
- }
- result.put(URIConverter.ATTRIBUTE_READ_ONLY, resourceAttributes.isReadOnly());
- }
- if (requestedAttributes == null || requestedAttributes.contains(URIConverter.ATTRIBUTE_ARCHIVE))
- {
- if (resourceAttributes == null)
- {
- resourceAttributes = resource.getResourceAttributes();
- if (resourceAttributes == null)
- {
- return result;
- }
- }
- result.put(URIConverter.ATTRIBUTE_ARCHIVE, resourceAttributes.isArchive());
- }
- if (requestedAttributes == null || requestedAttributes.contains(URIConverter.ATTRIBUTE_EXECUTABLE))
- {
- if (resourceAttributes == null)
- {
- resourceAttributes = resource.getResourceAttributes();
- if (resourceAttributes == null)
- {
- return result;
- }
- }
- result.put(URIConverter.ATTRIBUTE_EXECUTABLE, resourceAttributes.isExecutable());
- }
- if (requestedAttributes == null || requestedAttributes.contains(URIConverter.ATTRIBUTE_HIDDEN))
- {
- if (resourceAttributes == null)
- {
- resourceAttributes = resource.getResourceAttributes();
- if (resourceAttributes == null)
- {
- return result;
- }
- }
- result.put(URIConverter.ATTRIBUTE_HIDDEN, resourceAttributes.isHidden());
- }
- if (requestedAttributes == null || requestedAttributes.contains(URIConverter.ATTRIBUTE_DIRECTORY))
- {
- if (resourceAttributes == null)
- {
- resourceAttributes = resource.getResourceAttributes();
- if (resourceAttributes == null)
- {
- return result;
- }
- }
- result.put(URIConverter.ATTRIBUTE_DIRECTORY, resource instanceof IContainer);
- }
- }
- return result;
- }
-
- public static void updateAttributes(String platformResourcePath, Map attributes, Map, ?> options) throws IOException
- {
- IResource resource = getWorkspaceRoot().findMember(new Path(platformResourcePath));
- if (resource == null)
- {
- throw new FileNotFoundException("The resource " + platformResourcePath + " does not exist");
- }
- else
- {
- try
- {
- Long timeStamp = (Long)attributes.get(URIConverter.ATTRIBUTE_TIME_STAMP);
- if (timeStamp != null)
- {
- resource.setLocalTimeStamp(timeStamp);
- }
-
- ResourceAttributes resourceAttributes = null;
- Boolean readOnly = (Boolean)attributes.get(URIConverter.ATTRIBUTE_READ_ONLY);
- if (readOnly != null)
- {
- resourceAttributes = resource.getResourceAttributes();
- if (resourceAttributes == null)
- {
- return;
- }
- resourceAttributes.setReadOnly(readOnly);
- }
- Boolean archive = (Boolean)attributes.get(URIConverter.ATTRIBUTE_ARCHIVE);
- if (archive != null)
- {
- if (resourceAttributes == null)
- {
- resourceAttributes = resource.getResourceAttributes();
- if (resourceAttributes == null)
- {
- return;
- }
- }
- resourceAttributes.setArchive(archive);
- }
- Boolean executable = (Boolean)attributes.get(URIConverter.ATTRIBUTE_EXECUTABLE);
- if (executable != null)
- {
- if (resourceAttributes == null)
- {
- resourceAttributes = resource.getResourceAttributes();
- if (resourceAttributes == null)
- {
- return;
- }
- }
- resourceAttributes.setExecutable(executable);
- }
- Boolean hidden = (Boolean)attributes.get(URIConverter.ATTRIBUTE_HIDDEN);
- if (hidden != null)
- {
- if (resourceAttributes == null)
- {
- resourceAttributes = resource.getResourceAttributes();
- if (resourceAttributes == null)
- {
- return;
- }
- }
- resourceAttributes.setHidden(hidden);
- }
-
- if (resourceAttributes != null)
- {
- resource.setResourceAttributes(resourceAttributes);
- }
- }
- catch (CoreException exception)
- {
- throw new Resource.IOWrappedException(exception);
- }
- }
- }
-
- public static IContentDescription getContentDescription(String platformResourcePath, Map, ?> options) throws IOException
- {
- IFile file = getWorkspaceRoot().getFile(new Path(platformResourcePath));
- try
- {
- return file.getContentDescription();
- }
- catch (CoreException exception)
- {
- throw new Resource.IOWrappedException(exception);
- }
- }
-
- /**
- * Returns the {@link IFile#getCharset() character set} for the file at the specified location.
- * @since 2.9
- */
- public static String getCharset(String platformResourcePath, Map, ?> options) throws IOException
- {
- IFile file = getWorkspaceRoot().getFile(new Path(platformResourcePath));
- try
- {
- return file.getCharset();
- }
- catch (CoreException exception)
- {
- throw new Resource.IOWrappedException(exception);
- }
- }
-
- @SuppressWarnings("deprecation")
- private static final InstanceScope INSTANCE_SCOPE = new InstanceScope();
-
- private static final String SYSTEM_PROPERTY_LINE_SEPARATOR = System.getProperty(Platform.PREF_LINE_SEPARATOR);
-
- /**
- * Returns the project or workspace line delimiter preference for a new workspace file at the specified location.
- * @since 2.9
- */
- public static String getLineDelimiter(String platformResourcePath, Map, ?> options)
- {
- IFile file = getWorkspaceRoot().getFile(new Path(platformResourcePath));
- IProject project = file.getProject();
- return
- Platform.getPreferencesService().getString
- (Platform.PI_RUNTIME,
- Platform.PREF_LINE_SEPARATOR,
- SYSTEM_PROPERTY_LINE_SEPARATOR,
- new IScopeContext[] { new ProjectScope(project), INSTANCE_SCOPE });
- }
- }
-
- /**
- * The cached Eclipse workspace root.
- * @deprecated use {@link #getWorkspaceRoot()} instead.
- */
- protected static IWorkspaceRoot workspaceRoot = getWorkspaceRoot();
-
- /**
- * Whether {@link #cachedWorkspaceRoot} is initialized.
- */
- private static boolean cachedWorkspaceRootInitialized;
-
- /**
- * The cached Eclipse workspace root returned by {@link #getWorkspaceRoot()}.
- */
- private static IWorkspaceRoot cachedWorkspaceRoot;
-
- /**
- * Returns the Eclipse workspace root,
- * except in the case that the resource bundle is not available or the platform has not yet initialized in instance location,
- * in which case it returns {@code null}.
- * @return the workspace root.
- * @since 2.21
- */
- protected static IWorkspaceRoot getWorkspaceRoot()
- {
- if (!cachedWorkspaceRootInitialized)
- {
- try
- {
- // If the resource bundle isn't available, we will always return null for this method.
- if (EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE)
- {
- // This guards for the case when EMF is used by some component before the user chooses the workspace location.
- Bundle resourcesBundle = Platform.getBundle("org.eclipse.core.resources");
- if (resourcesBundle == null || (resourcesBundle.getState() & Bundle.ACTIVE) == 0)
- {
- return null;
- }
- else
- {
- cachedWorkspaceRoot = workspaceRoot = EcorePlugin.getWorkspaceRoot();
- }
- }
- cachedWorkspaceRootInitialized = true;
- }
- catch (Exception exception)
- {
- // Ignore.
- }
- }
- return cachedWorkspaceRoot;
- }
-
- /**
- * Creates an instance.
- */
- public PlatformResourceURIHandlerImpl()
- {
- super();
- }
-
- @Override
- public boolean canHandle(URI uri)
- {
- return uri.isPlatformResource();
- }
-
- /**
- * Creates an output stream for the platform resource path and returns it.
- *
- * This implementation does one of two things, depending on the runtime environment.
- * If there is an Eclipse workspace, it delegates to
- * {@link WorkbenchHelper#createPlatformResourceOutputStream WorkbenchHelper.createPlatformResourceOutputStream},
- * which gives the expected Eclipse behaviour.
- * Otherwise, the {@link EcorePlugin#resolvePlatformResourcePath resolved} URI
- * is delegated to {@link #createOutputStream createOutputStream}
- * for recursive processing.
- * @return an open output stream.
- * @exception IOException if there is a problem obtaining an open output stream or a valid interpretation of the path.
- * @see EcorePlugin#resolvePlatformResourcePath(String)
- */
- @Override
- public OutputStream createOutputStream(URI uri, Map, ?> options) throws IOException
- {
- String platformResourcePath = uri.toPlatformString(true);
- if (getWorkspaceRoot() != null)
- {
- return WorkbenchHelper.createPlatformResourceOutputStream(platformResourcePath, options);
- }
- else
- {
- URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath);
- if (resolvedLocation != null)
- {
- return ((URIConverter)options.get(URIConverter.OPTION_URI_CONVERTER)).createOutputStream(resolvedLocation, options);
- }
-
- throw new IOException("The path '" + platformResourcePath + "' is unmapped");
- }
- }
-
- /**
- * Creates an input stream for the platform resource path and returns it.
- *
- * This implementation does one of two things, depending on the runtime environment.
- * If there is an Eclipse workspace, it delegates to
- * {@link WorkbenchHelper#createPlatformResourceInputStream WorkbenchHelper.createPlatformResourceInputStream},
- * which gives the expected Eclipse behaviour.
- * Otherwise, the {@link EcorePlugin#resolvePlatformResourcePath resolved} URI
- * is delegated to {@link #createInputStream createInputStream}
- * for recursive processing.
- * @return an open input stream.
- * @exception IOException if there is a problem obtaining an open input stream or a valid interpretation of the path.
- * @see EcorePlugin#resolvePlatformResourcePath(String)
- */
- @Override
- public InputStream createInputStream(URI uri, Map, ?> options) throws IOException
- {
- String platformResourcePath = uri.toPlatformString(true);
- if (getWorkspaceRoot() != null)
- {
- return WorkbenchHelper.createPlatformResourceInputStream(platformResourcePath, options);
- }
- else
- {
- URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath);
- if (resolvedLocation != null)
- {
- return getURIConverter(options).createInputStream(resolvedLocation, options);
- }
-
- throw new IOException("The path '" + platformResourcePath + "' is unmapped");
- }
- }
-
- @Override
- public void delete(URI uri, Map, ?> options) throws IOException
- {
- String platformResourcePath = uri.toPlatformString(true);
- if (getWorkspaceRoot() != null)
- {
- WorkbenchHelper.delete(platformResourcePath, options);
- }
- else
- {
- URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath);
- if (resolvedLocation != null)
- {
- getURIConverter(options).delete(resolvedLocation, options);
- }
- else
- {
- throw new IOException("The path '" + platformResourcePath + "' is unmapped");
- }
- }
- }
-
- @Override
- public boolean exists(URI uri, Map, ?> options)
- {
- String platformResourcePath = uri.toPlatformString(true);
- if (getWorkspaceRoot() != null)
- {
- return WorkbenchHelper.exists(platformResourcePath, options);
- }
- else
- {
- URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath);
- return resolvedLocation != null && getURIConverter(options).exists(resolvedLocation, options);
- }
- }
-
- @Override
- public Map getAttributes(URI uri, Map, ?> options)
- {
- String platformResourcePath = uri.toPlatformString(true);
- if (getWorkspaceRoot() != null)
- {
- return WorkbenchHelper.attributes(platformResourcePath, options);
- }
- else
- {
- URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath);
- return resolvedLocation == null ? Collections.emptyMap() : getURIConverter(options).getAttributes(resolvedLocation, options);
- }
- }
-
- @Override
- public void setAttributes(URI uri, Map attributes, Map, ?> options) throws IOException
- {
- String platformResourcePath = uri.toPlatformString(true);
- if (getWorkspaceRoot() != null)
- {
- WorkbenchHelper.updateAttributes(platformResourcePath, attributes, options);
- }
- else
- {
- URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath);
- if (resolvedLocation != null)
- {
- getURIConverter(options).setAttributes(resolvedLocation, attributes, options);
- }
- else
- {
- throw new IOException("The platform resource path '" + platformResourcePath + "' does not resolve");
- }
- }
- }
-}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/ResourceImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/ResourceImpl.java
index 8a09fce..b36992b 100644
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/ResourceImpl.java
+++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/ResourceImpl.java
@@ -49,10 +49,10 @@
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.URIConverter;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.util.InternalEList;
-import org.eclipse.emf.ecore.util.NotifyingInternalEListImpl;
import org.eclipse.emf.ecore.util.EcoreUtil.ContentTreeIterator;
import org.eclipse.emf.ecore.util.EcoreUtil.ProperContentIterator;
+import org.eclipse.emf.ecore.util.InternalEList;
+import org.eclipse.emf.ecore.util.NotifyingInternalEListImpl;
/**
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/URIConverterImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/URIConverterImpl.java
deleted file mode 100644
index 0524169..0000000
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/URIConverterImpl.java
+++ /dev/null
@@ -1,610 +0,0 @@
-/**
- * Copyright (c) 2002-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 v2.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v20.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- */
-package org.eclipse.emf.ecore.resource.impl;
-
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.common.CommonPlugin;
-import org.eclipse.emf.common.archive.ArchiveURLConnection;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.plugin.EcorePlugin;
-import org.eclipse.emf.ecore.resource.Resource;
-
-
-/**
- * A highly functional and extensible URI converter implementation.
- *
- * This implementation provides seamless transparent Eclipse integration
- * by supporting the platform:/resource mechanism both inside of Eclipse and outside of Eclipse.
- * Furthermore, although the implementation imports
- * both {@link org.eclipse.core.runtime} and {@link org.eclipse.core.resources},
- * and hence requires the Eclipse libraries at development time,
- * the implementation does not require them at runtime.
- * Clients of this implementation must be cautious if they wish to maintain this platform neutral behaviour.
- *
- * @deprecated since 2.4; use {@link ExtensibleURIConverterImpl} instead.
- */
-@Deprecated
-public class URIConverterImpl extends ExtensibleURIConverterImpl
-{
- /**
- * An output stream that transfers its contents to an {@link IFile} upon closing.
- * @deprecated @since 2.4; use {@link PlatformResourceURIHandlerImpl.PlatformResourceOutputStream} directly.
- */
- @Deprecated
- public static class PlatformResourceOutputStream extends PlatformResourceURIHandlerImpl.PlatformResourceOutputStream
- {
- /**
- * @deprecated since 2.4; use {@link PlatformResourceURIHandlerImpl.PlatformResourceOutputStream#PlatformResourceOutputStream(IFile, boolean, boolean, IProgressMonitor)} instead.
- */
- @Deprecated
- public PlatformResourceOutputStream(IFile file, boolean force, boolean keepHistory, IProgressMonitor progressMonitor)
- {
- super(file, force, keepHistory, progressMonitor);
- }
- }
-
- /**
- * Isolated Eclipse workbench utilities.
- * @deprecated since 2.4; use {@link PlatformResourceURIHandlerImpl.WorkbenchHelper} directly.
- */
- @Deprecated
- public static class WorkbenchHelper extends PlatformResourceURIHandlerImpl.WorkbenchHelper
- {
- /**
- * Creates an output stream for the given {@link IFile} path.
- *
- * This implementation uses a {@link PlatformResourceURIHandlerImpl.PlatformResourceOutputStream}.
- *
- * @return an open output stream.
- * @exception IOException if there is a problem obtaining an open output stream.
- * @see IWorkspaceRoot#getFile(org.eclipse.core.runtime.IPath)
- * @see PlatformResourceURIHandlerImpl.PlatformResourceOutputStream
- * @see IFile#setContents(InputStream, boolean, boolean, IProgressMonitor)
- * @deprecated since 2.4; use {@link PlatformResourceURIHandlerImpl.WorkbenchHelper#createPlatformResourceOutputStream(String, Map)} directly.
- */
- @Deprecated
- public static OutputStream createPlatformResourceOutputStream(String platformResourcePath) throws IOException
- {
- return PlatformResourceURIHandlerImpl.WorkbenchHelper.createPlatformResourceOutputStream(platformResourcePath, null);
- }
-
- /**
- * Creates an input stream for the given {@link IFile} path.
- *
- * This implementation uses {@link IFile#getContents() IFile.getContents}.
- *
- * @return an open input stream.
- * @see IWorkspaceRoot#getFile(org.eclipse.core.runtime.IPath)
- * @see IFile#getContents()
- * @exception IOException if there is a problem obtaining an open input stream.
- * @deprecated since 2.4; use {@link PlatformResourceURIHandlerImpl.WorkbenchHelper#createPlatformResourceInputStream(String, Map)} directly.
- */
- @Deprecated
- public static InputStream createPlatformResourceInputStream(String platformResourcePath) throws IOException
- {
- return PlatformResourceURIHandlerImpl.WorkbenchHelper.createPlatformResourceInputStream(platformResourcePath, null);
- }
- }
-
- /**
- * The cached Eclipse workspace.
- * @deprecated
- */
- @Deprecated
- protected static IWorkspaceRoot workspaceRoot = EcorePlugin.getWorkspaceRoot();
-
- private static Map efsScheme;
- private static final Method EFS_GET_FILE_SYSTEM_METHOD;
- private static final Method EFS_GET_STORE_METHOD;
- private static final Method FILE_STORE_OPEN_INPUT_STREAM_METHOD;
- private static final Method FILE_STORE_OPEN_OUTPUT_STREAM_METHOD;
- static
- {
- Method efsGetStoreMethod = null;
- Method efsGetFileSystemMethod = null;
- Method fileStoreOpenInputStreamMethod = null;
- Method fileStoreOpenOutputStreamMethod = null;
- try
- {
- Class > efsClass = CommonPlugin.loadClass("org.eclipse.core.filesystem", "org.eclipse.core.filesystem.EFS");
- efsGetStoreMethod = efsClass.getMethod("getStore", java.net.URI.class);
- efsGetFileSystemMethod = efsClass.getMethod("getFileSystem", String.class);
- Class > fileStoreClass = efsGetStoreMethod.getReturnType();
- fileStoreOpenInputStreamMethod = fileStoreClass.getMethod("openInputStream", Integer.TYPE, IProgressMonitor.class);
- fileStoreOpenOutputStreamMethod = fileStoreClass.getMethod("openOutputStream", Integer.TYPE, IProgressMonitor.class);
- }
- catch (Throwable exeption)
- {
- // Ignore any exceptions and assume the class isn't available.
- }
- EFS_GET_STORE_METHOD = efsGetStoreMethod;
- EFS_GET_FILE_SYSTEM_METHOD = efsGetFileSystemMethod;
- FILE_STORE_OPEN_INPUT_STREAM_METHOD = fileStoreOpenInputStreamMethod;
- FILE_STORE_OPEN_OUTPUT_STREAM_METHOD = fileStoreOpenOutputStreamMethod;
- }
-
- /**
- * A map that remaps URIs.
- * @deprecated since 2.4 use {@link ExtensibleURIConverterImpl.URIMap} instead.
- */
- @Deprecated
- public interface URIMap extends ExtensibleURIConverterImpl.URIMap
- {
- // No methods added.
- }
-
- /**
- * Creates an instance.
- * @deprecated since 2.4;
- * use new {@link ExtensibleURIConverterImpl#ExtensibleURIConverterImpl() ExtensibleURIConverterImpl()} instead.
- */
- @Deprecated
- public URIConverterImpl()
- {
- super();
- }
-
- /**
- * Returns whether the scheme is one that this implementation should treat as an archive.
- * This implementation returns true when the scheme is "archive".
- * @param scheme the scheme to consider.
- * @return whether the scheme is one that this implementation treats as an archive.
- */
- protected boolean isArchiveScheme(String scheme)
- {
- return "archive".equals(scheme);
- }
-
- /**
- * Returns whether the scheme is one that this implementation should treat as a supported Eclipse File System scheme.
- * This implementation uses Java reflection to check whether there is an Eclipse File System available and if so whether it supports this scheme.
- * @param scheme the scheme to consider.
- * @return whether the scheme is one that this implementation treats as an Eclipse File System scheme.
- */
- protected boolean isEFSScheme(String scheme)
- {
- if (EFS_GET_FILE_SYSTEM_METHOD == null)
- {
- return false;
- }
- else
- {
- Boolean result = efsScheme == null ? null : efsScheme.get(scheme);
- if (result == null)
- {
- try
- {
- result = EFS_GET_FILE_SYSTEM_METHOD.invoke(null, scheme) != null;
- }
- catch (Throwable exception)
- {
- result = Boolean.FALSE;
- }
- Map map = new HashMap();
- if (efsScheme != null)
- {
- map.putAll(efsScheme);
- }
- map.put(scheme, result);
- efsScheme = map;
- }
- return result == Boolean.TRUE;
- }
- }
-
- /**
- * Creates an output stream for the URI and returns it.
- *
- * This implementation {@link #normalize(URI) normalizes} the URI and uses that as the basis for further processing.
- * A {@link URI#isFile() file-based} URI is {@link URI#toFileString converted} to a file path, e.g.,
- *
- * and is delegated to {@link #createFileOutputStream createFileOutputStream}.
- * An {@link #isArchiveScheme(String) archive-based} URI is delegated to {@link #createArchiveOutputStream createArchiveOutputStream}.
- * A {@link URI#isPlatformResource() platform-based} URI is {@link URI#toPlatformString(boolean) converted} to a platform path
- * by trimming the leading platform:/resource, e.g.,
- *
- * and is delegated to {@link #createPlatformResourceOutputStream createPlatformResourceOutputStream}.
- * An {@link #isEFSScheme(String) EFS-based} URI is delegated to {@link #createEFSInputStream(URI) createEFSOutputStream}.
- * And all other cases are handled as standard URLs by {@link #createURLOutputStream createURLOutputStream}.
- *
- * @return an open output stream.
- * @exception IOException if there is a problem obtaining an open output stream.
- */
- @Override
- public OutputStream createOutputStream(URI uri) throws IOException
- {
- URI converted = normalize(uri);
- if (converted.isFile())
- {
- String filePath = converted.toFileString();
- return createFileOutputStream(filePath);
- }
- else
- {
- String scheme = converted.scheme();
- if (isArchiveScheme(scheme))
- {
- return createArchiveOutputStream(converted);
- }
- else if (converted.isPlatformResource())
- {
- return createPlatformResourceOutputStream(converted.toPlatformString(true));
- }
- else if (isEFSScheme(scheme))
- {
- return createEFSOutputStream(converted);
- }
- else
- {
- return createURLOutputStream(converted);
- }
- }
- }
-
- @Override
- public OutputStream createOutputStream(URI uri, Map, ?> options) throws IOException
- {
- return createOutputStream(uri);
- }
-
- /**
- * Creates an output stream for the file path and returns it.
- *
- * This implementation allocates a {@link FileOutputStream} and creates subdirectories as necessary.
- *
- * @return an open output stream.
- * @exception IOException if there is a problem obtaining an open output stream.
- */
- protected OutputStream createFileOutputStream(String filePath) throws IOException
- {
- File file = new File(filePath);
- String parent = file.getParent();
- if (parent != null)
- {
- new File(parent).mkdirs();
- }
- OutputStream outputStream = new FileOutputStream(file);
- return outputStream;
- }
-
- /**
- * Creates an output stream for the archive access.
- *
- * @return an open output stream.
- * @exception IOException if there is a problem obtaining an open output stream.
- */
- protected OutputStream createArchiveOutputStream(URI archiveURI) throws IOException
- {
- return createArchive(archiveURI).getOutputStream();
- }
-
- /**
- * Creates an output stream for the platform resource path and returns it.
- *
- * This implementation does one of two things, depending on the runtime environment.
- * If there is an Eclipse workspace, it delegates to
- * {@link WorkbenchHelper#createPlatformResourceOutputStream WorkbenchHelper.createPlatformResourceOutputStream},
- * which gives the expected Eclipse behaviour.
- * Otherwise, the {@link EcorePlugin#resolvePlatformResourcePath resolved} URI
- * is delegated to {@link #createOutputStream(URI, Map) createOutputStream}
- * for recursive processing.
- * @return an open output stream.
- * @exception IOException if there is a problem obtaining an open output stream or a valid interpretation of the path.
- * @see EcorePlugin#resolvePlatformResourcePath(String)
- */
- protected OutputStream createPlatformResourceOutputStream(String platformResourcePath) throws IOException
- {
- // ECLIPSE-DEPEND-BEGIN
- if (workspaceRoot != null)
- {
- return WorkbenchHelper.createPlatformResourceOutputStream(platformResourcePath);
- }
- else
- // ECLIPSE-DEPEND-END
- {
- URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath);
- if (resolvedLocation != null)
- {
- return createOutputStream(resolvedLocation);
- }
-
- throw new IOException("The path '" + platformResourcePath + "' is unmapped");
- }
- }
-
- /**
- * Creates an output stream for the URI, assuming it's a URI recognized by the Eclipse File System, and returns it.
- * @return an open output stream.
- * @exception IOException if there is a problem obtaining an open output stream.
- */
- protected OutputStream createEFSOutputStream(URI uri) throws IOException
- {
- if (EFS_GET_STORE_METHOD != null)
- {
- try
- {
- Object store = EFS_GET_STORE_METHOD.invoke(null, new java.net.URI(uri.toString()));
- if (store != null)
- {
- return (OutputStream)FILE_STORE_OPEN_OUTPUT_STREAM_METHOD.invoke(store, 0, null);
- }
- }
- catch (Exception exception)
- {
- throw new Resource.IOWrappedException(exception);
- }
- }
- throw new IOException("EFS unavailable");
- }
-
- /**
- * Creates an output stream for the URI, assuming it's a URL, and returns it.
- * @return an open output stream.
- * @exception IOException if there is a problem obtaining an open output stream.
- */
- protected OutputStream createURLOutputStream(URI uri) throws IOException
- {
- try
- {
- URL url = new URL(uri.toString());
- URLConnection urlConnection = url.openConnection();
- urlConnection.setDoOutput(true);
- return urlConnection.getOutputStream();
- }
- catch (RuntimeException exception)
- {
- throw new Resource.IOWrappedException(exception);
- }
- }
-
- /**
- * Creates an input stream for the URI and returns it.
- *
- * This implementation {@link #normalize(URI) normalizes} the URI and uses that as the basis for further processing.
- * A {@link URI#isFile() file-based} URI is {@link URI#toFileString converted} to a file path, e.g.,
- *
- * and is delegated to {@link #createFileInputStream createFileInputStream}.
- * An {@link #isArchiveScheme(String) archive-based} URI is delegated to {@link #createArchiveInputStream createArchiveInputStream}.
- * A {@link URI#isPlatformResource() platform-based} URI is {@link URI#toPlatformString(boolean) converted} to a platform path
- * by trimming the leading platform:/resource, e.g.,
- *
- * and is delegated to {@link #createPlatformResourceInputStream createPlatformResourceInputStream}.
- * An {@link #isEFSScheme(String) EFS-based} URI is delegated to {@link #createEFSInputStream(URI) createEFSInputStream}.
- * And all other cases are handled as standard URLs by {@link #createURLInputStream createURLInputStream}.
- *
- * @return an open input stream.
- * @exception IOException if there is a problem obtaining an open input stream.
- */
- @Override
- public InputStream createInputStream(URI uri) throws IOException
- {
- URI converted = normalize(uri);
- if (converted.isFile())
- {
- String filePath = converted.toFileString();
- return createFileInputStream(filePath);
- }
- else
- {
- String scheme = converted.scheme();
- if (isArchiveScheme(scheme))
- {
- return createArchiveInputStream(converted);
- }
- else if (converted.isPlatformResource())
- {
- return createPlatformResourceInputStream(converted.toPlatformString(true));
- }
- else if (isEFSScheme(scheme))
- {
- return createEFSInputStream(converted);
- }
- else
- {
- return createURLInputStream(converted);
- }
- }
- }
-
- @Override
- public InputStream createInputStream(URI uri, Map, ?> options) throws IOException
- {
- return createInputStream(uri);
- }
-
- /**
- * Creates an input stream for the file path and returns it.
- *
- * This implementation allocates a {@link FileInputStream}.
- *
- * @return an open input stream.
- * @exception IOException if there is a problem obtaining an open input stream.
- */
- protected InputStream createFileInputStream(String filePath) throws IOException
- {
- File file = new File(filePath);
- InputStream inputStream = new FileInputStream(file);
- return inputStream;
- }
-
- /**
- * A specialized class for reading from an archive.
- */
- protected class Archive extends ArchiveURLConnection
- {
- public Archive(URI uri)
- {
- super(uri.toString());
- }
-
- @Override
- protected boolean emulateArchiveScheme()
- {
- return false;
- }
-
- @Override
- protected boolean useZipFile()
- {
- return true;
- }
-
- @Override
- protected InputStream createInputStream(String nestedURL) throws IOException
- {
- return URIConverterImpl.this.createInputStream(URI.createURI(nestedURL));
- }
-
- @Override
- protected OutputStream createOutputStream(String nestedURL) throws IOException
- {
- return URIConverterImpl.this.createOutputStream(URI.createURI(nestedURL));
- }
- }
-
- protected Archive createArchive(URI uri)
- {
- return new Archive(uri);
- }
-
- /**
- * Creates an input stream for the archive paths and returns it.
- * It uses {@link Archive} to implement read access.
- *
- * @return an open input stream.
- * @exception IOException if there is a problem obtaining an open input stream.
- */
- protected InputStream createArchiveInputStream(URI archiveURI) throws IOException
- {
- return createArchive(archiveURI).getInputStream();
- }
-
- /**
- * Creates an input stream for the platform resource path and returns it.
- *
- * This implementation does one of two things, depending on the runtime environment.
- * If there is an Eclipse workspace, it delegates to
- * {@link WorkbenchHelper#createPlatformResourceInputStream WorkbenchHelper.createPlatformResourceInputStream},
- * which gives the expected Eclipse behaviour.
- * Otherwise, the {@link EcorePlugin#resolvePlatformResourcePath resolved} URI
- * is delegated to {@link #createInputStream(URI, Map) createInputStream}
- * for recursive processing.
- * @return an open input stream.
- * @exception IOException if there is a problem obtaining an open input stream or a valid interpretation of the path.
- * @see EcorePlugin#resolvePlatformResourcePath(String)
- */
- protected InputStream createPlatformResourceInputStream(String platformResourcePath) throws IOException
- {
- // ECLIPSE-DEPEND-BEGIN
- if (workspaceRoot != null)
- {
- return WorkbenchHelper.createPlatformResourceInputStream(platformResourcePath);
- }
- else
- // ECLIPSE-DEPEND-END
- {
- URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath);
- if (resolvedLocation != null)
- {
- return createInputStream(resolvedLocation);
- }
-
- throw new IOException("The path '" + platformResourcePath + "' is unmapped");
- }
- }
-
- /**
- * Creates an input stream for the URI, assuming it's a URI recognized by the Eclipse File System, and returns it.
- * @return an open input stream.
- * @exception IOException if there is a problem obtaining an open input stream.
- */
- protected InputStream createEFSInputStream(URI uri) throws IOException
- {
- if (EFS_GET_STORE_METHOD != null)
- {
- try
- {
- Object store = EFS_GET_STORE_METHOD.invoke(null, new java.net.URI(uri.toString()));
- if (store != null)
- {
- return (InputStream)FILE_STORE_OPEN_INPUT_STREAM_METHOD.invoke(store, 0, null);
- }
- }
- catch (Exception exception)
- {
- throw new Resource.IOWrappedException(exception);
- }
- }
- throw new IOException("EFS unavailable");
- }
-
- /**
- * Creates an input stream for the URI, assuming it's a URL, and returns it.
- * @return an open input stream.
- * @exception IOException if there is a problem obtaining an open input stream.
- */
- protected InputStream createURLInputStream(URI uri) throws IOException
- {
- try
- {
- URL url = new URL(uri.toString());
- URLConnection urlConnection = url.openConnection();
- return urlConnection.getInputStream();
- }
- catch (RuntimeException exception)
- {
- throw new Resource.IOWrappedException(exception);
- }
- }
-
- /**
- * Returns the internal version of the URI map.
- * @return the internal version of the URI map.
- * @deprecated since 2.4; there should be no need to call this method directly so use {@link #getURIMap()} instead.
- */
- @Override
- @Deprecated
- protected URIMap getInternalURIMap()
- {
- return (URIMap)super.getInternalURIMap();
- }
-}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/URIMappingRegistryImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/URIMappingRegistryImpl.java
index 6666f36..0522dae 100644
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/URIMappingRegistryImpl.java
+++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/URIMappingRegistryImpl.java
@@ -103,10 +103,10 @@ public URI getURI(URI uri)
{
for (int i = Math.min(prefixMaps.size() - 1, uri.segmentCount()); i >= 0; --i)
{
- List> prefixes = prefixMaps.get(i);
+ final List> prefixes = prefixMaps.get(i);
for (int j = prefixes.size() - 1; j >= 0; --j)
{
- Entry entry = prefixes.get(j);
+ final Entry entry = prefixes.get(j);
result = uri.replacePrefix(entry.getKey(), entry.getValue());
if (result != null)
@@ -140,8 +140,7 @@ protected URI delegatedGetURI(URI uri)
/**
* A map that is a {@link ExtensibleURIConverterImpl.URIMap}.
*/
- @SuppressWarnings("deprecation")
- protected class URIMapImpl extends DelegatingMap implements URIConverterImpl.URIMap, ExtensibleURIConverterImpl.URIMap.Internal
+ protected class URIMapImpl extends DelegatingMap implements ExtensibleURIConverterImpl.URIMap, ExtensibleURIConverterImpl.URIMap.Internal
{
/**
* Creates an instance.
@@ -157,7 +156,8 @@ public URIMapImpl()
* @param uri the URI to remap.
* @return the remapped URI, or the URI itself.
*/
- public URI getURI(URI uri)
+ @Override
+ public URI getURI(URI uri)
{
return URIMappingRegistryImpl.this.getURI(uri);
}
@@ -166,7 +166,8 @@ public URI getURI(URI uri)
* Delegates to the {@link URIMappingRegistryImpl#modificationCount()}.
* @since 2.8
*/
- public int modificationCount()
+ @Override
+ public int modificationCount()
{
return URIMappingRegistryImpl.this.modificationCount();
}
@@ -216,7 +217,7 @@ protected void didAdd(Entry entry)
{
if (((MappingEntryImpl)entry).isPrefixMapEntry)
{
- int length = entry.getKey().segmentCount();
+ final int length = entry.getKey().segmentCount();
if (prefixMaps == null)
{
prefixMaps = new BasicEList>>();
@@ -250,7 +251,7 @@ protected void didRemove(Entry entry)
{
if (((MappingEntryImpl)entry).isPrefixMapEntry)
{
- int length = entry.getKey().segmentCount();
+ final int length = entry.getKey().segmentCount();
prefixMaps.get(length).remove(entry);
}
}
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/BasicEAnnotationValidator.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/BasicEAnnotationValidator.java
index 80fbeb4..5c167a6 100644
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/BasicEAnnotationValidator.java
+++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/BasicEAnnotationValidator.java
@@ -35,7 +35,6 @@
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.ETypedElement;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.EcorePackage;
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/BasicInvocationDelegate.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/BasicInvocationDelegate.java
index 0cd7c87..b928e6d 100644
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/BasicInvocationDelegate.java
+++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/BasicInvocationDelegate.java
@@ -14,11 +14,10 @@
import java.lang.reflect.InvocationTargetException;
import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.EOperation;
/**
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/BasicSettingDelegate.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/BasicSettingDelegate.java
index e2dc6a7..edfe144 100644
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/BasicSettingDelegate.java
+++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/BasicSettingDelegate.java
@@ -13,9 +13,9 @@
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.EStructuralFeature.Setting;
import org.eclipse.emf.ecore.EStructuralFeature.Internal.DynamicValueHolder;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.InternalEObject;
/**
* A basic implementation of a stateful setting delegate.
diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/DateConversionDelegateFactory.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/DateConversionDelegateFactory.java
index c88f8b2..4399728 100644
--- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/DateConversionDelegateFactory.java
+++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/DateConversionDelegateFactory.java
@@ -51,7 +51,7 @@
/**
* A {@link org.eclipse.emf.ecore.EDataType.Internal.ConversionDelegate.Factory conversion delegate factory}
- * for converting {@link Long#TYPE long}, {@link Long} {@link Date}, {@link java.sql.Date}, {@link Calendar}, {@link GregorianCalendar}, and {@link XMLGregorianCalendar} instances to and from a string representation.
+ * for converting {@link Long#TYPE long}, {@link Long} {@link Date}, {@link Calendar}, {@link GregorianCalendar}, and {@link XMLGregorianCalendar} instances to and from a string representation.
*
* The annotation detail for the {@code "format"} key of this annotation must be present and the value must be one of the following forms:
*