/** * Returns the list of authors separated by "and"s with first names before * last name; first names are not abbreviated. * <p> * <ul> * <li>"John Smith" ==> "John Smith"</li> * <li>"John Smith and Black Brown, Peter" ==> "John Smith and Peter Black * Brown"</li> * <li>"John von Neumann and John Smith and Black Brown, Peter" ==> "John * von Neumann and John Smith and Peter Black Brown" </li> * </li> * * @return formatted list of authors. */ public String getAuthorsFirstFirstAnds() { // Check if we've computed this before: if (authorsFirstFirstAnds != null) return authorsFirstFirstAnds; StringBuffer res = new StringBuffer(); if (size() > 0) { res.append(getAuthor(0).getFirstLast(false)); for (int i = 1; i < size(); i++) { res.append(" and "); res.append(getAuthor(i).getFirstLast(false)); } } authorsFirstFirstAnds = res.toString(); return authorsFirstFirstAnds; }
/** * Returns the list of authors separated by commas with first names after * 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" ==> "Smith, John" or "Smith, J."</li> * <li> "John Smith and Black Brown, Peter" ==> "Smith, John and Black * Brown, Peter" or "Smith, J. and Black Brown, P."</li> * <li> "John von Neumann and John Smith and Black Brown, Peter" ==> "von * Neumann, John, Smith, John and Black Brown, Peter" or "von Neumann, J., * Smith, J. and Black Brown, P.".</li> * </ul> * * @param abbreviate * 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 getAuthorsLastFirst(boolean abbreviate, boolean oxfordComma) { int abbrInt = (abbreviate ? 0 : 1); abbrInt += (oxfordComma ? 0 : 2); // Check if we've computed this before: if (authorsLastFirst[abbrInt] != null) return authorsLastFirst[abbrInt]; StringBuffer res = new StringBuffer(); if (size() > 0) { res.append(getAuthor(0).getLastFirst(abbreviate)); int i = 1; while (i < size() - 1) { res.append(", "); res.append(getAuthor(i).getLastFirst(abbreviate)); i++; } if (size() > 2 && oxfordComma) res.append(","); if (size() > 1) { res.append(" and "); res.append(getAuthor(i).getLastFirst(abbreviate)); } } authorsLastFirst[abbrInt] = res.toString(); return authorsLastFirst[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 getAuthorsFirstFirstAnds() Method name: String getAuthorsLastFirst(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 before
2
	 * Returns the list of authors separated by commas with first names after
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" ==> "John Smith"</li>
6
	 * <p>
7
	 * <li>"John Smith and Black Brown, Peter" ==> "John Smith and Peter Black
7
	 * 
8
	 * Brown"</li>
8
	 * <ul>
9
	 * <li>"John von Neumann and John Smith and Black Brown, Peter" ==> "John
9
	 * <li> "John Smith" ==> "Smith, John" or "Smith, J."</li>
10
	 * von Neumann and John Smith and Peter Black Brown" </li>
10
	 * <li> "John Smith and Black Brown, Peter" ==> "Smith, John and Black
11
	 * </li>
11
	 * Brown, Peter" or "Smith, J. and Black Brown, P."</li>
12
	 * 
12
	 * <li> "John von Neumann and John Smith and Black Brown, Peter" ==> "von
13
	 * @return formatted list of authors.
13
	 * Neumann, John, Smith, John and Black Brown, Peter" or "von Neumann, J.,
14
	 */
14
	 * Smith, J. and Black Brown, P.".</li>
15
	public String getAuthorsFirstFirstAnds() {
15
	 * </ul>
16
		// Check if we've computed this before:
16
	 * 
17
		if (authorsFirstFirstAnds != null)
17
	 * @param abbreviate
18
			return authorsFirstFirstAnds;
18
	 *            whether to abbreivate first names.
19
19
	 * 
20
		StringBuffer res = new StringBuffer();
20
	 * @param oxfordComma
21
		if (size() > 0) {
21
	 *            Whether to put a comma before the and at the end.
22
			res.append(getAuthor(0).getFirstLast(false));
22
	 * 
23
			for (int i = 1; i < size(); i++) {
23
	 * @see http://en.wikipedia.org/wiki/Serial_comma For an detailed
24
				res.append(" and ");
24
	 *      explaination about the Oxford comma.
25
				res.append(getAuthor(i).getFirstLast(false));
25
	 * 
26
			}
26
	 * @return formatted list of authors.
27
		}
27
	 */
28
		authorsFirstFirstAnds = res.toString();
28
	public String getAuthorsLastFirst(boolean abbreviate, boolean oxfordComma) {
29
		return authorsFirstFirstAnds;
29
		int abbrInt = (abbreviate ? 0 : 1);
30
	}
30
		abbrInt += (oxfordComma ? 0 : 2);
31
32
		// Check if we've computed this before:
33
		if (authorsLastFirst[abbrInt] != null)
34
			return authorsLastFirst[abbrInt];
35
36
		StringBuffer res = new StringBuffer();
37
		if (size() > 0) {
38
			res.append(getAuthor(0).getLastFirst(abbreviate));
39
			int i = 1;
40
			while (i < size() - 1) {
41
				res.append(", ");
42
				res.append(getAuthor(i).getLastFirst(abbreviate));
43
				i++;
44
			}
45
			if (size() > 2 && oxfordComma)
46
				res.append(",");
47
			if (size() > 1) {
48
				res.append(" and ");
49
				res.append(getAuthor(i).getLastFirst(abbreviate));
50
			}
51
		}
52
		authorsLastFirst[abbrInt] = res.toString();
53
		return authorsLastFirst[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
    6
    for (int i = 1; i < size(); i++)
    6
    for (int i = 1; i < size(); i++)
    9
    while (i < size() - 1)
    Differences
    Expression1Expression2Difference
    size()size() - 1TYPE_COMPATIBLE_REPLACEMENT
    9
    while (i < size() - 1)
    7
    res.append(" and ");
    7
    res.append(" and ");
    11
    res.append(getAuthor(i).getLastFirst(abbreviate));
    Differences
    Expression1Expression2Difference
    " and "getAuthor(i).getLastFirst(abbreviate)TYPE_COMPATIBLE_REPLACEMENT
    11
    res.append(getAuthor(i).getLastFirst(abbreviate));
    8
    res.append(getAuthor(i).getFirstLast(false));
    8
    res.append(getAuthor(i).getFirstLast(false));
    10
    res.append(", ");
    Differences
    Expression1Expression2Difference
    getAuthor(i).getFirstLast(false)", "TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression getAuthor(i).getFirstLast(false) 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).getFirstLast(false) 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