1 | class ExtensionParserRegistryReader extends RegistryReader↵ | | 1 | class ProtocolParserRegistryReader extends RegistryReader↵
|
2 | {↵ | | 2 | {↵
|
3 | static final String TAG_PARSER = "parser";↵ | | 3 | static final String TAG_PARSER = "parser";↵
|
4 | static final String ATT_TYPE = "type";↵ | | 4 | static final String ATT_PROTOCOLNAME = "protocolName";↵
|
5 | static final String ATT_CLASS = "class";↵ | | 5 | static final String ATT_CLASS = "class";↵
|
|
6 | public ExtensionParserRegistryReader()↵ | | 6 | public ProtocolParserRegistryReader()↵
|
7 | {↵ | | 7 | {↵
|
8 | super↵ | | 8 | super↵
|
9 | (Platform.getExtensionRegistry(),↵ | | 9 | (Platform.getExtensionRegistry(),↵
|
10 | EcorePlugin.getPlugin().getBundle().getSymbolicName(), ↵ | | 10 | EcorePlugin.getPlugin().getBundle().getSymbolicName(), ↵
|
11 | EcorePlugin.EXTENSION_PARSER_PPID);↵ | | 11 | EcorePlugin.PROTOCOL_PARSER_PPID);↵
|
12 | }↵ | | 12 | }↵
|
|
13 | @Override↵ | | 13 | @Override↵
|
14 | protected boolean readElement(IConfigurationElement element, boolean add)↵ | | 14 | protected boolean readElement(IConfigurationElement element, boolean add)↵
|
15 | {↵ | | 15 | {↵
|
16 | if (element.getName().equals(TAG_PARSER))↵ | | 16 | if (element.getName().equals(TAG_PARSER))↵
|
17 | {↵ | | 17 | {↵
|
18 | String type = element.getAttribute(ATT_TYPE);↵ | | 18 | String protocolName = element.getAttribute(ATT_PROTOCOLNAME);↵
|
19 | if (type == null)↵ | | 19 | if (protocolName == null)↵
|
20 | {↵ | | 20 | {↵
|
21 | logMissingAttribute(element, ATT_TYPE);↵ | | 21 | logMissingAttribute(element, ATT_PROTOCOLNAME);↵
|
22 | }↵ | | 22 | }↵
|
23 | else if (element.getAttribute(ATT_CLASS) == null)↵ | | 23 | else if (element.getAttribute(ATT_CLASS) == null)↵
|
24 | {↵ | | 24 | {↵
|
25 | logMissingAttribute(element, ATT_CLASS);↵ | | 25 | logMissingAttribute(element, ATT_CLASS);↵
|
26 | }↵ | | 26 | }↵
|
27 | else if (add)↵ | | 27 | else if (add)↵
|
28 | {↵ | | 28 | {↵
|
29 | Object previous = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS));↵ | | 29 | Object previous = Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName, new ResourceFactoryDescriptor(element, ATT_CLASS));↵
|
30 | if (previous instanceof ResourceFactoryDescriptor)↵ | | 30 | if (previous instanceof ResourceFactoryDescriptor)↵
|
31 | {↵ | | 31 | {↵
|
32 | ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;↵ | | 32 | ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;↵
|
33 | EcorePlugin.INSTANCE.log↵ | | 33 | EcorePlugin.INSTANCE.log↵
|
34 | ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register an extension parser for '" + type + "'");↵ | | 34 | ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a protocol parser for '" + protocolName + "'");↵
|
35 | }↵ | | 35 | }↵
|
36 | return true;↵ | | 36 | return true;↵
|
37 | }↵ | | 37 | }↵
|
38 | else↵ | | 38 | else↵
|
39 | {↵ | | 39 | {↵
|
40 | Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type);↵ | | 40 | Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().remove(protocolName);↵
|
41 | return true;↵ | | 41 | return true;↵
|
42 | }↵ | | 42 | }↵
|
43 | }↵ | | 43 | }↵
|
|
44 | return false;↵ | | 44 | return false;↵
|
45 | | | 45 |
|