1 17 package org.eclipse.emf.mapping.ecore2xml.impl; 18 19 import java.util.HashMap ; 20 21 import org.eclipse.emf.ecore.xmi.XMLResource; 22 import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLRegistry; 23 24 27 public class Ecore2XMLRegistryImpl extends HashMap implements Ecore2XMLRegistry 28 { 29 30 protected Ecore2XMLRegistry delegateRegistry; 31 32 public Ecore2XMLRegistryImpl() 33 { 34 super(); 35 } 36 37 public Ecore2XMLRegistryImpl(Ecore2XMLRegistry delegateRegistry) 38 { 39 this(); 40 41 this.delegateRegistry = delegateRegistry; 42 } 43 44 public XMLResource.XMLMap getXMLMap(String nsURI) 45 { 46 Object value = get(nsURI); 47 48 if (value instanceof XMLResource.XMLMap) 49 { 50 return (XMLResource.XMLMap)value; 51 } 52 else if (value instanceof Ecore2XMLRegistry.Descriptor) 53 { 54 XMLResource.XMLMap xmlMap = ((Ecore2XMLRegistry.Descriptor)value).getXMLMap(); 55 put(nsURI, xmlMap); 56 57 return xmlMap; 58 } 59 else 60 { 61 return delegatedGetXMLMap(nsURI); 62 } 63 } 64 65 protected XMLResource.XMLMap delegatedGetXMLMap(String nsURI) 66 { 67 return delegateRegistry == null ? null : delegateRegistry.getXMLMap(nsURI); 68 } 69 70 public boolean containsKey(Object key) 71 { 72 return super.containsKey(key) || delegateRegistry != null && delegateRegistry.containsKey(key); 73 } 74 75 } | Popular Tags |