/** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. */ package org.sintef.thingml.resource.thingml.mopp; public class ThingmlResourceFactoryDelegator implements org.eclipse.emf.ecore.resource.Resource.Factory { protected java.util.Map<String, org.eclipse.emf.ecore.resource.Resource.Factory> factories = null; public ThingmlResourceFactoryDelegator() { init(); } protected void init() { if (factories == null) { factories = new java.util.LinkedHashMap<String, org.eclipse.emf.ecore.resource.Resource.Factory>(); } if (new org.sintef.thingml.resource.thingml.util.ThingmlRuntimeUtil().isEclipsePlatformAvailable()) { new org.sintef.thingml.resource.thingml.util.ThingmlEclipseProxy().getResourceFactoryExtensions(factories); } if (factories.get("") == null) { factories.put("", new org.sintef.thingml.resource.thingml.mopp.ThingmlResourceFactory()); } } public java.util.Map<String, org.eclipse.emf.ecore.resource.Resource.Factory> getResourceFactoriesMap() { return factories; } public org.eclipse.emf.ecore.resource.Resource.Factory getFactoryForURI(org.eclipse.emf.common.util.URI uri) { org.eclipse.emf.common.util.URI trimmedURI = uri.trimFileExtension(); String secondaryFileExtension = trimmedURI.fileExtension(); org.eclipse.emf.ecore.resource.Resource.Factory factory = factories.get(secondaryFileExtension); if (factory == null) { factory = factories.get(""); } return factory; } public org.eclipse.emf.ecore.resource.Resource createResource(org.eclipse.emf.common.util.URI uri) { return getFactoryForURI(uri).createResource(uri); } }