1 17 package org.eclipse.emf.ecore.plugin; 18 19 20 import org.eclipse.core.runtime.IConfigurationElement; 21 import org.eclipse.core.runtime.Platform; 22 23 import org.eclipse.emf.common.util.URI; 24 import org.eclipse.emf.ecore.resource.URIConverter; 25 26 27 32 class URIMappingRegistryReader extends RegistryReader 33 { 34 static final String TAG_MAPPING = "mapping"; 35 static final String ATT_SOURCE = "source"; 36 static final String ATT_TARGET = "target"; 37 38 public URIMappingRegistryReader() 39 { 40 super 41 (Platform.getExtensionRegistry(), 42 EcorePlugin.getPlugin().getBundle().getSymbolicName(), 43 EcorePlugin.URI_MAPPING_PPID); 44 } 45 46 protected boolean readElement(IConfigurationElement element) 47 { 48 if (element.getName().equals(TAG_MAPPING)) 49 { 50 String sourceURIValue = element.getAttribute(ATT_SOURCE); 51 if (sourceURIValue == null) 52 { 53 logMissingAttribute(element, ATT_SOURCE); 54 } 55 else 56 { 57 String targetURIValue = element.getAttribute(ATT_TARGET); 58 if (targetURIValue == null) 59 { 60 logMissingAttribute(element, ATT_TARGET); 61 } 62 else 63 { 64 URI sourceURI = URI.createURI(sourceURIValue); 65 URI targetURI = URI.createURI(targetURIValue); 66 if (targetURI.isRelative() && targetURI.hasRelativePath()) 67 { 68 targetURI = 69 targetURI.resolve 70 (URI.createURI 71 (Platform.getBundle(element.getDeclaringExtension().getNamespace()).getEntry("/").toString())); 72 } 73 URIConverter.URI_MAP.put(sourceURI, targetURI); 74 return true; 75 } 76 } 77 } 78 return false; 79 } 80 } 81 | Popular Tags |