From 251e9bab340e61013231e8db2e44b58ec496474a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mora?= Date: Mon, 3 Dec 2018 14:45:28 +0800 Subject: [PATCH] Remove Eclipse code, Modularize projects --- .../src/main/java/module-info.java | 9 + .../org/eclipse/emf/common/CommonPlugin.java | 637 +-------- .../org/eclipse/emf/common/EMFPlugin.java | 393 +----- .../emf/common/util/BasicDiagnostic.java | 246 ---- .../eclipse/emf/common/util/BasicMonitor.java | 195 --- .../eclipse/emf/common/util/CommonUtil.java | 1 - .../emf/common/util/DiagnosticException.java | 7 - .../org/eclipse/emf/common/util/Pool.java | 1 - .../org/eclipse/emf/common/util/Reflect.java | 1 - .../emf/common/util/WeakInterningHashSet.java | 1 - org.eclipse.emf.ecore.xmi/build.gradle | 4 +- .../src/main/java/module-info.java | 11 + .../org/eclipse/emf/ecore/xmi/XMIPlugin.java | 54 - .../eclipse/emf/ecore/xmi/XMLResource.java | 5 - .../ecore/xmi/impl/EMOFExtendedMetaData.java | 12 +- .../xmi/impl/RootXMLContentHandlerImpl.java | 16 - .../emf/ecore/xmi/impl/StringSegment.java | 2 +- .../ecore/xmi/impl/XMLContentHandlerImpl.java | 15 - org.eclipse.emf.ecore/build.gradle | 2 +- .../src/main/java/module-info.java | 20 + .../emf/ecore/EAnnotationValidator.java | 7 +- .../java/org/eclipse/emf/ecore/EClass.java | 1 - .../java/org/eclipse/emf/ecore/EObject.java | 1 - .../eclipse/emf/ecore/InternalEObject.java | 1 - .../eclipse/emf/ecore/impl/EClassImpl.java | 2 +- .../eclipse/emf/ecore/impl/EFactoryImpl.java | 2 +- .../emf/ecore/impl/EOperationImpl.java | 2 +- .../eclipse/emf/ecore/impl/EPackageImpl.java | 2 +- .../emf/ecore/impl/EPackageRegistryImpl.java | 17 - .../ecore/impl/EStructuralFeatureImpl.java | 4 +- .../emf/ecore/impl/ETypeParameterImpl.java | 3 - .../ecore/impl/EValidatorRegistryImpl.java | 1 - .../emf/ecore/impl/EcoreFactoryImpl.java | 16 +- .../AnnotationValidatorRegistryReader.java | 136 -- .../plugin/ContentHandlerRegistryReader.java | 117 -- .../plugin/ContentParserRegistryReader.java | 74 - ...nversionDelegateFactoryRegistryReader.java | 86 -- .../plugin/DynamicPackageRegistryReader.java | 73 - .../eclipse/emf/ecore/plugin/EcorePlugin.java | 1200 +---------------- .../plugin/ExtensionParserRegistryReader.java | 73 - .../plugin/FactoryOverrideRegistryReader.java | 197 --- .../GeneratedPackageRegistryReader.java | 102 -- ...vocationDelegateFactoryRegistryReader.java | 87 -- .../plugin/ProtocolParserRegistryReader.java | 74 - .../QueryDelegateFactoryRegistryReader.java | 86 -- .../emf/ecore/plugin/RegistryReader.java | 386 ------ .../SettingDelegateFactoryRegistryReader.java | 87 -- .../plugin/URIMappingRegistryReader.java | 92 -- .../ValidationDelegateRegistryReader.java | 87 -- .../emf/ecore/resource/ContentHandler.java | 19 +- .../emf/ecore/resource/URIConverter.java | 32 +- .../emf/ecore/resource/URIHandler.java | 2 - .../resource/impl/BinaryResourceImpl.java | 1 - .../resource/impl/ContentHandlerImpl.java | 180 --- .../resource/impl/EFSURIHandlerImpl.java | 9 +- .../impl/ExtensibleURIConverterImpl.java | 16 +- .../impl/PlatformContentHandlerImpl.java | 205 --- .../impl/PlatformResourceURIHandlerImpl.java | 661 --------- .../emf/ecore/resource/impl/ResourceImpl.java | 4 +- .../ecore/resource/impl/URIConverterImpl.java | 610 --------- .../resource/impl/URIMappingRegistryImpl.java | 17 +- .../ecore/util/BasicEAnnotationValidator.java | 1 - .../ecore/util/BasicInvocationDelegate.java | 3 +- .../emf/ecore/util/BasicSettingDelegate.java | 4 +- .../util/DateConversionDelegateFactory.java | 93 +- .../eclipse/emf/ecore/util/Diagnostician.java | 4 +- .../emf/ecore/util/EObjectValidator.java | 11 +- .../emf/ecore/util/EcoreAdapterFactory.java | 20 +- .../ecore/util/EcoreAnnotationValidator.java | 2 - .../eclipse/emf/ecore/util/EcoreSwitch.java | 19 +- .../emf/ecore/util/EcoreValidator.java | 27 +- .../eclipse/emf/ecore/util/InternalEList.java | 3 - .../eclipse/emf/ecore/util/QueryDelegate.java | 58 - .../org/eclipse/emf/ecore/util/Switch.java | 1 - .../emf/ecore/xml/type/XMLTypeFactory.java | 1 - .../type/impl/ProcessingInstructionImpl.java | 3 - .../type/impl/XMLTypeDocumentRootImpl.java | 1 + .../xml/type/impl/XMLTypeFactoryImpl.java | 15 +- .../xml/type/impl/XMLTypePackageImpl.java | 4 +- .../ecore/xml/type/internal/XMLDuration.java | 2 +- .../xml/type/util/XMLTypeResourceImpl.java | 6 +- .../emf/ecore/xml/type/util/XMLTypeUtil.java | 1 - .../ecore/xml/type/util/XMLTypeValidator.java | 10 +- 83 files changed, 212 insertions(+), 6481 deletions(-) create mode 100644 org.eclipse.emf.common/src/main/java/module-info.java create mode 100644 org.eclipse.emf.ecore.xmi/src/main/java/module-info.java create mode 100644 org.eclipse.emf.ecore/src/main/java/module-info.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/AnnotationValidatorRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ContentHandlerRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ContentParserRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ConversionDelegateFactoryRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/DynamicPackageRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ExtensionParserRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/FactoryOverrideRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/GeneratedPackageRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/InvocationDelegateFactoryRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ProtocolParserRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/QueryDelegateFactoryRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/RegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/SettingDelegateFactoryRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/URIMappingRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ValidationDelegateRegistryReader.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/PlatformContentHandlerImpl.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/PlatformResourceURIHandlerImpl.java delete mode 100644 org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/resource/impl/URIConverterImpl.java diff --git a/org.eclipse.emf.common/src/main/java/module-info.java b/org.eclipse.emf.common/src/main/java/module-info.java new file mode 100644 index 0000000..58dd6af --- /dev/null +++ b/org.eclipse.emf.common/src/main/java/module-info.java @@ -0,0 +1,9 @@ +module org.eclipse.emf.common +{ + exports org.eclipse.emf.common.command; + exports org.eclipse.emf.common.util; + exports org.eclipse.emf.common.notify; + exports org.eclipse.emf.common.notify.impl; + exports org.eclipse.emf.common; + exports org.eclipse.emf.common.archive; +} \ No newline at end of file diff --git a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/CommonPlugin.java b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/CommonPlugin.java index 162dd25..92496d1 100644 --- a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/CommonPlugin.java +++ b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/CommonPlugin.java @@ -11,10 +11,7 @@ package org.eclipse.emf.common; -import java.io.File; -import java.io.IOException; import java.lang.reflect.Method; -import java.net.URL; import java.text.Collator; import java.util.ArrayList; import java.util.Collections; @@ -27,13 +24,7 @@ import java.util.Set; import java.util.TreeMap; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Platform; import org.eclipse.emf.common.util.ResourceLocator; -import org.eclipse.emf.common.util.URI; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleActivator; /** @@ -55,11 +46,6 @@ public final class CommonPlugin extends EMFPlugin */ public static final CommonPlugin INSTANCE = new CommonPlugin(); - /** - * The one instance of this class. - */ - private static Implementation plugin; - /** * Creates the singleton instance. */ @@ -68,111 +54,12 @@ private CommonPlugin() super(new ResourceLocator[] {}); } - @Override - public ResourceLocator getPluginResourceLocator() - { - return plugin; - } - - /** - * Returns the singleton instance of the Eclipse plugin. - * @return the singleton instance. - */ - public static Implementation getPlugin() - { - return plugin; - } - - /** - * Use the platform, if available, to convert to a local URI. - */ - public static URI asLocalURI(URI uri) - { - return plugin == null ? uri : Implementation.asLocalURI(uri); - } - - /** - * Use the platform, if available, to resolve the URI. - */ - public static URI resolve(URI uri) - { - return plugin == null ? uri : Implementation.resolve(uri); - } - /** * Use the platform, if available, to load the named class using the right class loader. */ public static Class loadClass(String pluginID, String className) throws ClassNotFoundException { - return plugin == null ? Class.forName(className) : Implementation.loadClass(pluginID, className); - } - - /** - * Computes a list of {@link ElementRecord element records} for each requested extension point. - * Each key in the map is extension point ID. - *

- * 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 + ""); -// } -// } -// } - - } } 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 data; - - public DiagnosticWrapper(IStatus status) - { - this.status = status; - } - - public int getCode() - { - return status.getCode(); - } - - public String getMessage() - { - return status.getMessage(); - } - - public int getSeverity() - { - return status.getSeverity(); - } - - public String getSource() - { - return status.getPlugin(); - } - - public Throwable getException() - { - return status.getException(); - } - - public List basicGetChildren() - { - if (wrappedChildren == null) - { - IStatus[] children = status.getChildren(); - if (children.length == 0) - { - wrappedChildren = new ArrayList(); - } - else - { - wrappedChildren = new ArrayList(children.length); - for (IStatus child : children) - { - wrappedChildren.add(toDiagnostic(child)); - } - } - } - return wrappedChildren; - } - - public List getChildren() - { - if (unmodifiableWrappedChildren == null) - { - unmodifiableWrappedChildren = Collections.unmodifiableList(basicGetChildren()); - } - return unmodifiableWrappedChildren; - } - - public List getData() - { - if (data == null) - { - List list = new ArrayList(2); - Throwable exception = getException(); - if (exception != null) - { - list.add(exception); - } - list.add(status); - data = Collections.unmodifiableList(list); - } - return data; - } - - public static Diagnostic convert(IStatus status) - { - return - status instanceof StatusWrapper ? - ((StatusWrapper)status).diagnostic : - new DiagnosticWrapper(status); - } - } - - public static Diagnostic toDiagnostic(IStatus status) - { - return DiagnosticWrapper.convert(status); - } - /** * Returns the throwable viewed as a {@link Diagnostic}. * @@ -525,15 +307,6 @@ else if (throwable instanceof WrappedException) return toDiagnostic(throwable.getCause()); } - if (EMFPlugin.IS_ECLIPSE_RUNNING) - { - Diagnostic diagnostic = EclipseHelper.toDiagnostic(throwable); - if (diagnostic != null) - { - return diagnostic; - } - } - String message = throwable.getClass().getName(); int index = message.lastIndexOf('.'); if (index >= 0) @@ -561,23 +334,4 @@ else if (throwable instanceof WrappedException) return basicDiagnostic; } - - private static class EclipseHelper - { - public static Diagnostic toDiagnostic(Throwable throwable) - { - if (throwable instanceof org.eclipse.core.runtime.CoreException) - { - IStatus status = ((org.eclipse.core.runtime.CoreException)throwable).getStatus(); - DiagnosticWrapper wrapperDiagnostic = new DiagnosticWrapper(status); - Throwable cause = throwable.getCause(); - if (cause != null && cause != throwable) - { - wrapperDiagnostic.basicGetChildren().add(BasicDiagnostic.toDiagnostic(cause)); - } - return wrapperDiagnostic; - } - return null; - } - } } diff --git a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/BasicMonitor.java b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/BasicMonitor.java index d987753..03c2fd1 100644 --- a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/BasicMonitor.java +++ b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/BasicMonitor.java @@ -12,9 +12,6 @@ import java.io.PrintStream; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IProgressMonitorWithBlocking; -import org.eclipse.core.runtime.IStatus; /** @@ -151,198 +148,6 @@ public void done() { monitor.done(); } - - /** - * A simple monitor that delegates to another monitor, and implements the Eclipse API - */ - private static class Eclipse extends Delegating implements IProgressMonitorWithBlocking - { - public Eclipse(Monitor monitor) - { - super(monitor); - } - - public void setBlocked(IStatus reason) - { - setBlocked - (new BasicDiagnostic - (reason.getSeverity(), - reason.getPlugin(), - reason.getCode(), - reason.getMessage(), - null)); - } - - public static IProgressMonitorWithBlocking createIProgressMonitorWithBlocking(Monitor monitor) - { - if (monitor instanceof IProgressMonitorWithBlocking) - { - return (IProgressMonitorWithBlocking)monitor; - } - else - { - return new Eclipse(monitor); - } - } - - public static IProgressMonitor createIProgressMonitor(Monitor monitor) - { - if (monitor instanceof IProgressMonitor) - { - return (IProgressMonitor)monitor; - } - else - { - return new Eclipse(monitor); - } - } - } - } - - /** - * Creates a delegating wrapper that allows the monitor to be used - * in a context requiring an instance implementing the Eclipse API. - */ - public static IProgressMonitor toIProgressMonitor(Monitor monitor) - { - return Delegating.Eclipse.createIProgressMonitor(monitor); - } - - /** - * Creates a delegating wrapper that allows the monitor to be used - * in a context requiring an instance implementing the Eclipse API. - */ - public static IProgressMonitorWithBlocking toIProgressMonitorWithBlocking(Monitor monitor) - { - return Delegating.Eclipse.createIProgressMonitorWithBlocking(monitor); - } - - /** - * Create a progress monitor that consumes the specified number of ticks. - * @since 2.13 - */ - public static IProgressMonitorWithBlocking subProgress(IProgressMonitor monitor, int ticks) - { - return new EclipseSubProgress(monitor, ticks); - } - - /** - * A simple monitor that delegates to another Eclipse monitor. - */ - private static class EclipseDelegating implements Monitor - { - protected IProgressMonitor progressMonitor; - protected IProgressMonitorWithBlocking progressMonitorWithBlocking; - - public EclipseDelegating(IProgressMonitor progressMonitor) - { - this.progressMonitor = progressMonitor; - if (progressMonitor instanceof IProgressMonitorWithBlocking) - { - this.progressMonitorWithBlocking = (IProgressMonitorWithBlocking)progressMonitor; - } - } - - public EclipseDelegating(IProgressMonitorWithBlocking progressMonitorWithBlocking) - { - this.progressMonitor = progressMonitorWithBlocking; - this.progressMonitorWithBlocking = progressMonitorWithBlocking; - } - - public boolean isCanceled() - { - return progressMonitor.isCanceled(); - } - - public void setCanceled(boolean value) - { - progressMonitor.setCanceled(value); - } - - public void setBlocked(Diagnostic reason) - { - if (progressMonitorWithBlocking != null) - { - progressMonitorWithBlocking.setBlocked(BasicDiagnostic.toIStatus(reason)); - } - } - - public void clearBlocked() - { - if (progressMonitorWithBlocking != null) - { - progressMonitorWithBlocking.clearBlocked(); - } - } - - public void beginTask(String name, int totalWork) - { - progressMonitor.beginTask(name, totalWork); - } - - public void setTaskName(String name) - { - progressMonitor.setTaskName(name); - } - - public void subTask(String name) - { - progressMonitor.subTask(name); - } - - public void worked(int work) - { - progressMonitor.worked(work); - } - - public void internalWorked(double work) - { - progressMonitor.internalWorked(work); - } - - public void done() - { - progressMonitor.done(); - } - } - - /** - * Creates a delegating wrapper that allows the Eclipse progress monitor to be used - * in a context requiring an instance implementing the monitor API. - */ - public static Monitor toMonitor(IProgressMonitorWithBlocking progressMonitor) - { - return new EclipseDelegating(progressMonitor); - } - - /** - * Creates a delegating wrapper that allows the Eclipse progress monitor to be used - * in a context requiring an instance implementing the monitor API. - */ - public static Monitor toMonitor(IProgressMonitor progressMonitor) - { - return new EclipseDelegating(progressMonitor); - } - - /** - * An Eclipse subprogress monitor that directly implements the monitor API. - */ - public static class EclipseSubProgress extends org.eclipse.core.runtime.SubProgressMonitor implements Monitor - { - public EclipseSubProgress(IProgressMonitor monitor, int ticks) - { - super(monitor, ticks); - } - - public EclipseSubProgress(IProgressMonitor monitor, int ticks, int style) - { - super(monitor, ticks, style); - } - - public void setBlocked(Diagnostic reason) - { - super.setBlocked(BasicDiagnostic.toIStatus(reason)); - } } /** diff --git a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/CommonUtil.java b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/CommonUtil.java index e23302f..2589813 100644 --- a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/CommonUtil.java +++ b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/CommonUtil.java @@ -9,7 +9,6 @@ import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; -import java.lang.ref.WeakReference; import java.util.Locale; import org.eclipse.emf.common.CommonPlugin; diff --git a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/DiagnosticException.java b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/DiagnosticException.java index 4918fb8..fe789d3 100644 --- a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/DiagnosticException.java +++ b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/DiagnosticException.java @@ -10,8 +10,6 @@ */ package org.eclipse.emf.common.util; -import org.eclipse.core.runtime.CoreException; - /** * A checked exception representing a diagnosed failure. *

@@ -35,9 +33,4 @@ public final Diagnostic getDiagnostic() { return diagnostic; } - - public static CoreException toCoreException(DiagnosticException exception) - { - return new CoreException(BasicDiagnostic.toIStatus(exception)); - } } diff --git a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/Pool.java b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/Pool.java index 449e00e..b3fe273 100644 --- a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/Pool.java +++ b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/Pool.java @@ -13,7 +13,6 @@ import java.util.Iterator; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; /** diff --git a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/Reflect.java b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/Reflect.java index f309a7c..1c42cb4 100644 --- a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/Reflect.java +++ b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/Reflect.java @@ -10,7 +10,6 @@ */ package org.eclipse.emf.common.util; -import java.lang.reflect.Array; import java.util.HashMap; import java.util.Map; diff --git a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/WeakInterningHashSet.java b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/WeakInterningHashSet.java index 677f1ad..213bf9c 100644 --- a/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/WeakInterningHashSet.java +++ b/org.eclipse.emf.common/src/main/java/org/eclipse/emf/common/util/WeakInterningHashSet.java @@ -20,7 +20,6 @@ import java.util.ConcurrentModificationException; import java.util.Iterator; import java.util.NoSuchElementException; -import java.util.WeakHashMap; /** * An implementation of an {@link InterningSet interning set} that keeps weak references to its element. diff --git a/org.eclipse.emf.ecore.xmi/build.gradle b/org.eclipse.emf.ecore.xmi/build.gradle index 9c4bd82..54f47db 100644 --- a/org.eclipse.emf.ecore.xmi/build.gradle +++ b/org.eclipse.emf.ecore.xmi/build.gradle @@ -4,6 +4,6 @@ plugins { dependencies { - implementation project(':org.eclipse.emf.common') - implementation project(':org.eclipse.emf.ecore') + api project(':org.eclipse.emf.common') + api project(':org.eclipse.emf.ecore') } diff --git a/org.eclipse.emf.ecore.xmi/src/main/java/module-info.java b/org.eclipse.emf.ecore.xmi/src/main/java/module-info.java new file mode 100644 index 0000000..0eb3143 --- /dev/null +++ b/org.eclipse.emf.ecore.xmi/src/main/java/module-info.java @@ -0,0 +1,11 @@ +module org.eclipse.emf.ecore.xmi +{ + exports org.eclipse.emf.ecore.xmi; + exports org.eclipse.emf.ecore.xmi.impl; + exports org.eclipse.emf.ecore.xmi.util; + + requires java.xml; + + requires transitive org.eclipse.emf.common; + requires transitive org.eclipse.emf.ecore; +} diff --git a/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/XMIPlugin.java b/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/XMIPlugin.java index 1e0712c..72f79e2 100644 --- a/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/XMIPlugin.java +++ b/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/XMIPlugin.java @@ -13,7 +13,6 @@ import org.eclipse.emf.common.EMFPlugin; import org.eclipse.emf.common.util.ResourceLocator; -import org.osgi.framework.BundleActivator; /** @@ -26,11 +25,6 @@ public final class XMIPlugin extends EMFPlugin */ public static final XMIPlugin INSTANCE = new XMIPlugin(); - /** - * The one instance of this class. - */ - private static Implementation plugin; - /** * Creates the singleton instance. */ @@ -38,52 +32,4 @@ private XMIPlugin() { super(new ResourceLocator[] {}); } - - /* - * Javadoc copied from base class. - */ - @Override - public ResourceLocator getPluginResourceLocator() - { - return plugin; - } - - /** - * Returns the singleton instance of the Eclipse plugin. - * @return the singleton instance. - */ - public static Implementation getPlugin() - { - return plugin; - } - - /** - * 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; - } - - /** - * @since 2.10 - */ - public static class Activator extends EMFPlugin.OSGiDelegatingBundleActivator - { - @Override - protected BundleActivator createBundle() - { - return new Implementation(); - } - } - } } diff --git a/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/XMLResource.java b/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/XMLResource.java index 35bb670..7901843 100644 --- a/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/XMLResource.java +++ b/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/XMLResource.java @@ -25,12 +25,7 @@ import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; -import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.BinaryIO.Version; import org.eclipse.emf.ecore.util.ExtendedMetaData; -import org.eclipse.emf.ecore.xmi.impl.ConfigurationCache; -import org.eclipse.emf.ecore.xmi.impl.ResourceEntityHandlerImpl; -import org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl; import org.eclipse.emf.ecore.xml.type.AnyType; import org.w3c.dom.Document; import org.w3c.dom.Node; diff --git a/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/EMOFExtendedMetaData.java b/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/EMOFExtendedMetaData.java index 372e9cf..d67a9f0 100644 --- a/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/EMOFExtendedMetaData.java +++ b/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/EMOFExtendedMetaData.java @@ -12,11 +12,9 @@ import java.util.HashMap; -import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EModelElement; import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.emf.ecore.util.BasicExtendedMetaData; @@ -100,10 +98,10 @@ public EPackage getPackage(String namespace) @Override public String getName(EClassifier eClassifier) { - XMLResource.XMLInfo info = xmlMap.getInfo(eClassifier); + final XMLResource.XMLInfo info = xmlMap.getInfo(eClassifier); if (info != null) { - String name = info.getName(); + final String name = info.getName(); if (name != null) { return info.getName(); @@ -115,10 +113,10 @@ public String getName(EClassifier eClassifier) @Override public String getName(EStructuralFeature eStructuralFeature) { - XMLResource.XMLInfo info = xmlMap.getInfo(eStructuralFeature); + final XMLResource.XMLInfo info = xmlMap.getInfo(eStructuralFeature); if (info != null) { - String name = info.getName(); + final String name = info.getName(); if (name != null) { return info.getName(); @@ -141,7 +139,7 @@ public EClassifier getType(EPackage ePackage, String name) @Override public int getFeatureKind(EStructuralFeature feature) { - XMLResource.XMLInfo info = xmlMap.getInfo(feature); + final XMLResource.XMLInfo info = xmlMap.getInfo(feature); if (info != null) { switch (info.getXMLRepresentation()) diff --git a/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/RootXMLContentHandlerImpl.java b/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/RootXMLContentHandlerImpl.java index 9dc4aed..e27e601 100644 --- a/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/RootXMLContentHandlerImpl.java +++ b/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/RootXMLContentHandlerImpl.java @@ -20,7 +20,6 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.resource.ContentHandler; -import org.eclipse.emf.ecore.resource.impl.ContentHandlerImpl; import org.eclipse.emf.ecore.util.ExtendedMetaData; import org.eclipse.emf.ecore.xmi.XMLResource; import org.eclipse.emf.ecore.xml.type.XMLTypeDocumentRoot; @@ -306,19 +305,4 @@ protected boolean isMatchingNamespace(String rootElementNamespace) return namespace == null ? rootElementNamespace == null : namespace.equals(rootElementNamespace); } } - - /** - * A describer that {@link #createContentHandler(Map) creates} a {@link RootXMLContentHandlerImpl} instance. - */ - public static class Describer extends ContentHandlerImpl.Describer - { - /** - * Creates a {@link RootXMLContentHandlerImpl} instance. - */ - @Override - protected ContentHandler createContentHandler(Map parameters) - { - return new RootXMLContentHandlerImpl(parameters); - } - } } diff --git a/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/StringSegment.java b/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/StringSegment.java index 4bd3870..bdf1f46 100644 --- a/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/StringSegment.java +++ b/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/StringSegment.java @@ -460,7 +460,7 @@ public void write(Writer os, int flushThreshold) throws IOException } - protected static class Element + public static class Element { int size; diff --git a/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/XMLContentHandlerImpl.java b/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/XMLContentHandlerImpl.java index 97571ad..9a9f9e2 100644 --- a/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/XMLContentHandlerImpl.java +++ b/org.eclipse.emf.ecore.xmi/src/main/java/org/eclipse/emf/ecore/xmi/impl/XMLContentHandlerImpl.java @@ -268,20 +268,5 @@ public Map contentDescription(URI uri, InputStream inputStream, } return result; } - - /** - * A describer that {@link #createContentHandler(Map) creates} an {@link XMI} instance. - */ - public static class Describer extends ContentHandlerImpl.Describer - { - /** - * Creates a {@link RootXMLContentHandlerImpl} instance. - */ - @Override - protected ContentHandler createContentHandler(Map parameters) - { - return new XMI(); - } - } } } diff --git a/org.eclipse.emf.ecore/build.gradle b/org.eclipse.emf.ecore/build.gradle index a5b3518..b9f6948 100644 --- a/org.eclipse.emf.ecore/build.gradle +++ b/org.eclipse.emf.ecore/build.gradle @@ -4,5 +4,5 @@ plugins { dependencies { - implementation project(':org.eclipse.emf.common') + api project(':org.eclipse.emf.common') } diff --git a/org.eclipse.emf.ecore/src/main/java/module-info.java b/org.eclipse.emf.ecore/src/main/java/module-info.java new file mode 100644 index 0000000..f725a79 --- /dev/null +++ b/org.eclipse.emf.ecore/src/main/java/module-info.java @@ -0,0 +1,20 @@ +module org.eclipse.emf.ecore +{ + exports org.eclipse.emf.ecore; + exports org.eclipse.emf.ecore.impl; + exports org.eclipse.emf.ecore.xml.namespace.impl; + exports org.eclipse.emf.ecore.resource.impl; + exports org.eclipse.emf.ecore.xml.type.internal; + exports org.eclipse.emf.ecore.plugin; + exports org.eclipse.emf.ecore.xml.namespace.util; + exports org.eclipse.emf.ecore.xml.type; + exports org.eclipse.emf.ecore.xml.type.util; + exports org.eclipse.emf.ecore.xml.type.impl; + exports org.eclipse.emf.ecore.resource; + exports org.eclipse.emf.ecore.util; + exports org.eclipse.emf.ecore.xml.namespace; + + requires transitive java.xml; + + requires transitive org.eclipse.emf.common; +} \ No newline at end of file diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/EAnnotationValidator.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/EAnnotationValidator.java index 7581858..8aaa40f 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/EAnnotationValidator.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/EAnnotationValidator.java @@ -12,8 +12,6 @@ import java.util.Map; import org.eclipse.emf.common.util.DiagnosticChain; -import org.eclipse.emf.ecore.util.BasicEAnnotationValidator; -import org.eclipse.emf.ecore.util.EObjectValidator; /** @@ -68,7 +66,7 @@ public Object get(Object key) Object eAnnotationValidator = super.get(key); if (eAnnotationValidator instanceof EAnnotationValidator.Descriptor) { - EAnnotationValidator.Descriptor eAnnotationValidatorDescriptor = (EAnnotationValidator.Descriptor)eAnnotationValidator; + final EAnnotationValidator.Descriptor eAnnotationValidatorDescriptor = (EAnnotationValidator.Descriptor)eAnnotationValidator; eAnnotationValidator = eAnnotationValidatorDescriptor.getEAnnotationValidator(); put((String)key, eAnnotationValidator); return eAnnotationValidator; @@ -79,7 +77,8 @@ public Object get(Object key) } } - public EAnnotationValidator getEAnnotationValidator(String annotationSource) + @Override + public EAnnotationValidator getEAnnotationValidator(String annotationSource) { return (EAnnotationValidator)get(annotationSource); } diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/EClass.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/EClass.java index 2deb2b8..8a52b13 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/EClass.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/EClass.java @@ -12,7 +12,6 @@ import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.util.EcoreUtil; /** diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/EObject.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/EObject.java index de2a732..9877939 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/EObject.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/EObject.java @@ -18,7 +18,6 @@ import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.util.ExtendedMetaData; /** diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/InternalEObject.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/InternalEObject.java index 35d7e83..09d4274 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/InternalEObject.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/InternalEObject.java @@ -17,7 +17,6 @@ import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.util.ExtendedMetaData; /** diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EClassImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EClassImpl.java index 68ba010..b1c7520 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EClassImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EClassImpl.java @@ -12,8 +12,8 @@ package org.eclipse.emf.ecore.impl; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Array; +import java.lang.reflect.InvocationTargetException; import java.util.AbstractSequentialList; import java.util.Collection; import java.util.HashMap; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EFactoryImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EFactoryImpl.java index 29b7d8f..b3ebaf4 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EFactoryImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EFactoryImpl.java @@ -42,11 +42,11 @@ import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.util.ExtendedMetaData; import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.emf.ecore.xml.type.util.XMLTypeUtil; -import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; /** * diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EOperationImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EOperationImpl.java index 729d8dc..0204989 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EOperationImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EOperationImpl.java @@ -12,8 +12,8 @@ package org.eclipse.emf.ecore.impl; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Array; +import java.lang.reflect.InvocationTargetException; import java.util.AbstractSequentialList; import java.util.Collection; import java.util.Iterator; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EPackageImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EPackageImpl.java index a024b04..ee37e2e 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EPackageImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EPackageImpl.java @@ -51,8 +51,8 @@ import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; import org.eclipse.emf.ecore.util.BasicExtendedMetaData; -import org.eclipse.emf.ecore.util.ExtendedMetaData; import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.ExtendedMetaData; import org.eclipse.emf.ecore.util.InternalEList; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EPackageRegistryImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EPackageRegistryImpl.java index c2ce4e6..00c4663 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EPackageRegistryImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EPackageRegistryImpl.java @@ -22,7 +22,6 @@ import org.eclipse.emf.common.EMFPlugin; import org.eclipse.emf.ecore.EFactory; import org.eclipse.emf.ecore.EPackage; - import org.eclipse.emf.ecore.plugin.EcorePlugin; @@ -52,22 +51,6 @@ public static EPackage.Registry createGlobalRegistry() { return EcorePlugin.getDefaultRegistryImplementation(); } - else if (!EMFPlugin.IS_OSGI_RUNNING) - { - try - { - SecurityManager securityManager = System.getSecurityManager(); - if (securityManager != null) - { - securityManager.checkPermission(new RuntimePermission("classLoader")); - } - return new Delegator(); - } - catch (Throwable throwable) - { - return new SecureDelegator(); - } - } else { return new EPackageRegistryImpl(); diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java index eb29a70..e32a466 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java @@ -19,16 +19,16 @@ import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.notify.impl.NotificationChainImpl; import org.eclipse.emf.common.util.BasicEMap; +import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.EMap; import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EGenericType; import org.eclipse.emf.ecore.EDataType; import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EGenericType; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EReference; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/ETypeParameterImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/ETypeParameterImpl.java index 3bde23d..bb2d701 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/ETypeParameterImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/ETypeParameterImpl.java @@ -18,16 +18,13 @@ import java.util.WeakHashMap; import org.eclipse.emf.common.notify.NotificationChain; - import org.eclipse.emf.common.util.EList; - import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EGenericType; import org.eclipse.emf.ecore.ETypeParameter; import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.emf.ecore.InternalEObject; - import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EValidatorRegistryImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EValidatorRegistryImpl.java index 684188a..0ec0699 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EValidatorRegistryImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EValidatorRegistryImpl.java @@ -15,7 +15,6 @@ import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EValidator; - import org.eclipse.emf.ecore.util.EObjectValidator; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EcoreFactoryImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EcoreFactoryImpl.java index c03d7fc..778752b 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EcoreFactoryImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/impl/EcoreFactoryImpl.java @@ -19,10 +19,22 @@ import java.util.Map; import org.eclipse.emf.common.util.WrappedException; -import org.eclipse.emf.ecore.*; - +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EEnum; +import org.eclipse.emf.ecore.EEnumLiteral; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EGenericType; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.ETypeParameter; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.emf.ecore.plugin.EcorePlugin; //import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/AnnotationValidatorRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/AnnotationValidatorRegistryReader.java deleted file mode 100644 index 050751c..0000000 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/AnnotationValidatorRegistryReader.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Copyright (c) 2017 Eclipse contributors 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 - */ -package org.eclipse.emf.ecore.plugin; - - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.RegistryFactory; -import org.eclipse.emf.common.CommonPlugin; -import org.eclipse.emf.common.util.WrappedException; -import org.eclipse.emf.ecore.EAnnotationValidator; - - -/** - * A plugin extension reader that populates the - * {@link org.eclipse.emf.ecore.EAnnotationValidator.Registry#INSTANCE global} annotation validator registry. - * Clients are not expected to use this class directly. - */ -class AnnotationValidatorRegistryReader extends RegistryReader -{ - static class AnnotationValidatorDescriptor extends PluginClassDescriptor implements EAnnotationValidator.Descriptor - { - protected EAnnotationValidator eAnnotationValidator; - - public AnnotationValidatorDescriptor(IConfigurationElement e, String attrName) - { - super(e, attrName); - } - - public EAnnotationValidator getEAnnotationValidator() - { - try - { - Class javaClass = CommonPlugin.loadClass(element.getDeclaringExtension().getContributor().getName(), element.getAttribute(attributeName)); - try - { - // First try to see if this class has an INSTANCE field - // - Field field = javaClass.getField("INSTANCE"); - Object result = field.get(null); - return (EAnnotationValidator)result; - } - catch (NoSuchFieldError e) - { - // If not, create a new instance. - return (EAnnotationValidator) javaClass.getDeclaredConstructor().newInstance(); - } - } - catch (ClassNotFoundException e) - { - throw new WrappedException(e); - } - catch (IllegalAccessException e) - { - throw new WrappedException(e); - } - catch (NoSuchFieldException 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); - } - } - } - - static final String TAG_VALIDATOR = "validator"; - - static final String ATT_URI = "uri"; - - static final String ATT_CLASS = "class"; - - public AnnotationValidatorRegistryReader() - { - super(RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.ANNOTATION_VALIDATOR_PPID); - } - - @Override - protected boolean readElement(IConfigurationElement element, boolean add) - { - if (element.getName().equals(TAG_VALIDATOR)) - { - 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 = EAnnotationValidator.Registry.INSTANCE.put(uri, new AnnotationValidatorDescriptor(element, ATT_CLASS)); - if (previous instanceof AnnotationValidatorDescriptor) - { - AnnotationValidatorDescriptor descriptor = (AnnotationValidatorDescriptor)previous; - EcorePlugin.INSTANCE.log( - "Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register an annotation validator for '" + uri + "'"); - } - return true; - } - else - { - EAnnotationValidator.Registry.INSTANCE.remove(uri); - return true; - } - } - - return false; - } -} \ No newline at end of file diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ContentHandlerRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ContentHandlerRegistryReader.java deleted file mode 100644 index 45829e4..0000000 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ContentHandlerRegistryReader.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (c) 2007-2010 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.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.RegistryFactory; - -import org.eclipse.emf.common.CommonPlugin; -import org.eclipse.emf.ecore.resource.ContentHandler; - - -/** - * 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#getContentTypeToFactoryMap() content type} map. - * Clients are not expected to use this class directly. - */ -class ContentHandlerRegistryReader extends RegistryReader -{ - static final String TAG_HANDLER = "contentHandler"; - static final String ATT_CLASS = "class"; - static final String ATT_PRIORITY = "priority"; - - public ContentHandlerRegistryReader() - { - super - (RegistryFactory.getRegistry(), - EcorePlugin.INSTANCE.getSymbolicName(), - EcorePlugin.CONTENT_HANDLER_PPID); - } - - private static final Map> CONTRIBUTION_MAP = new HashMap>(); - - @Override - protected boolean readElement(IConfigurationElement element, boolean add) - { - if (element.getName().equals(TAG_HANDLER)) - { - int priority = 0; - if (element.getAttribute(ATT_PRIORITY) != null) - { - priority = Integer.parseInt(element.getAttribute(ATT_PRIORITY)); - } - String contributorClassName = element.getAttribute(ATT_CLASS); - if (contributorClassName == null) - { - logMissingAttribute(element, ATT_CLASS); - } - else - { - String contributorName = element.getContributor().getName(); - if (add) - { - try - { - @SuppressWarnings("unchecked") - Class contributorHandlerClass = (Class)CommonPlugin.loadClass(element.getNamespaceIdentifier(), contributorClassName); - Map parameters = new HashMap(); - for (IConfigurationElement parameter : element.getChildren("parameter")) - { - parameters.put(parameter.getAttribute("name"), parameter.getAttribute("value")); - } - ContentHandler contentHandler = - parameters.isEmpty() ? - contributorHandlerClass.getDeclaredConstructor().newInstance() : - contributorHandlerClass.getConstructor(Map.class).newInstance(parameters); - ContentHandler.Registry.INSTANCE.put(priority, contentHandler); - List contributions = CONTRIBUTION_MAP.get(contributorName); - if (contributions == null) - { - CONTRIBUTION_MAP.put(contributorName, contributions = new ArrayList()); - } - contributions.add(contentHandler); - } - catch (Exception exception) - { - EcorePlugin.INSTANCE.log(exception); - } - return true; - } - else - { - List contributions = CONTRIBUTION_MAP.get(contributorName); - if (contributions != null) - { - for (List values : ContentHandler.Registry.INSTANCE.values()) - { - values.removeAll(contributions); - } - } - CONTRIBUTION_MAP.remove(contributorName); - return true; - } - } - } - else if (element.getName().equals("parameter")) - { - return true; - } - - return false; - } -} diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ContentParserRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ContentParserRegistryReader.java deleted file mode 100644 index 85a3eee..0000000 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ContentParserRegistryReader.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 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.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#getContentTypeToFactoryMap() content type} map. - * Clients are not expected to use this class directly. - */ -class ContentParserRegistryReader extends RegistryReader -{ - static final String TAG_PARSER = "parser"; - static final String ATT_CONTENT_TYPE_IDENTIFIER = "contentTypeIdentifier"; - static final String ATT_CLASS = "class"; - - public ContentParserRegistryReader() - { - super - (RegistryFactory.getRegistry(), - EcorePlugin.INSTANCE.getSymbolicName(), - EcorePlugin.CONTENT_PARSER_PPID); - } - - @Override - protected boolean readElement(IConfigurationElement element, boolean add) - { - if (element.getName().equals(TAG_PARSER)) - { - String contentTypeIdentifier = element.getAttribute(ATT_CONTENT_TYPE_IDENTIFIER); - if (contentTypeIdentifier == null) - { - logMissingAttribute(element, ATT_CONTENT_TYPE_IDENTIFIER); - } - else if (element.getAttribute(ATT_CLASS) == null) - { - logMissingAttribute(element, ATT_CLASS); - } - else if (add) - { - Object previous = Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().put(contentTypeIdentifier, 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 content parser for '" + contentTypeIdentifier + "'"); - } - return true; - } - else - { - Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().remove(contentTypeIdentifier); - return true; - } - } - - return false; - } -} diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ConversionDelegateFactoryRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ConversionDelegateFactoryRegistryReader.java deleted file mode 100644 index 4928936..0000000 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/ConversionDelegateFactoryRegistryReader.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2011 Hallvard Traetteberg 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: - * Hallvard Traetteberg - 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.EDataType; - - -/** - * A plugin extension reader that populates the - * {@link org.eclipse.emf.ecore.EDataType.Internal.ConversionDelegate.Factory.Registry#INSTANCE global} EDataType delegate factory registry. - * Clients are not expected to use this class directly. - */ -class ConversionDelegateFactoryRegistryReader extends RegistryReader -{ - static class ConversionDelegateFactoryDescriptor extends PluginClassDescriptor implements EDataType.Internal.ConversionDelegate.Factory.Descriptor - { - protected EDataType.Internal.ConversionDelegate.Factory factory; - - public ConversionDelegateFactoryDescriptor(IConfigurationElement e, String attrName) - { - super(e, attrName); - } - - public EDataType.Internal.ConversionDelegate.Factory getFactory() - { - if (factory == null) - { - factory = (EDataType.Internal.ConversionDelegate.Factory)createInstance(); - } - return factory; - } - } - - static final String TAG_FACTORY = "factory"; - static final String ATT_URI = "uri"; - static final String ATT_CLASS = "class"; - - public ConversionDelegateFactoryRegistryReader() - { - super(RegistryFactory.getRegistry(), EcorePlugin.INSTANCE.getSymbolicName(), EcorePlugin.CONVERSION_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 = EDataType.Internal.ConversionDelegate.Factory.Registry.INSTANCE.put(uri, new ConversionDelegateFactoryDescriptor(element, ATT_CLASS)); - if (previous instanceof ConversionDelegateFactoryDescriptor) - { - ConversionDelegateFactoryDescriptor descriptor = (ConversionDelegateFactoryDescriptor)previous; - EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a conversion delegate factory for '" + uri + "'"); - } - return true; - } - else - { - EDataType.Internal.ConversionDelegate.Factory.Registry.INSTANCE.remove(uri); - return true; - } - } - - return false; - } -} diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/DynamicPackageRegistryReader.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/DynamicPackageRegistryReader.java deleted file mode 100644 index e5f8c77..0000000 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/DynamicPackageRegistryReader.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2008 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.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 DynamicPackageRegistryReader extends RegistryReader -{ - static final String TAG_RESOURCE = "resource"; - static final String ATT_URI = "uri"; - static final String ATT_LOCATION = "location"; - - public DynamicPackageRegistryReader() - { - super - (RegistryFactory.getRegistry(), - EcorePlugin.INSTANCE.getSymbolicName(), - EcorePlugin.DYNAMIC_PACKAGE_PPID); - } - - @Override - protected boolean readElement(IConfigurationElement element, boolean add) - { - if (element.getName().equals(TAG_RESOURCE)) - { - String packageURI = element.getAttribute(ATT_URI); - if (packageURI == null) - { - logMissingAttribute(element, ATT_URI); - } - else if (element.getAttribute(ATT_LOCATION) == null) - { - logMissingAttribute(element, ATT_LOCATION); - } - else if (add) - { - Object previous = EPackage.Registry.INSTANCE.put(packageURI, new EPackageDescriptor.Dynamic(element, ATT_LOCATION)); - 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 + "'"); - } - - return true; - } - else - { - EPackage.Registry.INSTANCE.remove(packageURI); - return true; - } - } - - return false; - } -} diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/EcorePlugin.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/EcorePlugin.java index 1654121..779a548 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/EcorePlugin.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/plugin/EcorePlugin.java @@ -10,59 +10,13 @@ */ package org.eclipse.emf.ecore.plugin; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Method; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Enumeration; import java.util.HashMap; -import java.util.HashSet; -import java.util.List; import java.util.Map; -import java.util.PropertyResourceBundle; -import java.util.ResourceBundle; -import java.util.jar.JarFile; -import java.util.jar.Manifest; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.zip.ZipEntry; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.ContributorFactorySimple; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IContributor; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.RegistryFactory; -import org.eclipse.core.runtime.spi.IRegistryProvider; -import org.eclipse.core.runtime.spi.RegistryStrategy; -import org.eclipse.emf.common.CommonPlugin; import org.eclipse.emf.common.EMFPlugin; import org.eclipse.emf.common.util.ResourceLocator; import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.common.util.WrappedException; import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.impl.EPackageRegistryImpl; -import org.eclipse.emf.ecore.resource.URIConverter; /** @@ -84,150 +38,6 @@ private EcorePlugin() super(new ResourceLocator[] {}); } - @Override - public ResourceLocator getPluginResourceLocator() - { - return plugin; - } - - /** - * Returns the platform resource map. - *

- * This map is from {@link String} to {@link URI}. - * It is the logical equivalent of the map implied by an {@link IWorkspaceRoot}: - * I.e., each entry in the map corresponds to - * an {@link org.eclipse.core.resources.IProject} - * that has a {@link org.eclipse.core.resources.IResource#getName name} - * and a location {@link org.eclipse.core.resources.IResource#getLocation location}; - * the name is the key - * and the location, interpreted as a {@link URI#createFileURI file URI}, is the value. - * This map is used to {@link #resolvePlatformResourcePath resolve} a platform resource path, - * and thereby supports relocatable projects in a manner that is transparently the same as an Eclipse workspace. - *

- * @return the platform resource map. - * @see #resolvePlatformResourcePath - */ - public static Map getPlatformResourceMap() - { - if (platformResourceMap == null) - { - platformResourceMap = new HashMap(); - } - return platformResourceMap; - } - - /** - * Resolves a platform resource path of the form "/project/path" - * against the platform resource map. - *

- * The first segment of the path, i.e., the project name, - * is used to get a URI from the {@link #getPlatformResourceMap() map}. - * If a URI results, the remaining segments are {@link URI#resolve(URI) resolved} against it - * and that is the result. - * Otherwise, the result is null. - * For example, given this mapping - *

-   *  EcoreUtil.getPlatformResourceMap().put
-   *    ("project", URI.createURI("file:///C:/location/"));
-   *
- * the following transformation would result: - *
-   *  /project/directory/file
-   *    ->
-   *  file:///C:/location/directory/file
-   *
- *

- * @return the resolved URI or null. - */ - public static URI resolvePlatformResourcePath(String platformResourcePath) - { - if (platformResourceMap != null) - { - int index = platformResourcePath.indexOf("/", 1); - String rootContainerName = platformResourcePath.substring(1, index); - String relativeName = platformResourcePath.substring(index + 1); - URI rootContainerLocation = getPlatformResourceMap().get(rootContainerName); - if (rootContainerLocation != null) - { - return URI.createURI(relativeName).resolve(rootContainerLocation); - } - } - return null; - } - - /** - * Handles recognized platform resource arguments and returns the stripped result. - *

- * Recognized arguments are of this form: - *

-   *  -platformResource ( <project-name> <file-or-URI> )+
-   *
- * E.g., This these arguments - *
-   *  -platformResource project file:///C:/location/
-   *
- * will produce this effect: - *
-   *  EcoreUtil.getPlatformResourceMap().put
-   *    ("project", URI.createURI("file:///C:/location/"));
-   *
- * This mechanism supports relocatable projects outside of Eclipse. - *

- * @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: - *

-      result.putAll(computePlatformPluginToPlatformResourceMap());
-      result.putAll(computePlatformResourceToPlatformPluginMap(new HashSet(EcorePlugin.getEPackageNsURIToGenModelLocationMap(false).values())));
-   *
- * 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: - *

-   *  resourceSet.getURIConverter().getURIMap().putAll(EcorePlugin.computePlatformURIMap(true));
-   *
- * 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: - *

-     *  <extension point="org.eclipse.emf.ecore.generated_package" >
-     *      <package uri="http://www.example.org/abc/Abc.ecore" class="org.example.abc.AbcPackage"/>
-     *  <extension>
-     *
- *

- * The URI is arbitrary but an absolute URI is recommended. - * Provision for access to the serialized model via "http:" is encouraged. - *

- * The {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#INSTANCE global} resource factory registry's - * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getExtensionToFactoryMap() extension} map - * is populated by plugin registration of the form: - *

-     *  <extension point="org.eclipse.emf.ecore.extension_parser">
-     *      <parser type="abc" class="org.example.abc.util.AbcResourceFactoryImpl"/>
-     *  <extension>
-     *
- *

- *

- * The {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#INSTANCE global} resource factory registry's - * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getProtocolToFactoryMap() protocol} map - * is populated by plugin registration of the form: - *

-     *  <extension point="org.eclipse.emf.ecore.protocol_parser" >
-     *      <parser protocolName="abc" class="org.example.abc.util.AbcResourceFactoryImpl"/>
-     *  <extension>
-     *
- *

- *

- * The {@link org.eclipse.emf.ecore.resource.URIConverter#URI_MAP global} URI map - * is populated by plugin registration of the form: - *

-     *  <extension point="org.eclipse.emf.ecore.uri_mapping" >
-     *      <mapping source="//special/" target="special/"/>
-     *  <extension>
-     *
- * If the target is relative, it is resolved against the plugin's installed location, - * resulting in a URI of the form: - *
-     *  platform:/plugin/plugin-name_1.2.3/...
-     *
- * The above registration would map - *
-     *  //special/a/b.c
-     *
- * to - *
-     *  platform:/plugin/plugin-name_1.2.3/special/a/b.c
-     *
- *

- * @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 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., - *

-   *  file:///C:/directory/file
-   *    ->
-   *   C:/directory/file
-   *
- * 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., - *
-   *  platform:/resource/project/directory/file 
-   *    ->
-   *  /project/directory/file 
-   *
- * 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., - *

-   *  file:///C:/directory/file
-   *    ->
-   *   C:/directory/file
-   *
- * 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., - *
-   *  platform:/resource/project/directory/file 
-   *    ->
-   *  /project/directory/file 
-   *
- * 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: *

@@ -330,18 +330,6 @@ else if (instanceClass == Date.class) return new DateConversionDelegate(dateFormat); } } - else if (instanceClass == java.sql.Date.class) - { - if ("Long".equals(formatURI.authority())) - { - return SQLDateAsLongConversionDelegate.INSTANCE; - } - else - { - DateFormat dateFormat = getDateFormat(formatURI); - return new SQLDateConversionDelegate(dateFormat); - } - } else if (instanceClass == Calendar.class) { String calendarType = formatURI.query(); @@ -396,7 +384,7 @@ else if (instanceClass != null && XMLGregorianCalendar.class.isAssignableFrom(in AnnotationValidator.INSTANCE.throwIllegalArgumentException( AnnotationValidator.INVALID_INSTANCE_TYPE, eDataType.getInstanceTypeName(), - Arrays.asList(new Object []{ long.class, Long.class, Date.class, java.sql.Date.class, Calendar.class, XMLGregorianCalendar.class })); + Arrays.asList(new Object []{ long.class, Long.class, Date.class, Calendar.class, XMLGregorianCalendar.class })); } } @@ -1073,83 +1061,6 @@ public synchronized Object createFromString(String literal) } } - private static class SQLDateAsLongConversionDelegate implements EDataType.Internal.ConversionDelegate - { - private static final SQLDateAsLongConversionDelegate INSTANCE = new SQLDateAsLongConversionDelegate(); - - private SQLDateAsLongConversionDelegate() - { - } - - public String convertToString(Object value) - { - if (value == null) - { - return null; - } - else - { - return Long.toString(((Date)value).getTime()); - } - } - - public Object createFromString(String literal) - { - if (literal == null) - { - return null; - } - else - { - return new java.sql.Date(Long.parseLong(literal)); - } - } - } - - private static class SQLDateConversionDelegate implements EDataType.Internal.ConversionDelegate - { - private final DateFormat dateFormat; - - public SQLDateConversionDelegate(DateFormat dateFormat) - { - this.dateFormat = dateFormat; - } - - public synchronized String convertToString(Object value) - { - if (value == null) - { - return null; - } - else - { - dateFormat.setTimeZone(GMT); - return dateFormat.format(value); - } - } - - public synchronized Object createFromString(String literal) - { - if (literal == null) - { - return null; - } - else - { - try - { - dateFormat.setTimeZone(GMT); - Date date = dateFormat.parse(literal); - return new java.sql.Date(date.getTime()); - } - catch (ParseException exception) - { - throw new IllegalArgumentException(exception); - } - } - } - } - private static class CalendarAsLongConversionDelegate implements EDataType.Internal.ConversionDelegate { private final CalendarBuilder calendarBuilder; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/Diagnostician.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/Diagnostician.java index 7c6b081..72ea010 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/Diagnostician.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/Diagnostician.java @@ -22,14 +22,12 @@ import org.eclipse.emf.common.util.Diagnostic; import org.eclipse.emf.common.util.DiagnosticChain; import org.eclipse.emf.common.util.TreeIterator; - -import org.eclipse.emf.ecore.EValidator; - import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EDataType; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EValidator; import org.eclipse.emf.ecore.plugin.EcorePlugin; /** diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EObjectValidator.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EObjectValidator.java index 7976dc0..4e496c4 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EObjectValidator.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EObjectValidator.java @@ -11,6 +11,8 @@ package org.eclipse.emf.ecore.util; +import java.lang.reflect.Array; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -20,16 +22,12 @@ import java.util.ListIterator; import java.util.Map; -import java.lang.reflect.Array; -import java.math.BigDecimal; - import org.eclipse.emf.common.util.BasicDiagnostic; import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.Diagnostic; import org.eclipse.emf.common.util.DiagnosticChain; import org.eclipse.emf.common.util.EMap; import org.eclipse.emf.common.util.ResourceLocator; - import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EDataType; @@ -41,12 +39,9 @@ import org.eclipse.emf.ecore.EValidator; import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.emf.ecore.InternalEObject; - import org.eclipse.emf.ecore.plugin.EcorePlugin; - import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; - import org.eclipse.emf.ecore.xml.type.XMLTypePackage; import org.eclipse.emf.ecore.xml.type.util.XMLTypeUtil; @@ -176,7 +171,7 @@ protected static EValidator.ValidationDelegate.Registry getValidationDelegateReg } } - return EValidator.ValidationDelegate.Registry.INSTANCE; + return null; } /** diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreAdapterFactory.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreAdapterFactory.java index 34dc6ac..8001aaf 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreAdapterFactory.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreAdapterFactory.java @@ -16,8 +16,26 @@ import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.Notifier; import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; -import org.eclipse.emf.ecore.*; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EEnum; +import org.eclipse.emf.ecore.EEnumLiteral; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EGenericType; +import org.eclipse.emf.ecore.EModelElement; +import org.eclipse.emf.ecore.ENamedElement; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.ETypeParameter; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.EcorePackage; /** diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreAnnotationValidator.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreAnnotationValidator.java index fce5637..540e488 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreAnnotationValidator.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreAnnotationValidator.java @@ -248,7 +248,6 @@ private static abstract class PropertySwitch extends EcoreSwitch (EAttribute)ANNOTATION_PACKAGE_CLASS.getEStructuralFeature("invocationDelegates"), EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.keySet()); VALID_KEYS.put((EAttribute)ANNOTATION_PACKAGE_CLASS.getEStructuralFeature("conversionDelegates"), EDataType.Internal.ConversionDelegate.Factory.Registry.INSTANCE.keySet()); - VALID_KEYS.put((EAttribute)ANNOTATION_PACKAGE_CLASS.getEStructuralFeature("queryDelegates"), QueryDelegate.Factory.Registry.INSTANCE.keySet()); ANNOTATION_CLASSIFIER_CLASS = (EClass)ePackage.getEClassifier("Classifier"); @@ -332,7 +331,6 @@ public static Set getValidKeys(EAttribute attribute, Map validKeys.put( (EAttribute)ANNOTATION_PACKAGE_CLASS.getEStructuralFeature("conversionDelegates"), EDataType.Internal.ConversionDelegate.Factory.Registry.INSTANCE.getTargetPlatformFactories()); - validKeys.put((EAttribute)ANNOTATION_PACKAGE_CLASS.getEStructuralFeature("queryDelegates"), QueryDelegate.Factory.Registry.INSTANCE.getTargetPlatformFactories()); if (context != null) { diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreSwitch.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreSwitch.java index 09ca323..45b4022 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreSwitch.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreSwitch.java @@ -13,9 +13,26 @@ import java.util.Map; -import org.eclipse.emf.ecore.*; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EEnum; +import org.eclipse.emf.ecore.EEnumLiteral; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EGenericType; +import org.eclipse.emf.ecore.EModelElement; +import org.eclipse.emf.ecore.ENamedElement; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.ETypeParameter; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.EcorePackage; /** diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreValidator.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreValidator.java index 78c1c6a..2efbe54 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreValidator.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/EcoreValidator.java @@ -14,7 +14,6 @@ import java.lang.reflect.InvocationTargetException; import java.math.BigDecimal; import java.math.BigInteger; - import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -35,13 +34,31 @@ import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.common.util.UniqueEList; - -import org.eclipse.emf.ecore.*; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EAnnotationValidator; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EEnum; +import org.eclipse.emf.ecore.EEnumLiteral; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EGenericType; +import org.eclipse.emf.ecore.EModelElement; +import org.eclipse.emf.ecore.ENamedElement; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.ETypeParameter; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.emf.ecore.plugin.EcorePlugin; - import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; - import org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage; import org.eclipse.emf.ecore.xml.type.XMLTypePackage; import org.eclipse.emf.ecore.xml.type.util.XMLTypeValidator; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/InternalEList.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/InternalEList.java index c2593eb..36052bc 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/InternalEList.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/InternalEList.java @@ -18,9 +18,6 @@ import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.ETypedElement; /** diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/QueryDelegate.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/QueryDelegate.java index 1bf0bc1..c0af62f 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/QueryDelegate.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/QueryDelegate.java @@ -12,9 +12,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.Map; -import java.util.Set; -import org.eclipse.emf.common.CommonPlugin; import org.eclipse.emf.ecore.EClassifier; @@ -48,62 +46,6 @@ interface Descriptor { Factory getFactory(); } - - /** - * A registry of query delegate factories. - * @noimplement Do not implement this interface directly; instead extend {@link Impl}. - */ - interface Registry extends Map - { - Registry INSTANCE = new Impl(); - - Factory getFactory(String uri); - - /** - * Returns the factories registered in the target platform when running with the Eclipse Plug-in Development environment, - * a copy of the {@link #keySet()} otherwise. - * @since 2.14 - */ - Set getTargetPlatformFactories(); - - class Impl extends CommonPlugin.SimpleTargetPlatformRegistryImpl implements Registry - { - private static final long serialVersionUID = 1L; - - public Set getTargetPlatformFactories() - { - return getTargetPlatformValues("org.eclipse.emf.ecore.query_delegate", "uri"); - } - - @Override - protected String createKey(String attribute) - { - return attribute; - } - - @Override - public Object get(Object key) - { - Object factory = super.get(key); - if (factory instanceof Descriptor) - { - Descriptor factoryDescriptor = (Descriptor)factory; - factory = factoryDescriptor.getFactory(); - put((String)key, factory); - return factory; - } - else - { - return factory; - } - } - - public Factory getFactory(String uri) - { - return (Factory)get(uri); - } - } - } } /** diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/Switch.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/Switch.java index 59e5256..7498c93 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/Switch.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/util/Switch.java @@ -13,7 +13,6 @@ import java.util.List; import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/XMLTypeFactory.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/XMLTypeFactory.java index 9e23d63..febb16d 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/XMLTypeFactory.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/XMLTypeFactory.java @@ -12,7 +12,6 @@ import java.math.BigDecimal; import java.math.BigInteger; - import java.util.List; import javax.xml.datatype.Duration; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/ProcessingInstructionImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/ProcessingInstructionImpl.java index 2e7a113..e2431f8 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/ProcessingInstructionImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/ProcessingInstructionImpl.java @@ -11,11 +11,8 @@ package org.eclipse.emf.ecore.xml.type.impl; import org.eclipse.emf.common.notify.Notification; - import org.eclipse.emf.ecore.EClass; - import org.eclipse.emf.ecore.impl.ENotificationImpl; - import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; import org.eclipse.emf.ecore.xml.type.ProcessingInstruction; import org.eclipse.emf.ecore.xml.type.XMLTypePackage; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/XMLTypeDocumentRootImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/XMLTypeDocumentRootImpl.java index a43bb11..bd6e929 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/XMLTypeDocumentRootImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/XMLTypeDocumentRootImpl.java @@ -12,6 +12,7 @@ import java.util.Collection; + import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.EMap; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/XMLTypeFactoryImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/XMLTypeFactoryImpl.java index f8b45c7..b8f729a 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/XMLTypeFactoryImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/XMLTypeFactoryImpl.java @@ -26,19 +26,24 @@ import javax.xml.datatype.Duration; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; + import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EDataType; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; - import org.eclipse.emf.ecore.impl.EFactoryImpl; import org.eclipse.emf.ecore.plugin.EcorePlugin; - -import org.eclipse.emf.ecore.xml.type.*; -import org.eclipse.emf.ecore.xml.type.internal.XMLCalendar; -import org.eclipse.emf.ecore.xml.type.internal.XMLDuration; +import org.eclipse.emf.ecore.xml.type.AnyType; +import org.eclipse.emf.ecore.xml.type.InvalidDatatypeValueException; +import org.eclipse.emf.ecore.xml.type.ProcessingInstruction; +import org.eclipse.emf.ecore.xml.type.SimpleAnyType; +import org.eclipse.emf.ecore.xml.type.XMLTypeDocumentRoot; +import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; import org.eclipse.emf.ecore.xml.type.internal.DataValue.Base64; import org.eclipse.emf.ecore.xml.type.internal.DataValue.HexBin; +import org.eclipse.emf.ecore.xml.type.internal.XMLCalendar; +import org.eclipse.emf.ecore.xml.type.internal.XMLDuration; /** * diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/XMLTypePackageImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/XMLTypePackageImpl.java index 0f15e8e..dc3e47d 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/XMLTypePackageImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/impl/XMLTypePackageImpl.java @@ -18,13 +18,13 @@ import javax.xml.datatype.Duration; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; + import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EDataType; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EValidator; - import org.eclipse.emf.ecore.impl.EPackageImpl; import org.eclipse.emf.ecore.xml.type.AnyType; import org.eclipse.emf.ecore.xml.type.ProcessingInstruction; @@ -32,8 +32,6 @@ import org.eclipse.emf.ecore.xml.type.XMLTypeDocumentRoot; import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; import org.eclipse.emf.ecore.xml.type.XMLTypePackage; - - import org.eclipse.emf.ecore.xml.type.util.XMLTypeValidator; /** diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/internal/XMLDuration.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/internal/XMLDuration.java index 236062e..c8a42f0 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/internal/XMLDuration.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/internal/XMLDuration.java @@ -75,8 +75,8 @@ import java.util.Calendar; import javax.xml.datatype.DatatypeConstants; -import javax.xml.datatype.Duration; import javax.xml.datatype.DatatypeConstants.Field; +import javax.xml.datatype.Duration; import org.eclipse.emf.ecore.xml.type.util.XMLTypeUtil; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/util/XMLTypeResourceImpl.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/util/XMLTypeResourceImpl.java index 2816772..ccece5e 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/util/XMLTypeResourceImpl.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/util/XMLTypeResourceImpl.java @@ -12,24 +12,20 @@ import java.math.BigDecimal; import java.math.BigInteger; - - import java.util.List; + import javax.xml.datatype.Duration; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; import org.eclipse.emf.common.util.URI; - import org.eclipse.emf.ecore.resource.impl.ResourceImpl; - import org.eclipse.emf.ecore.xml.type.AnyType; import org.eclipse.emf.ecore.xml.type.ProcessingInstruction; import org.eclipse.emf.ecore.xml.type.SimpleAnyType; import org.eclipse.emf.ecore.xml.type.XMLTypeDocumentRoot; import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; // import org.eclipse.emf.ecore.xml.type.XMLTypePackage; - import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/util/XMLTypeUtil.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/util/XMLTypeUtil.java index 5dbc7bb..df64cff 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/util/XMLTypeUtil.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/util/XMLTypeUtil.java @@ -16,7 +16,6 @@ import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.Duration; import javax.xml.datatype.XMLGregorianCalendar; - import javax.xml.namespace.QName; import org.eclipse.emf.ecore.EValidator; diff --git a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/util/XMLTypeValidator.java b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/util/XMLTypeValidator.java index f9f0109..ba73ebc 100644 --- a/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/util/XMLTypeValidator.java +++ b/org.eclipse.emf.ecore/src/main/java/org/eclipse/emf/ecore/xml/type/util/XMLTypeValidator.java @@ -12,7 +12,6 @@ import java.math.BigDecimal; import java.math.BigInteger; - import java.util.Iterator; import java.util.List; import java.util.Map; @@ -23,16 +22,17 @@ import org.eclipse.emf.common.util.Diagnostic; import org.eclipse.emf.common.util.DiagnosticChain; - import org.eclipse.emf.common.util.ResourceLocator; import org.eclipse.emf.ecore.EDataType; import org.eclipse.emf.ecore.EPackage; - import org.eclipse.emf.ecore.plugin.EcorePlugin; import org.eclipse.emf.ecore.util.EObjectValidator; import org.eclipse.emf.ecore.util.ExtendedMetaData; - -import org.eclipse.emf.ecore.xml.type.*; +import org.eclipse.emf.ecore.xml.type.AnyType; +import org.eclipse.emf.ecore.xml.type.ProcessingInstruction; +import org.eclipse.emf.ecore.xml.type.SimpleAnyType; +import org.eclipse.emf.ecore.xml.type.XMLTypeDocumentRoot; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; /** *