private static CSLItemData [ ] sanitizeItems ( ItemDataProvider provider ) { Set < String > knownIds = new LinkedHashSet <> ( ) ; //create a date parser which will be used to get the item's year CSLDateParser dateParser = new CSLDateParser ( ) ; //iterate through all items String [ ] ids = provider . getIds ( ) ; CSLItemData [ ] result = new CSLItemData [ ids . length ] ; for ( int i = 0 ; i < ids . length ; ++ i ) { String id = ids [ i ] ; CSLItemData item = provider . retrieveItem ( id ) ; //create a new ID String newId = makeId ( item , dateParser ) ; //make ID unique newId = uniquify ( newId , knownIds ) ; knownIds . add ( newId ) ; //copy item and replace ID item = new CSLItemDataBuilder ( item ) . id ( newId ) . build ( ) ; result [ i ] = item ; } return result ; }
Copies all items from the given provider and sanitizes its IDs