/** * Returns the list of authors in a form suitable for alphabetization. This * means that last names come first, never preceded by "von" particles, and * that any braces are removed. First names are abbreviated so the same name * is treated similarly if abbreviated in one case and not in another. This * form is not intended to be suitable for presentation, only for sorting. * * <p> * <ul> * <li>"John Smith" ==> "Smith, J.";</li> * * * @return formatted list of authors */ public String getAuthorsForAlphabetization() { if (authorsAlph != null) return authorsAlph; StringBuffer res = new StringBuffer(); if (size() > 0) { res.append(getAuthor(0).getNameForAlphabetization()); for (int i = 1; i < size(); i++) { res.append(" and "); res.append(getAuthor(i).getNameForAlphabetization()); } } authorsAlph = res.toString(); return authorsAlph; }
/** * Returns the list of authors separated by commas with last name only; If * the list consists of three or more authors, "and" is inserted before the * last author's name. * <p> * * <ul> * <li> "John Smith" ==> "Smith"</li> * <li> "John Smith and Black Brown, Peter" ==> "Smith and Black Brown"</li> * <li> "John von Neumann and John Smith and Black Brown, Peter" ==> "von * Neumann, Smith and Black Brown".</li> * </ul> * * @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 getAuthorsLastOnly(boolean oxfordComma) { int abbrInt = (oxfordComma ? 0 : 1); // Check if we've computed this before: if (authorsLastOnly[abbrInt] != null) return authorsLastOnly[abbrInt]; StringBuffer res = new StringBuffer(); if (size() > 0) { res.append(getAuthor(0).getLastOnly()); int i = 1; while (i < size() - 1) { res.append(", "); res.append(getAuthor(i).getLastOnly()); i++; } if (size() > 2 && oxfordComma) res.append(","); if (size() > 1) { res.append(" and "); res.append(getAuthor(i).getLastOnly()); } } authorsLastOnly[abbrInt] = res.toString(); return authorsLastOnly[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 getAuthorsForAlphabetization() Method name: String getAuthorsLastOnly(boolean)
Number of AST nodes: 3 Number of AST nodes: 4
1
/**
1
/**
2
	 * Returns the list of authors in a form suitable for alphabetization. This
2
	 * Returns the list of authors separated by commas with last name only; If
3
	 * means that last names come first, never preceded by "von" particles, and
3
	 * the list consists of three or more authors, "and" is inserted before the
4
	 * that any braces are removed. First names are abbreviated so the same name
4
	 * last author's name.
5
	 * is treated similarly if abbreviated in one case and not in another. This
5
	 * <p>
6
	 * form is not intended to be suitable for presentation, only for sorting.
6
	 * 
7
	 * 
7
	 * <ul>
8
	 * <p>
8
	 * <li> "John Smith" ==> "Smith"</li>
9
	 * <ul>
9
	 * <li> "John Smith and Black Brown, Peter" ==> "Smith and Black Brown"</li>
10
	 * <li>"John Smith" ==> "Smith, J.";</li>
10
	 * <li> "John von Neumann and John Smith and Black Brown, Peter" ==> "von
11
	 * 
11
	 * Neumann, Smith and Black Brown".</li>
12
	 * 
12
	 * </ul>
13
	 * @return formatted list of authors
13
	 * 
14
	 */
14
	 * @param oxfordComma
15
	public String getAuthorsForAlphabetization() {
15
	 *            Whether to put a comma before the and at the end.
16
		if (authorsAlph != null)
16
	 * 
17
			return authorsAlph;
17
	 * @see http://en.wikipedia.org/wiki/Serial_comma For an detailed
18
18
	 *      explaination about the Oxford comma.
19
		StringBuffer res = new StringBuffer();
19
	 * 
20
		if (size() > 0) {
20
	 * @return formatted list of authors.
21
			res.append(getAuthor(0).getNameForAlphabetization());
21
	 */
22
			for (int i = 1; i < size(); i++) {
22
	public String getAuthorsLastOnly(boolean oxfordComma) {
23
				res.append(" and ");
23
		int abbrInt = (oxfordComma ? 0 : 1);
24
				res.append(getAuthor(i).getNameForAlphabetization());
24
25
			}
25
		// Check if we've computed this before:
26
		}
26
		if (authorsLastOnly[abbrInt] != null)
27
		authorsAlph = res.toString();
27
			return authorsLastOnly[abbrInt];
28
		return authorsAlph;
28
29
	}
29
		StringBuffer res = new StringBuffer();
30
		if (size() > 0) {
31
			res.append(getAuthor(0).getLastOnly());
32
			int i = 1;
33
			while (i < size() - 1) {
34
				res.append(", ");
35
				res.append(getAuthor(i).getLastOnly());
36
				i++;
37
			}
38
			if (size() > 2 && oxfordComma)
39
				res.append(",");
40
			if (size() > 1) {
41
				res.append(" and ");
42
				res.append(getAuthor(i).getLastOnly());
43
			}
44
		}
45
		authorsLastOnly[abbrInt] = res.toString();
46
		return authorsLastOnly[abbrInt];
47
	}
  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.714
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    6
    for (int i = 1; i < size(); i++)
    6
    for (int i = 1; i < size(); i++)
    8
    while (i < size() - 1)
    Differences
    Expression1Expression2Difference
    size()size() - 1TYPE_COMPATIBLE_REPLACEMENT
    8
    while (i < size() - 1)
    7
    res.append(" and ");
    7
    res.append(" and ");
    10
    res.append(getAuthor(i).getLastOnly());
    Differences
    Expression1Expression2Difference
    " and "getAuthor(i).getLastOnly()TYPE_COMPATIBLE_REPLACEMENT
    10
    res.append(getAuthor(i).getLastOnly());
    8
    res.append(getAuthor(i).getNameForAlphabetization());
    8
    res.append(getAuthor(i).getNameForAlphabetization());
    9
    res.append(", ");
    Differences
    Expression1Expression2Difference
    getAuthor(i).getNameForAlphabetization()", "TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression getAuthor(i).getNameForAlphabetization() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    res.append(", ");
                    
    11
    i++;
    Precondition Violations (2)
    Row Violation
    1Expression getAuthor(i).getNameForAlphabetization() 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