KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > mapping > ecore2xml > impl > Ecore2XMLRegistryImpl


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2005 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: Ecore2XMLRegistryImpl.java,v 1.2 2005/06/21 16:17:03 khussey Exp $
16  */

17 package org.eclipse.emf.mapping.ecore2xml.impl;
18
19 import java.util.HashMap JavaDoc;
20
21 import org.eclipse.emf.ecore.xmi.XMLResource;
22 import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLRegistry;
23
24 /**
25  *
26  */

27 public class Ecore2XMLRegistryImpl extends HashMap JavaDoc 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 JavaDoc nsURI)
45   {
46     Object JavaDoc 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 JavaDoc nsURI)
66   {
67     return delegateRegistry == null ? null : delegateRegistry.getXMLMap(nsURI);
68   }
69   
70   public boolean containsKey(Object JavaDoc key)
71   {
72     return super.containsKey(key) || delegateRegistry != null && delegateRegistry.containsKey(key);
73   }
74   
75 }
Popular Tags