try { XMLBeanReader doc = new XMLBeanReader(); File prefFile = PreferenceUtil.getPreferenceFileToReadFrom(plugin); doc.load(prefFile, RefactoringPreferenceBean.class.getClassLoader()); Iterator<?> it = doc.iterator(); if (it.hasNext()) { _prefs = (RefactoringPreferenceBean)it.next(); } } catch (FileNotFoundException ignore) { s_log.info(USER_PREFS_FILE_NAME + " not found - will be created"); } catch (Exception ex) { s_log.error("Error occured reading from preferences file: " + USER_PREFS_FILE_NAME, ex); } if (_prefs == null) { _prefs = new RefactoringPreferenceBean(); } _prefs.setClientName(Version.getApplicationName() + "/" + plugin.getDescriptiveName()); _prefs.setClientVersion(Version.getShortVersion() + "/" + plugin.getVersion());
try { XMLBeanReader doc = new XMLBeanReader(); File prefFile = PreferenceUtil.getPreferenceFileToReadFrom(plugin); doc.load(prefFile, SQLScriptPreferenceBean.class.getClassLoader()); Iterator<?> it = doc.iterator(); if (it.hasNext()) { _prefs = (SQLScriptPreferenceBean)it.next(); } } catch (FileNotFoundException ignore) { s_log.info(USER_PREFS_FILE_NAME + " not found - will be created"); } catch (Exception ex) { s_log.error("Error occured reading from preferences file: " + USER_PREFS_FILE_NAME, ex); } if (_prefs == null) { _prefs = new SQLScriptPreferenceBean(); } _prefs.setClientName(Version.getApplicationName() + "/" + plugin.getDescriptiveName()); _prefs.setClientVersion(Version.getShortVersion() + "/" + plugin.getVersion());
Clone fragments detected by clone detection tool
File path: /sql12/plugins/refactoring/src/net/sourceforge/squirrel_sql/plugins/refactoring/prefs/RefactoringPreferencesManager.java File path: /sql12/plugins/sqlscript/src/net/sourceforge/squirrel_sql/plugins/sqlscript/prefs/SQLScriptPreferencesManager.java
Method name: void loadPrefs() Method name: void loadPrefs()
Number of AST nodes: 11 Number of AST nodes: 11
1
try {
1
try {
2
            XMLBeanReader doc = new XMLBeanReader();
2
            XMLBeanReader doc = new XMLBeanReader();
3
            
3
            
4
            File prefFile = PreferenceUtil.getPreferenceFileToReadFrom(plugin);
4
            File prefFile = PreferenceUtil.getPreferenceFileToReadFrom(plugin);
5
            
5
            
6
            doc.load(prefFile, RefactoringPreferenceBean.class.getClassLoader());            
6
            doc.load(prefFile, SQLScriptPreferenceBean.class.getClassLoader());            
7
            Iterator<?> it = doc.iterator();
7
            Iterator<?> it = doc.iterator();
8
            if (it.hasNext()) {
8
            if (it.hasNext()) {
9
                _prefs = (RefactoringPreferenceBean)it.next();
9
                _prefs = (SQLScriptPreferenceBean)it.next();
10
            }
10
            }
11
        } catch (FileNotFoundException ignore) {
11
        } catch (FileNotFoundException ignore) {
12
            s_log.info(USER_PREFS_FILE_NAME + " not found - will be created");
12
            s_log.info(USER_PREFS_FILE_NAME + " not found - will be created");
13
        } catch (Exception ex) {
13
        } catch (Exception ex) {
14
            s_log.error("Error occured reading from preferences file: "
14
            s_log.error("Error occured reading from preferences file: "
15
                    + USER_PREFS_FILE_NAME, ex);
15
                    + USER_PREFS_FILE_NAME, ex);
16
        }
16
        }
17
        if (_prefs == null) {
17
        if (_prefs == null) {
18
            _prefs = new RefactoringPreferenceBean();
18
            _prefs = new SQLScriptPreferenceBean();
19
        }
19
        }
20
        _prefs.setClientName(Version.getApplicationName() + "/" + plugin.getDescriptiveName());
20
        _prefs.setClientName(Version.getApplicationName() + "/" + plugin.getDescriptiveName());
21
        _prefs.setClientVersion(Version.getShortVersion() + "/" + plugin.getVersion());
21
        _prefs.setClientVersion(Version.getShortVersion() + "/" + plugin.getVersion());
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.7
Clones locationClones are in different classes
Number of node comparisons37
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)4.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    try
    1
    try
    2
    XMLBeanReader doc = new XMLBeanReader();
    2
    XMLBeanReader doc = new XMLBeanReader();
    3
    File prefFile = PreferenceUtil.getPreferenceFileToReadFrom(plugin);
    3
    File prefFile = PreferenceUtil.getPreferenceFileToReadFrom(plugin);
    4
    doc.load(prefFile, RefactoringPreferenceBean.class.getClassLoader());
    4
    doc.load(prefFile, RefactoringPreferenceBean.class.getClassLoader());
    4
    doc.load(prefFile, SQLScriptPreferenceBean.class.getClassLoader());
    Differences
    Expression1Expression2Difference
    RefactoringPreferenceBean.classSQLScriptPreferenceBean.classLITERAL_VALUE_MISMATCH
    4
    doc.load(prefFile, SQLScriptPreferenceBean.class.getClassLoader());
    5
    Iterator<?> it = doc.iterator();
    5
    Iterator<?> it = doc.iterator();
    6
    if (it.hasNext())
    6
    if (it.hasNext())
                                                                                              
    7
    _prefs = (SQLScriptPreferenceBean)it.next();
    Preondition Violations
    Unmatched statement _prefs=(SQLScriptPreferenceBean)it.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    _prefs = (SQLScriptPreferenceBean)it.next();
    7
    _prefs = (RefactoringPreferenceBean)it.next();
    7
    _prefs = (RefactoringPreferenceBean)it.next();
    Preondition Violations
    Unmatched statement _prefs=(RefactoringPreferenceBean)it.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                  
    8
    if (_prefs == null)
    8
    if (_prefs == null)
    8
    if (_prefs == null)
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.plugins.refactoring.prefs.RefactoringPreferenceBeannet.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferenceBeanVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type net.sourceforge.squirrel_sql.plugins.refactoring.prefs.RefactoringPreferenceBean of variable _prefs does not match with type net.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferenceBean of variable _prefs
    • Make classes net.sourceforge.squirrel_sql.plugins.refactoring.prefs.RefactoringPreferenceBean and net.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferenceBean extend a common superclass
    8
    if (_prefs == null)
                                                                                    
    9
    _prefs = new SQLScriptPreferenceBean();
    Preondition Violations
    Unmatched statement _prefs=new SQLScriptPreferenceBean(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9
    _prefs = new SQLScriptPreferenceBean();
    9
    _prefs = new RefactoringPreferenceBean();
    9
    _prefs = new RefactoringPreferenceBean();
    Preondition Violations
    Unmatched statement _prefs=new RefactoringPreferenceBean(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                        
    10
    _prefs.setClientName(Version.getApplicationName() + "/" + plugin.getDescriptiveName());
    10
    _prefs.setClientName(Version.getApplicationName() + "/" + plugin.getDescriptiveName());
    10
    _prefs.setClientName(Version.getApplicationName() + "/" + plugin.getDescriptiveName());
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.plugins.refactoring.prefs.RefactoringPreferenceBeannet.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferenceBeanVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type net.sourceforge.squirrel_sql.plugins.refactoring.prefs.RefactoringPreferenceBean of variable _prefs does not match with type net.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferenceBean of variable _prefs
    • Make classes net.sourceforge.squirrel_sql.plugins.refactoring.prefs.RefactoringPreferenceBean and net.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferenceBean extend a common superclass
    10
    _prefs.setClientName(Version.getApplicationName() + "/" + plugin.getDescriptiveName());
    11
    _prefs.setClientVersion(Version.getShortVersion() + "/" + plugin.getVersion());
    11
    _prefs.setClientVersion(Version.getShortVersion() + "/" + plugin.getVersion());
    11
    _prefs.setClientVersion(Version.getShortVersion() + "/" + plugin.getVersion());
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.plugins.refactoring.prefs.RefactoringPreferenceBeannet.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferenceBeanVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type net.sourceforge.squirrel_sql.plugins.refactoring.prefs.RefactoringPreferenceBean of variable _prefs does not match with type net.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferenceBean of variable _prefs
    • Make classes net.sourceforge.squirrel_sql.plugins.refactoring.prefs.RefactoringPreferenceBean and net.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferenceBean extend a common superclass
    11
    _prefs.setClientVersion(Version.getShortVersion() + "/" + plugin.getVersion());
    Precondition Violations (7)
    Row Violation
    1Unmatched statement _prefs=(SQLScriptPreferenceBean)it.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement _prefs=(RefactoringPreferenceBean)it.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type net.sourceforge.squirrel_sql.plugins.refactoring.prefs.RefactoringPreferenceBean of variable _prefs does not match with type net.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferenceBean of variable _prefs
    4Unmatched statement _prefs=new SQLScriptPreferenceBean(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement _prefs=new RefactoringPreferenceBean(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Type net.sourceforge.squirrel_sql.plugins.refactoring.prefs.RefactoringPreferenceBean of variable _prefs does not match with type net.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferenceBean of variable _prefs
    7Type net.sourceforge.squirrel_sql.plugins.refactoring.prefs.RefactoringPreferenceBean of variable _prefs does not match with type net.sourceforge.squirrel_sql.plugins.sqlscript.prefs.SQLScriptPreferenceBean of variable _prefs