KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > plugin > ExtensionParserRegistryReader


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 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: ExtensionParserRegistryReader.java,v 1.3 2005/06/08 06:20:10 nickb Exp $
16  */

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.ecore.resource.Resource;
24
25
26 /**
27  * A plugin extension reader that populates the
28  * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#INSTANCE global} resource factory's
29  * {@link org.eclipse.emf.ecore.resource.Resource.Factory.Registry#getExtensionToFactoryMap() extension} map.
30  * Clients are not expected to use this class directly.
31  */

32 class ExtensionParserRegistryReader extends RegistryReader
33 {
34   static final String JavaDoc TAG_PARSER = "parser";
35   static final String JavaDoc ATT_TYPE = "type";
36   static final String JavaDoc ATT_CLASS = "class";
37
38   public ExtensionParserRegistryReader()
39   {
40     super
41       (Platform.getExtensionRegistry(),
42        EcorePlugin.getPlugin().getBundle().getSymbolicName(),
43        EcorePlugin.EXTENSION_PARSER_PPID);
44   }
45
46   protected boolean readElement(IConfigurationElement element)
47   {
48     if (element.getName().equals(TAG_PARSER))
49     {
50       String JavaDoc type = element.getAttribute(ATT_TYPE);
51       if (type == null)
52       {
53         logMissingAttribute(element, ATT_TYPE);
54       }
55       else if (element.getAttribute(ATT_CLASS) == null)
56       {
57         logMissingAttribute(element, ATT_CLASS);
58       }
59       else
60       {
61         Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put
62           (type, new ResourceFactoryDescriptor(element, ATT_CLASS));
63         return true;
64       }
65     }
66     return false;
67   }
68 }
69
Popular Tags