@Override public String toString() { StringBuffer res = new StringBuffer(100); res.append(getClass().getName()).append(" {\n"); List<ToDoItem> itemList = getToDoItemList(); synchronized (itemList) { for (ToDoItem item : itemList) { res.append(" ").append(item.toString()).append("\n"); } } res.append(" }"); return res.toString(); }
/** * Generates the association ends of the body of a class or interface. * @param cls * @param sb Where to put the result. */ private void generateClassifierBodyTypedefs(Object cls, StringBuffer sb) { if (generatorPass == HEADER_PASS) { Collection publicTypedefStatements = findTagValues(cls, TV_NAME_TYPEDEF_PUBLIC); Collection protectedTypedefStatements = findTagValues(cls, TV_NAME_TYPEDEF_PROTECTED); Collection privateTypedefStatements = findTagValues(cls, TV_NAME_TYPEDEF_PRIVATE); if (!publicTypedefStatements.isEmpty()) { sb.append(LINE_SEPARATOR).append(" public:") .append(LINE_SEPARATOR).append(indent); sb.append("// public type definitions for header defined " + "by Tag entries in ArgoUML").append(LINE_SEPARATOR); sb.append(indent); sb.append("// Result: typedef <typedef_public> " + "<tag_value>;").append(LINE_SEPARATOR); Iterator typedefEnum = publicTypedefStatements.iterator(); while (typedefEnum.hasNext()) { sb.append(indent).append("typedef "); sb.append(typedefEnum.next()) .append(";").append(LINE_SEPARATOR); } } if (!protectedTypedefStatements.isEmpty()) { sb.append(LINE_SEPARATOR).append(" protected:") .append(LINE_SEPARATOR).append(indent); sb.append("// protected type definitions for header defined " + "by Tag entries in ArgoUML").append(LINE_SEPARATOR); sb.append(indent); sb.append("// Result: typedef <typedef_protected> " + "<tag_value>;").append(LINE_SEPARATOR); Iterator typedefEnum = protectedTypedefStatements.iterator(); while (typedefEnum.hasNext()) { sb.append(indent).append("typedef "); sb.append(typedefEnum.next()) .append(";").append(LINE_SEPARATOR); } } if (!privateTypedefStatements.isEmpty()) { sb.append(LINE_SEPARATOR).append(" private:") .append(LINE_SEPARATOR).append(indent); sb.append("// private type definitions for header defined " + "by Tag entries in ArgoUML").append(LINE_SEPARATOR); sb.append(indent); sb.append("// Result: typedef <typedef_private> " + "<tag_value>;").append(LINE_SEPARATOR); Iterator typedefEnum = privateTypedefStatements.iterator(); while (typedefEnum.hasNext()) { sb.append(indent).append("typedef "); sb.append(typedefEnum.next()).append(";") .append(LINE_SEPARATOR); } } } }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/cognitive/ToDoList.java File path: /ArgoUML-0.34-src/argouml-cpp/src/org/argouml/language/cpp/generator/GeneratorCpp.java
Method name: String toString() Method name: void generateClassifierBodyTypedefs(Object, StringBuffer)
Number of AST nodes: 2 Number of AST nodes: 3
1
@Override
1
/**
2
    public String toString() {
2
     * Generates the association ends of the body of a class or interface.
3
        StringBuffer res = new StringBuffer(100);
3
     * @param cls
4
        res.append(getClass().getName()).append(" {\n");
4
     * @param sb Where to put the result.
5
        List<ToDoItem> itemList = getToDoItemList();
5
     */
6
        synchronized (itemList) {
6
    private void generateClassifierBodyTypedefs(Object cls, StringBuffer sb) {
7
            for (ToDoItem item : itemList) {
7
        if (generatorPass == HEADER_PASS) {
8
                res.append("    ").append(item.toString()).append("\n");
8
            Collection publicTypedefStatements =
9
            }
9
                findTagValues(cls, TV_NAME_TYPEDEF_PUBLIC);
10
        }
10
            Collection protectedTypedefStatements =
11
        res.append("  }");
11
                findTagValues(cls, TV_NAME_TYPEDEF_PROTECTED);
12
        return res.toString();
12
            Collection privateTypedefStatements =
13
    }
13
                findTagValues(cls, TV_NAME_TYPEDEF_PRIVATE);
14
            if (!publicTypedefStatements.isEmpty()) {
15
                sb.append(LINE_SEPARATOR).append(" public:")
16
                    .append(LINE_SEPARATOR).append(indent);
17
                sb.append("// public type definitions for header defined "
18
                      + "by Tag entries in ArgoUML").append(LINE_SEPARATOR);
19
                sb.append(indent);
20
                sb.append("// Result: typedef <typedef_public> "
21
                      + "<tag_value>;").append(LINE_SEPARATOR);
22
                Iterator typedefEnum = publicTypedefStatements.iterator();
23
24
                while (typedefEnum.hasNext()) {
25
                    sb.append(indent).append("typedef ");
26
                    sb.append(typedefEnum.next())
27
                        .append(";").append(LINE_SEPARATOR);
28
                }
29
            }
30
            if (!protectedTypedefStatements.isEmpty()) {
31
                sb.append(LINE_SEPARATOR).append(" protected:")
32
                    .append(LINE_SEPARATOR).append(indent);
33
                sb.append("// protected type definitions for header defined "
34
                      + "by Tag entries in ArgoUML").append(LINE_SEPARATOR);
35
                sb.append(indent);
36
                sb.append("// Result: typedef <typedef_protected> "
37
                      + "<tag_value>;").append(LINE_SEPARATOR);
38
                Iterator typedefEnum = protectedTypedefStatements.iterator();
39
40
                while (typedefEnum.hasNext()) {
41
                    sb.append(indent).append("typedef ");
42
                    sb.append(typedefEnum.next())
43
                        .append(";").append(LINE_SEPARATOR);
44
                }
45
            }
46
            if (!privateTypedefStatements.isEmpty()) {
47
                sb.append(LINE_SEPARATOR).append(" private:")
48
                    .append(LINE_SEPARATOR).append(indent);
49
                sb.append("// private type definitions for header defined "
50
                      + "by Tag entries in ArgoUML").append(LINE_SEPARATOR);
51
                sb.append(indent);
52
                sb.append("// Result: typedef <typedef_private> "
53
                      + "<tag_value>;").append(LINE_SEPARATOR);
54
                Iterator typedefEnum = privateTypedefStatements.iterator();
55
56
                while (typedefEnum.hasNext()) {
57
                    sb.append(indent).append("typedef ");
58
                    sb.append(typedefEnum.next()).append(";")
59
                        .append(LINE_SEPARATOR);
60
                }
61
            }
62
        }
63
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.500
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    5
    for (ToDoItem item : itemList)
    5
    for (ToDoItem item : itemList)
    11
    while (typedefEnum.hasNext())
    Differences
    Expression1Expression2Difference
    java.util.Listjava.util.CollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.List<org.argouml.cognitive.ToDoItem> of variable itemList does not match with type java.util.Collection of variable publicTypedefStatements
    • Make classes java.util.List and java.util.Collection extend a common superclass
    11
    while (typedefEnum.hasNext())
    6
    res.append("    ").append(item.toString()).append("\n");
    6
    res.append(" ").append(item.toString()).append("\n");
    12
    sb.append(indent).append("typedef ");
    Differences
    Expression1Expression2Difference
    "\n""typedef "LITERAL_VALUE_MISMATCH
    item.toString()indentTYPE_COMPATIBLE_REPLACEMENT
    res.append(" ")sbTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression item.toString() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12
    sb.append(indent).append("typedef ");
                                                                                                                                              
    13
    sb.append(typedefEnum.next()).append(";").append(LINE_SEPARATOR);
    Precondition Violations (2)
    Row Violation
    1Type java.util.List<org.argouml.cognitive.ToDoItem> of variable itemList does not match with type java.util.Collection of variable publicTypedefStatements
    2Expression item.toString() cannot be parameterized, because it has dependencies to/from statements that will be extracted