@SuppressWarnings("unchecked") public OOCalcDatabase(BibtexDatabase bibtex, Set<String> keySet) { // 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(bibtex.getEntries()); else { for (String key : keySet) entryList.add(bibtex.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/OOCalcDatabase.java File path: /jabref-2.10/src/java/net/sf/jabref/export/FileActions.java
Method name: void OOCalcDatabase(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 OOCalcDatabase(BibtexDatabase bibtex, Set<String> keySet) {
2
	public static List<BibtexEntry> getSortedEntries(BibtexDatabase database, Set<String> keySet, boolean isSaveOperation) {
3
        // Make a list of comparators for sorting the entries:
3
        boolean inOriginalOrder = isSaveOperation ? Globals.prefs.getBoolean("saveInOriginalOrder") :
4
        List<FieldComparator> comparators = new ArrayList<FieldComparator>();
4
            Globals.prefs.getBoolean("exportInOriginalOrder");
5
        comparators.add(new FieldComparator("author"));
5
        List<Comparator<BibtexEntry>> comparators;
6
        comparators.add(new FieldComparator("year"));
6
        if (inOriginalOrder) {
7
        comparators.add(new FieldComparator(BibtexFields.KEY_FIELD));
7
            // Sort entries based on their creation order, utilizing the fact
8
        // Use glazed lists to get a sorted view of the entries:
8
            // that IDs used for entries are increasing, sortable numbers.
9
        BasicEventList entryList = new BasicEventList();
9
            comparators = new ArrayList<Comparator<BibtexEntry>>();
10
        // Set up a list of all entries, if keySet==null, or the entries whose
10
            comparators.add(new CrossRefEntryComparator());
11
        // ids are in keySet, otherwise:
11
            comparators.add(new IdComparator());
12
        if (keySet == null)
12
        } else {
13
            entryList.addAll(bibtex.getEntries());
13
            comparators = getSaveComparators(isSaveOperation);
14
        else {
14
        }
15
            for (String key : keySet)
15
        
16
                entryList.add(bibtex.getEntryById(key));
16
        // Use glazed lists to get a sorted view of the entries:
17
        }
17
        FieldComparatorStack<BibtexEntry> comparatorStack = new FieldComparatorStack<BibtexEntry>(comparators);
18
        
18
        BasicEventList entryList = new BasicEventList();
19
        entries = new SortedList(entryList, new FieldComparatorStack(comparators));
19
        SortedList sorter = new SortedList(entryList, comparatorStack);
20
20
21
    }
21
        if (keySet == null)
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
    8
    for (String key : keySet)
    15
    for (; i.hasNext(); )
    9
    entryList.add(bibtex.getEntryById(key));
    9
    entryList.add(bibtex.getEntryById(key));
    16
    sorter.add(database.getEntryById((i.next())));
    Differences
    Expression1Expression2Difference
    key(i.next())TYPE_COMPATIBLE_REPLACEMENT
    bibtexdatabaseVARIABLE_NAME_MISMATCH
    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