@@ -182,28 +182,23 @@ public void endEntity() {
182
182
@ Override
183
183
public void literal (final String name , final String value ) {
184
184
if ("" .equals (currentEntity )) {
185
- prettyPrintIndentation ();
186
- writeRaw (String .format (CONTROLFIELD_OPEN_TEMPLATE , name ));
187
- if (value != null ) {
188
- writeEscaped (value .trim ());
185
+ if (!writeLeader (name , value )) {
186
+ prettyPrintIndentation ();
187
+ writeRaw (String .format (CONTROLFIELD_OPEN_TEMPLATE , name ));
188
+ if (value != null ) {
189
+ writeEscaped (value .trim ());
190
+ }
191
+ writeRaw (CONTROLFIELD_CLOSE );
192
+ prettyPrintNewLine ();
189
193
}
190
- writeRaw (CONTROLFIELD_CLOSE );
191
- prettyPrintNewLine ();
192
194
}
193
- else if (!currentEntity . equals ( Marc21EventNames . LEADER_ENTITY )) {
195
+ else if (!writeLeader ( currentEntity , value )) {
194
196
prettyPrintIndentation ();
195
197
writeRaw (String .format (SUBFIELD_OPEN_TEMPLATE , name ));
196
198
writeEscaped (value .trim ());
197
199
writeRaw (SUBFIELD_CLOSE );
198
200
prettyPrintNewLine ();
199
201
}
200
- else {
201
- if (name .equals (Marc21EventNames .LEADER_ENTITY )) {
202
- prettyPrintIndentation ();
203
- writeRaw (LEADER_OPEN_TEMPLATE + value + LEADER_CLOSE_TEMPLATE );
204
- prettyPrintNewLine ();
205
- }
206
- }
207
202
208
203
}
209
204
@@ -252,6 +247,19 @@ private void writeEscaped(final String str) {
252
247
builder .append (XmlUtil .escape (str , false ));
253
248
}
254
249
250
+ private boolean writeLeader (final String name , final String value ) {
251
+ if (name .equals (Marc21EventNames .LEADER_ENTITY )) {
252
+ prettyPrintIndentation ();
253
+ writeRaw (LEADER_OPEN_TEMPLATE + value + LEADER_CLOSE_TEMPLATE );
254
+ prettyPrintNewLine ();
255
+
256
+ return true ;
257
+ }
258
+ else {
259
+ return false ;
260
+ }
261
+ }
262
+
255
263
private void prettyPrintIndentation () {
256
264
if (formatted ) {
257
265
final String prefix = String .join ("" , Collections .nCopies (indentationLevel , INDENT ));
0 commit comments