class ContentParserRegistryReader extends RegistryReader { static final String TAG_PARSER = "parser"; static final String ATT_CONTENT_TYPE_IDENTIFIER = "contentTypeIdentifier"; static final String ATT_CLASS = "class"; public ContentParserRegistryReader() { super (Platform.getExtensionRegistry(), EcorePlugin.getPlugin().getBundle().getSymbolicName(), EcorePlugin.CONTENT_PARSER_PPID); } @Override protected boolean readElement(IConfigurationElement element, boolean add) { if (element.getName().equals(TAG_PARSER)) { String contentTypeIdentifier = element.getAttribute(ATT_CONTENT_TYPE_IDENTIFIER); if (contentTypeIdentifier == null) { logMissingAttribute(element, ATT_CONTENT_TYPE_IDENTIFIER); } else if (element.getAttribute(ATT_CLASS) == null) { logMissingAttribute(element, ATT_CLASS); } else if (add) { Object previous = Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().put(contentTypeIdentifier, 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 content parser for '" + contentTypeIdentifier + "'"); } return true; } else { Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().remove(contentTypeIdentifier); return true; } } return false;
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;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/plugin/ContentParserRegistryReader.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/plugin/ExtensionParserRegistryReader.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
class ContentParserRegistryReader extends RegistryReader
1
class ExtensionParserRegistryReader extends RegistryReader
2
{
2
{
3
  static final String TAG_PARSER = "parser";
3
  static final String TAG_PARSER = "parser";
4
  static final String ATT_CONTENT_TYPE_IDENTIFIER = "contentTypeIdentifier";
4
  static final String ATT_TYPE = "type";
5
  static final String ATT_CLASS = "class";
5
  static final String ATT_CLASS = "class";
6
  public ContentParserRegistryReader()
6
  public ExtensionParserRegistryReader()
7
  {
7
  {
8
    super
8
    super
9
      (Platform.getExtensionRegistry(),
9
      (Platform.getExtensionRegistry(),
10
       EcorePlugin.getPlugin().getBundle().getSymbolicName(), 
10
       EcorePlugin.getPlugin().getBundle().getSymbolicName(), 
11
       EcorePlugin.CONTENT_PARSER_PPID);
11
       EcorePlugin.EXTENSION_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 contentTypeIdentifier = element.getAttribute(ATT_CONTENT_TYPE_IDENTIFIER);
18
      String type = element.getAttribute(ATT_
19
      if (contentTypeIdentifier
19
TYPE);
20
 == null)
20
      if (type == null)
21
      {
21
      {
22
        logMissingAttribute(element, ATT_CONTENT_TYPE_IDENTIFIER);
22
        logMissingAttribute(element, ATT_TYPE);
23
      }
23
      }
24
      else if (element.getAttribute(ATT_CLASS) == null)
24
      else if (element.getAttribute(ATT_CLASS) == null)
25
      {
25
      {
26
        logMissingAttribute(element, ATT_CLASS);
26
        logMissingAttribute(element, ATT_CLASS);
27
      }
27
      }
28
      else if (add)
28
      else if (add)
29
      {
29
      {
30
        Object previous = Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().put(contentTypeIdentifier, new ResourceFactoryDescriptor(element, ATT_CLASS));
30
        Object previous = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(type, new ResourceFactoryDescriptor(element, ATT_CLASS));
31
        if (previous instanceof ResourceFactoryDescriptor)
31
        if (previous instanceof ResourceFactoryDescriptor)
32
        {
32
        {
33
          ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
33
          ResourceFactoryDescriptor descriptor = (ResourceFactoryDescriptor)previous;
34
          EcorePlugin.INSTANCE.log
34
          EcorePlugin.INSTANCE.log
35
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a content parser for '" + contentTypeIdentifier + "'");
35
            ("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register an extension parser for '" + type + "'");
36
        }
36
        }
37
        return true;
37
        return true;
38
      }
38
      }
39
      else
39
      else
40
      {
40
      {
41
        Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap().remove(contentTypeIdentifier);
41
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().remove(type);
42
        return true;
42
        return true;
43
      }
43
      }
44
    }
44
    }
45
    return false;
45
    return false;
46
  
46
  
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