1 17 package org.eclipse.emf.ecore.resource.impl; 18 19 20 import java.util.HashMap ; 21 import java.util.Map ; 22 23 import org.eclipse.emf.common.util.URI; 24 import org.eclipse.emf.ecore.resource.Resource; 25 26 27 30 public class ResourceFactoryRegistryImpl implements Resource.Factory.Registry 31 { 32 35 protected Map protocolToFactoryMap = new HashMap (); 36 37 40 protected Map extensionToFactoryMap = new HashMap (); 41 42 45 public ResourceFactoryRegistryImpl() 46 { 47 } 48 49 61 public Resource.Factory getFactory(URI uri) 62 { 63 String protocol = uri.scheme(); 64 Object resourceFactory = protocolToFactoryMap.get(protocol); 65 if (resourceFactory == null) 66 { 67 String extension = uri.fileExtension(); 68 resourceFactory = extensionToFactoryMap.get(extension); 69 if (resourceFactory == null) 70 { 71 resourceFactory = extensionToFactoryMap.get("*"); 72 if (resourceFactory == null) 73 { 74 resourceFactory = delegatedGetFactory(uri); 75 } 76 } 77 } 78 79 return 80 resourceFactory instanceof Resource.Factory.Descriptor ? 81 ((Resource.Factory.Descriptor)resourceFactory).createFactory() : 82 (Resource.Factory)resourceFactory; 83 } 84 85 95 protected Resource.Factory delegatedGetFactory(URI uri) 96 { 97 return null; 98 } 99 100 103 public Map getExtensionToFactoryMap() 104 { 105 return extensionToFactoryMap; 106 } 107 108 111 public Map getProtocolToFactoryMap() 112 { 113 return protocolToFactoryMap; 114 } 115 } 116 | Popular Tags |