KickJava   Java API By Example, From Geeks To Geeks.

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


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: ProtocolParserRegistryReader.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#getProtocolToFactoryMap() protocol} map.
30  * Clients are not expected to use this class directly.
31  */

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