use of org.jabref.logic.bibtex.comparator.BibtexStringComparator in project jabref by JabRef.
the class BibDatabaseWriter method writeStrings.
/**
* Write all strings in alphabetical order, modified to produce a safe (for
* BibTeX) order of the strings if they reference each other.
*
* @param database The database whose strings we should write.
*/
private void writeStrings(BibDatabase database, Boolean reformatFile, LatexFieldFormatterPreferences latexFieldFormatterPreferences) throws SaveException {
List<BibtexString> strings = database.getStringKeySet().stream().map(database::getString).collect(Collectors.toList());
strings.sort(new BibtexStringComparator(true));
// First, make a Map of all entries:
Map<String, BibtexString> remaining = new HashMap<>();
int maxKeyLength = 0;
for (BibtexString string : strings) {
remaining.put(string.getName(), string);
maxKeyLength = Math.max(maxKeyLength, string.getName().length());
}
for (BibtexString.Type t : BibtexString.Type.values()) {
boolean isFirstStringInType = true;
for (BibtexString bs : strings) {
if (remaining.containsKey(bs.getName()) && (bs.getType() == t)) {
writeString(bs, isFirstStringInType, remaining, maxKeyLength, reformatFile, latexFieldFormatterPreferences);
isFirstStringInType = false;
}
}
}
}
use of org.jabref.logic.bibtex.comparator.BibtexStringComparator in project jabref by JabRef.
the class StringDialog method sortStrings.
private void sortStrings() {
// Rebuild our sorted set of strings:
strings = new ArrayList<>();
for (String s : base.getStringKeySet()) {
strings.add(base.getString(s));
}
Collections.sort(strings, new BibtexStringComparator(false));
}
Aggregations