@SuppressWarnings("unchecked") public OpenDocumentRepresentation(BibtexDatabase database, Set<String> keySet) { this.database = database; // Make a list of comparators for sorting the entries: List<FieldComparator> comparators = new ArrayList<FieldComparator>(); comparators.add(new FieldComparator("author")); comparators.add(new FieldComparator("year")); comparators.add(new FieldComparator(BibtexFields.KEY_FIELD)); // Use glazed lists to get a sorted view of the entries: BasicEventList entryList = new BasicEventList(); // Set up a list of all entries, if keySet==null, or the entries whose // ids are in keySet, otherwise: if (keySet == null) entryList.addAll(database.getEntries()); else { for (String key : keySet) entryList.add(database.getEntryById(key)); } entries = new SortedList(entryList, new FieldComparatorStack(comparators)); }
@SuppressWarnings("unchecked") public static List<BibtexEntry> getSortedEntries(BibtexDatabase database, Set<String> keySet, boolean isSaveOperation) { boolean inOriginalOrder = isSaveOperation ? Globals.prefs.getBoolean("saveInOriginalOrder") : Globals.prefs.getBoolean("exportInOriginalOrder"); List<Comparator<BibtexEntry>> comparators; if (inOriginalOrder) { // Sort entries based on their creation order, utilizing the fact // that IDs used for entries are increasing, sortable numbers. comparators = new ArrayList<Comparator<BibtexEntry>>(); comparators.add(new CrossRefEntryComparator()); comparators.add(new IdComparator()); } else { comparators = getSaveComparators(isSaveOperation); } // Use glazed lists to get a sorted view of the entries: FieldComparatorStack<BibtexEntry> comparatorStack = new FieldComparatorStack<BibtexEntry>(comparators); BasicEventList entryList = new BasicEventList(); SortedList sorter = new SortedList(entryList, comparatorStack); if (keySet == null) keySet = database.getKeySet(); if (keySet != null) { Iterator<String> i = keySet.iterator(); for (; i.hasNext();) { sorter.add(database.getEntryById((i.next()))); } } return sorter; }
Clone fragments detected by clone detection tool
File path: /jabref-2.10/src/java/net/sf/jabref/export/OpenDocumentRepresentation.java File path: /jabref-2.10/src/java/net/sf/jabref/export/FileActions.java
Method name: void OpenDocumentRepresentation(BibtexDatabase, Set) Method name: List getSortedEntries(BibtexDatabase, Set, boolean)
Number of AST nodes: 2 Number of AST nodes: 2
1
@SuppressWarnings("unchecked")
1
@SuppressWarnings("unchecked")
2
	public OpenDocumentRepresentation(BibtexDatabase database, Set<String> keySet) {
2
	public static List<BibtexEntry> getSortedEntries(BibtexDatabase database, Set<String> keySet, boolean isSaveOperation) {
3
        this.database = database;
3
        boolean inOriginalOrder = isSaveOperation ? Globals.prefs.getBoolean("saveInOriginalOrder") :
4
        // Make a list of comparators for sorting the entries:
4
            Globals.prefs.getBoolean("exportInOriginalOrder");
5
        List<FieldComparator> comparators = new ArrayList<FieldComparator>();
5
        List<Comparator<BibtexEntry>> comparators;
6
        comparators.add(new FieldComparator("author"));
6
        if (inOriginalOrder) {
7
        comparators.add(new FieldComparator("year"));
7
            // Sort entries based on their creation order, utilizing the fact
8
        comparators.add(new FieldComparator(BibtexFields.KEY_FIELD));
8
            // that IDs used for entries are increasing, sortable numbers.
9
        // Use glazed lists to get a sorted view of the entries:
9
            comparators = new ArrayList<Comparator<BibtexEntry>>();
10
        BasicEventList entryList = new BasicEventList();
10
            comparators.add(new CrossRefEntryComparator());
11
11
            comparators.add(new IdComparator());
12
        // Set up a list of all entries, if keySet==null, or the entries whose
12
        } else {
13
        // ids are in keySet, otherwise:
13
            comparators = getSaveComparators(isSaveOperation);
14
        if (keySet == null)
14
        }
15
            entryList.addAll(database.getEntries());
15
        
16
        else {
16
        // Use glazed lists to get a sorted view of the entries:
17
            for (String key : keySet)
17
        FieldComparatorStack<BibtexEntry> comparatorStack = new FieldComparatorStack<BibtexEntry>(comparators);
18
                entryList.add(database.getEntryById(key));
18
        BasicEventList entryList = new BasicEventList();
19
        }
19
        SortedList sorter = new SortedList(entryList, comparatorStack);
20
20
21
        entries = new SortedList(entryList, new FieldComparatorStack(comparators));
21
        if (keySet == null)
22
    }
22
            keySet = database.getKeySet();
23
24
        if (keySet != null) {
25
            Iterator<String> i = keySet.iterator();
26
27
            for (; i.hasNext();) {
28
                sorter.add(database.getEntryById((i.next())));
29
            }
30
        }
31
        return sorter;
32
    }
  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 fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.667
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    9
    for (String key : keySet)
    15
    for (; i.hasNext(); )
    10
    entryList.add(database.getEntryById(key));
    10
    entryList.add(database.getEntryById(key));
    16
    sorter.add(database.getEntryById((i.next())));
    Differences
    Expression1Expression2Difference
    key(i.next())TYPE_COMPATIBLE_REPLACEMENT
    entryListsorterVARIABLE_NAME_MISMATCH
    ca.odell.glazedlists.BasicEventListca.odell.glazedlists.SortedListSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression key cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16
    sorter.add(database.getEntryById((i.next())));
    Precondition Violations (1)
    Row Violation
    1Expression key cannot be parameterized, because it has dependencies to/from statements that will be extracted