39
39
40
40
public class EndnoteXmlExporter extends Exporter {
41
41
42
- private static final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory .newInstance ();
43
-
44
- private record EndNoteType (String name , Integer number ) {
45
- }
46
-
47
42
private static final Map <EntryType , EndNoteType > ENTRY_TYPE_MAPPING = new HashMap <>();
48
43
49
44
static {
@@ -64,8 +59,10 @@ private record EndNoteType(String name, Integer number) {
64
59
ENTRY_TYPE_MAPPING .put (StandardEntryType .Misc , new EndNoteType ("Generic" , 15 ));
65
60
}
66
61
67
- // Contains the mapping of all fields not explicitly handled by mapX methods
68
- // We need a fixed order here, so we use a SequencedMap
62
+ /**
63
+ * Contains the mapping of all fields not explicitly handled by mapX methods.
64
+ * We need a fixed order here, so we use a SequencedMap
65
+ */
69
66
private static final SequencedMap <Field , String > STANDARD_FIELD_MAPPING = new LinkedHashMap <>();
70
67
71
68
static {
@@ -95,11 +92,17 @@ private record EndNoteType(String name, Integer number) {
95
92
96
93
private static final EndNoteType DEFAULT_TYPE = new EndNoteType ("Generic" , 15 );
97
94
95
+ private final DocumentBuilderFactory documentBuilderFactory ;
96
+
97
+ private record EndNoteType (String name , int number ) {
98
+ }
99
+
98
100
private final BibEntryPreferences bibEntryPreferences ;
99
101
100
102
public EndnoteXmlExporter (BibEntryPreferences bibEntryPreferences ) {
101
103
super ("endnote" , "EndNote XML" , StandardFileType .XML );
102
104
this .bibEntryPreferences = bibEntryPreferences ;
105
+ this .documentBuilderFactory = DocumentBuilderFactory .newInstance ();
103
106
}
104
107
105
108
@ Override
@@ -112,7 +115,7 @@ public void export(BibDatabaseContext databaseContext, Path file, List<BibEntry>
112
115
return ;
113
116
}
114
117
115
- DocumentBuilder dBuilder = DOCUMENT_BUILDER_FACTORY .newDocumentBuilder ();
118
+ DocumentBuilder dBuilder = documentBuilderFactory .newDocumentBuilder ();
116
119
Document document = dBuilder .newDocument ();
117
120
118
121
Element rootElement = document .createElement ("xml" );
@@ -187,7 +190,7 @@ private static void mapJournalTitle(BibEntry entry, Document document, Element r
187
190
}
188
191
189
192
private void mapKeywords (BibDatabase bibDatabase , BibEntry entry , Document document , Element recordElement ) {
190
- entry .getFieldOrAlias (StandardField .KEYWORDS ).ifPresent (keywords -> {
193
+ entry .getFieldOrAlias (StandardField .KEYWORDS ).ifPresent (_ -> {
191
194
Element keywordsElement = document .createElement ("keywords" );
192
195
entry .getResolvedKeywords (bibEntryPreferences .getKeywordSeparator (), bibDatabase ).forEach (keyword -> {
193
196
Element keywordElement = document .createElement ("keyword" );
@@ -258,7 +261,7 @@ private static void mapEntryType(BibEntry entry, Document document, Element reco
258
261
EndNoteType endNoteType = ENTRY_TYPE_MAPPING .getOrDefault (entryType , DEFAULT_TYPE );
259
262
Element refTypeElement = document .createElement ("ref-type" );
260
263
refTypeElement .setAttribute ("name" , endNoteType .name ());
261
- refTypeElement .setTextContent (endNoteType .number (). toString ( ));
264
+ refTypeElement .setTextContent (String . valueOf ( endNoteType .number ()));
262
265
recordElement .appendChild (refTypeElement );
263
266
}
264
267
0 commit comments