try { XMLBeanReader doc = new XMLBeanReader(); File prefFile = PreferenceUtil.getPreferenceFileToReadFrom(plugin); doc.load(prefFile, _prefs.getClass().getClassLoader()); Iterator<Object> it = doc.iterator(); if (it.hasNext()) { _prefs = (IQueryTokenizerPreferenceBean)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); }
try { XMLBeanReader doc = new XMLBeanReader(); File prefFile = PreferenceUtil.getPreferenceFileToReadFrom(plugin); doc.load(prefFile, MSSQLPreferenceBean.class.getClassLoader()); Iterator<?> it = doc.iterator(); if (it.hasNext()) { _prefs = (MSSQLPreferenceBean)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); }
Clone fragments detected by clone detection tool
File path: /sql12/app/src/net/sourceforge/squirrel_sql/client/plugin/PluginQueryTokenizerPreferencesManager.java File path: /sql12/plugins/mssql/src/net/sourceforge/squirrel_sql/plugins/mssql/prefs/PreferencesManager.java
Method name: void loadPrefs() Method name: void loadPrefs()
Number of AST nodes: 7 Number of AST nodes: 7
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, _prefs.getClass().getClassLoader());
6
            doc.load(prefFile, MSSQLPreferenceBean.class.getClassLoader());
7
                        
7
                        
8
            Iterator<Object> it = doc.iterator();
8
            Iterator<?> it = doc.iterator();
9
            
10
            if (it.hasNext()) {
9
            if (it.hasNext()) {
11
                _prefs = (IQueryTokenizerPreferenceBean)it.next();
10
                _prefs = (MSSQLPreferenceBean)it.next();
12
            }
11
            }
13
        } catch (FileNotFoundException ignore) {
12
        } catch (FileNotFoundException ignore) {
14
            s_log.info(USER_PREFS_FILE_NAME + " not found - will be created");
13
            s_log.info(USER_PREFS_FILE_NAME + " not found - will be created");
15
        } catch (Exception ex) {
14
        } catch (Exception ex) {
16
            s_log.error("Error occured reading from preferences file: "
15
            s_log.error("Error occured reading from preferences file: "
17
                    + USER_PREFS_FILE_NAME, ex);
16
                    + USER_PREFS_FILE_NAME, ex);
18
        }
17
        }
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.6
Clones locationClones are in different classes
Number of node comparisons29
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)3.6
    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, _prefs.getClass().getClassLoader());
    4
    doc.load(prefFile, _prefs.getClass().getClassLoader());
    4
    doc.load(prefFile, MSSQLPreferenceBean.class.getClassLoader());
    Differences
    Expression1Expression2Difference
    _prefs.getClass()MSSQLPreferenceBean.classTYPE_COMPATIBLE_REPLACEMENT
    4
    doc.load(prefFile, MSSQLPreferenceBean.class.getClassLoader());
                                                                      
    5
    Iterator<?> it = doc.iterator();
    Preondition Violations
    Unmatched statement Iterator<?> it=doc.iterator(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    Iterator<?> it = doc.iterator();
    5
    Iterator<Object> it = doc.iterator();
    5
    Iterator<Object> it = doc.iterator();
    Preondition Violations
    Unmatched statement Iterator<Object> it=doc.iterator(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                
    6
    if (it.hasNext())
    6
    if (it.hasNext())
    6
    if (it.hasNext())
    Differences
    Expression1Expression2Difference
    java.util.Iteratorjava.util.Iterator<>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Iterator<java.lang.Object> of variable it does not match with type java.util.Iterator<> of variable it
    • Make classes java.util.Iterator and java.util.Iterator<> extend a common superclass
    6
    if (it.hasNext())
    7
    _prefs = (IQueryTokenizerPreferenceBean)it.next();
    7
    _prefs = (IQueryTokenizerPreferenceBean)it.next();
    7
    _prefs = (MSSQLPreferenceBean)it.next();
    Differences
    Expression1Expression2Difference
    net.sourceforge.squirrel_sql.fw.preferences.IQueryTokenizerPreferenceBeannet.sourceforge.squirrel_sql.plugins.mssql.prefs.MSSQLPreferenceBeanSUBCLASS_TYPE_MISMATCH
    net.sourceforge.squirrel_sql.fw.preferences.IQueryTokenizerPreferenceBeannet.sourceforge.squirrel_sql.plugins.mssql.prefs.MSSQLPreferenceBeanSUBCLASS_TYPE_MISMATCH
    java.lang.ObjectVARIABLE_TYPE_MISMATCH
    java.util.Iteratorjava.util.Iterator<>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression (IQueryTokenizerPreferenceBean)it.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (MSSQLPreferenceBean)it.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression it.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression it.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.lang.Object of variable it.next() does not match with type of variable it.next()
    • Make classes java.lang.Object and extend a common superclass
    Type java.util.Iterator<java.lang.Object> of variable it does not match with type java.util.Iterator<> of variable it
    • Make classes java.util.Iterator and java.util.Iterator<> extend a common superclass
    7
    _prefs = (MSSQLPreferenceBean)it.next();
    Precondition Violations (9)
    Row Violation
    1Unmatched statement Iterator<?> it=doc.iterator(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement Iterator<Object> it=doc.iterator(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type java.util.Iterator<java.lang.Object> of variable it does not match with type java.util.Iterator<> of variable it
    4Expression (IQueryTokenizerPreferenceBean)it.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression (MSSQLPreferenceBean)it.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression it.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression it.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Type java.lang.Object of variable it.next() does not match with type of variable it.next()
    9Type java.util.Iterator<java.lang.Object> of variable it does not match with type java.util.Iterator<> of variable it