/** * Returns the elements of the right-hand "selected" list. Note * that these are not the elements selected (ie highlighted) in the * Swing sense, but rather the entire contents of the list containing * the user selections. * * @return a Vector of selected elements. */ public Vector getSelected() { Vector result = new Vector(); ListModel list = selectedList.getModel(); for (int i = 0; i < list.getSize(); i++) { result.add(list.getElementAt(i)); } return result; }
/** * Returns the choices a user can make. * @return List of choices */ private List getChoices() { List result = new ArrayList(); for (int index : choicesList.getSelectedIndices()) { result.add(choicesList.getModel().getElementAt(index)); } return result; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/ui/UMLAddDialog.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/ui/UMLAddDialog.java
Method name: Vector getSelected() Method name: List getChoices()
Number of AST nodes: 2 Number of AST nodes: 2
1
/**
1
/**
2
     * Returns the elements of the right-hand "selected" list.  Note
2
     * Returns the choices a user can make.
3
     * that these are not the elements selected (ie highlighted) in the
3
     * @return List of choices
4
     * Swing sense, but rather the entire contents of the list containing
4
     */
5
     * the user selections.
5
    private List getChoices() {
6
     *
6
        List result = new ArrayList();
7
     * @return a Vector of selected elements.
7
        for (int index : choicesList.getSelectedIndices()) {
8
     */
8
            result.add(choicesList.getModel().getElementAt(index));
9
    public Vector getSelected() {
9
        }
10
        Vector result = new Vector();
10
        return result;
11
        ListModel list = selectedList.getModel();
11
    }
12
        for (int i = 0; i < list.getSize(); i++) {
13
            result.add(list.getElementAt(i));
14
        }
15
        return result;
16
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.571
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    for (int i = 0; i < list.getSize(); i++)
    3
    for (int i = 0; i < list.getSize(); i++)
    2
    for (int index : choicesList.getSelectedIndices())
    Differences
    Expression1Expression2Difference
    javax.swing.ListModelint[]VARIABLE_TYPE_MISMATCH
    javax.swing.ListModelint[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type javax.swing.ListModel of variable list does not match with type int[] of variable choicesList.getSelectedIndices()
    • Make classes javax.swing.ListModel and int[] extend a common superclass
    Type javax.swing.ListModel of variable list does not match with type int[] of variable choicesList.getSelectedIndices()
    • Make classes javax.swing.ListModel and int[] extend a common superclass
    2
    for (int index : choicesList.getSelectedIndices())
    4
    result.add(list.getElementAt(i));
    4
    result.add(list.getElementAt(i));
    3
    result.add(choicesList.getModel().getElementAt(index));
    Differences
    Expression1Expression2Difference
    iindexVARIABLE_NAME_MISMATCH
    listchoicesList.getModel()TYPE_COMPATIBLE_REPLACEMENT
    java.util.Vectorjava.util.ListSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression i cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression index cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    result.add(choicesList.getModel().getElementAt(index));
    Precondition Violations (4)
    Row Violation
    1Type javax.swing.ListModel of variable list does not match with type int[] of variable choicesList.getSelectedIndices()
    2Type javax.swing.ListModel of variable list does not match with type int[] of variable choicesList.getSelectedIndices()
    3Expression i cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression index cannot be parameterized, because it has dependencies to/from statements that will be extracted