class ExtensionParserRegistryReader extends RegistryReader { static final String TAG_PARSER = "parser"; static final String ATT_TYPE = "type"; static final String ATT_CLASS = "class"; public ExtensionParserRegistryReader() { super (Platform.getExtensionRegistry(), EcorePlugin.getPlugin().getBundle().getSymbolicName(), EcorePlugin.EXTENSION_PARSER_PPID); } @Override protected boolean readElement(IConfigurationElement element, boolean add) { if (element.getName().equals(TAG_PARSER)) { String type = element.getAttribute(ATT_TYPE); if (type == null) { logMissingAttribute(element, ATT_TYPE); } else if (element.getAttribute(ATT_CLASS) == null) { logMissingAttribute(element, ATT_CLASS); } else if (add) { Object previous = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS)); if (previous instanceof ResourceFactoryDescriptor) { ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous; EcorePlugin.INSTANCE.log ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register an extension parser for '" + type + "'"); } return true; } else { Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type); return true; } } return false;
class ProtocolParserRegistryReader extends RegistryReader { static final String TAG_PARSER = "parser"; static final String ATT_PROTOCOLNAME = "protocolName"; static final String ATT_CLASS = "class"; public ProtocolParserRegistryReader() { super (Platform.getExtensionRegistry(), EcorePlugin.getPlugin().getBundle().getSymbolicName(), EcorePlugin.PROTOCOL_PARSER_PPID); } @Override protected boolean readElement(IConfigurationElement element, boolean add) { if (element.getName().equals(TAG_PARSER)) { String protocolName = element.getAttribute(ATT_PROTOCOLNAME); if (protocolName == null) { logMissingAttribute(element, ATT_PROTOCOLNAME); } else if (element.getAttribute(ATT_CLASS) == null) { logMissingAttribute(element, ATT_CLASS); } else if (add) { Object previous = Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().put(protocolName, new ResourceFactoryDescriptor(element, ATT_CLASS)); if (previous instanceof ResourceFactoryDescriptor) { ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous; EcorePlugin.INSTANCE.log ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a protocol parser for '" + protocolName + "'"); } return true; } else { Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap().remove(protocolName); return true; } } return false;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/plugin/ExtensionParserRegistryReader.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/plugin/ProtocolParserRegistryReader.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
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
  
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0