/** * Returns the list of authors separated by "and"s with first names after * last name; first names are not abbreviated. * <p> * <ul> * <li>"John Smith" ==> "Smith, John"</li> * <li>"John Smith and Black Brown, Peter" ==> "Smith, John and Black * Brown, Peter"</li> * <li>"John von Neumann and John Smith and Black Brown, Peter" ==> "von * Neumann, John and Smith, John and Black Brown, Peter".</li> * </ul> * * @return formatted list of authors. */ public String getAuthorsLastFirstAnds(boolean abbreviate) { int abbrInt = (abbreviate ? 0 : 1); // Check if we've computed this before: if (authorLastFirstAnds[abbrInt] != null) return authorLastFirstAnds[abbrInt]; StringBuffer res = new StringBuffer(); if (size() > 0) { res.append(getAuthor(0).getLastFirst(abbreviate)); for (int i = 1; i < size(); i++) { res.append(" and "); res.append(getAuthor(i).getLastFirst(abbreviate)); } } authorLastFirstAnds[abbrInt] = res.toString(); return authorLastFirstAnds[abbrInt]; }
/** * Returns the list of authors separated by commas with first names before * last name; first names are abbreviated or not depending on parameter. If * the list consists of three or more authors, "and" is inserted before the * last author's name. * <p> * <ul> * <li>"John Smith" ==> "John Smith" or "J. Smith"</li> * <li>"John Smith and Black Brown, Peter" ==> "John Smith and Peter Black * Brown" or "J. Smith and P. Black Brown"</li> * <li> "John von Neumann and John Smith and Black Brown, Peter" ==> "John * von Neumann, John Smith and Peter Black Brown" or "J. von Neumann, J. * Smith and P. Black Brown" </li> * </ul> * * @param abbr * whether to abbreivate first names. * * @param oxfordComma * Whether to put a comma before the and at the end. * * @see http://en.wikipedia.org/wiki/Serial_comma For an detailed * explaination about the Oxford comma. * * @return formatted list of authors. */ public String getAuthorsFirstFirst(boolean abbr, boolean oxfordComma) { int abbrInt = (abbr ? 0 : 1); abbrInt += (oxfordComma ? 0 : 2); // Check if we've computed this before: if (authorsFirstFirst[abbrInt] != null) return authorsFirstFirst[abbrInt]; StringBuffer res = new StringBuffer(); if (size() > 0) { res.append(getAuthor(0).getFirstLast(abbr)); int i = 1; while (i < size() - 1) { res.append(", "); res.append(getAuthor(i).getFirstLast(abbr)); i++; } if (size() > 2 && oxfordComma) res.append(","); if (size() > 1) { res.append(" and "); res.append(getAuthor(i).getFirstLast(abbr)); } } authorsFirstFirst[abbrInt] = res.toString(); return authorsFirstFirst[abbrInt]; }
Clone fragments detected by clone detection tool
File path: /jabref-2.10/src/java/net/sf/jabref/AuthorList.java File path: /jabref-2.10/src/java/net/sf/jabref/AuthorList.java
Method name: String getAuthorsLastFirstAnds(boolean) Method name: String getAuthorsFirstFirst(boolean, boolean)
Number of AST nodes: 3 Number of AST nodes: 4
1
/**
1
/**
2
	 * Returns the list of authors separated by "and"s with first names after
2
	 * Returns the list of authors separated by commas with first names before
3
	 * last name; first names are not abbreviated.
3
	 * last name; first names are abbreviated or not depending on parameter. If
4
	 * <p>
4
	 * the list consists of three or more authors, "and" is inserted before the
5
	 * <ul>
5
	 * last author's name.
6
	 * <li>"John Smith" ==> "Smith, John"</li>
6
	 * <p>
7
	 * <li>"John Smith and Black Brown, Peter" ==> "Smith, John and Black
7
	 * <ul>
8
	 * Brown, Peter"</li>
8
	 * <li>"John Smith" ==> "John Smith" or "J. Smith"</li>
9
	 * <li>"John von Neumann and John Smith and Black Brown, Peter" ==> "von
9
	 * <li>"John Smith and Black Brown, Peter" ==> "John Smith and Peter Black
10
	 * Neumann, John and Smith, John and Black Brown, Peter".</li>
10
	 * Brown" or "J. Smith and P. Black Brown"</li>
11
	 * </ul>
11
	 * <li> "John von Neumann and John Smith and Black Brown, Peter" ==> "John
12
	 * 
12
	 * von Neumann, John Smith and Peter Black Brown" or "J. von Neumann, J.
13
	 * @return formatted list of authors.
13
	 * Smith and P. Black Brown" </li>
14
	 */
14
	 * </ul>
15
	public String getAuthorsLastFirstAnds(boolean abbreviate) {
15
	 * 
16
		int abbrInt = (abbreviate ? 0 : 1);
16
	 * @param abbr
17
		// Check if we've computed this before:
17
	 *            whether to abbreivate first names.
18
		if (authorLastFirstAnds[abbrInt] != null)
18
	 * 
19
			return authorLastFirstAnds[abbrInt];
19
	 * @param oxfordComma
20
20
	 *            Whether to put a comma before the and at the end.
21
		StringBuffer res = new StringBuffer();
21
	 * 
22
		if (size() > 0) {
22
	 * @see http://en.wikipedia.org/wiki/Serial_comma For an detailed
23
			res.append(getAuthor(0).getLastFirst(abbreviate));
23
	 *      explaination about the Oxford comma.
24
			for (int i = 1; i < size(); i++) {
24
	 * 
25
				res.append(" and ");
25
	 * @return formatted list of authors.
26
				res.append(getAuthor(i).getLastFirst(abbreviate));
26
	 */
27
			}
27
	public String getAuthorsFirstFirst(boolean abbr, boolean oxfordComma) {
28
		}
28
29
29
		int abbrInt = (abbr ? 0 : 1);
30
		authorLastFirstAnds[abbrInt] = res.toString();
30
		abbrInt += (oxfordComma ? 0 : 2);
31
		return authorLastFirstAnds[abbrInt];
31
32
	}
32
		// Check if we've computed this before:
33
		if (authorsFirstFirst[abbrInt] != null)
34
			return authorsFirstFirst[abbrInt];
35
36
		StringBuffer res = new StringBuffer();
37
		if (size() > 0) {
38
			res.append(getAuthor(0).getFirstLast(abbr));
39
			int i = 1;
40
			while (i < size() - 1) {
41
				res.append(", ");
42
				res.append(getAuthor(i).getFirstLast(abbr));
43
				i++;
44
			}
45
			if (size() > 2 && oxfordComma)
46
				res.append(",");
47
			if (size() > 1) {
48
				res.append(" and ");
49
				res.append(getAuthor(i).getFirstLast(abbr));
50
			}
51
		}
52
		authorsFirstFirst[abbrInt] = res.toString();
53
		return authorsFirstFirst[abbrInt];
54
	}
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    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.750
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    7
    for (int i = 1; i < size(); i++)
    7
    for (int i = 1; i < size(); i++)
    9
    while (i < size() - 1)
    Differences
    Expression1Expression2Difference
    size()size() - 1TYPE_COMPATIBLE_REPLACEMENT
    9
    while (i < size() - 1)
    8
    res.append(" and ");
    8
    res.append(" and ");
    11
    res.append(getAuthor(i).getFirstLast(abbr));
    Differences
    Expression1Expression2Difference
    " and "getAuthor(i).getFirstLast(abbr)TYPE_COMPATIBLE_REPLACEMENT
    11
    res.append(getAuthor(i).getFirstLast(abbr));
    9
    res.append(getAuthor(i).getLastFirst(abbreviate));
    9
    res.append(getAuthor(i).getLastFirst(abbreviate));
    10
    res.append(", ");
    Differences
    Expression1Expression2Difference
    getAuthor(i).getLastFirst(abbreviate)", "TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression getAuthor(i).getLastFirst(abbreviate) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    res.append(", ");
                    
    12
    i++;
    Precondition Violations (2)
    Row Violation
    1Expression getAuthor(i).getLastFirst(abbreviate) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Clone fragment #1 returns variables , while Clone fragment #2 returns variables i