16
16
17
17
package org .metafacture .biblio .marc21 ;
18
18
19
+ import org .metafacture .biblio .iso2709 .Iso2709Constants ;
19
20
import org .metafacture .biblio .iso2709 .RecordBuilder ;
20
21
import org .metafacture .biblio .iso2709 .RecordFormat ;
21
22
import org .metafacture .framework .FluxCommand ;
@@ -180,7 +181,12 @@ public void literal(final String name, final String value) {
180
181
builder .appendSubfield (name .toCharArray (), value );
181
182
break ;
182
183
case IN_LEADER_ENTITY :
183
- processLiteralInLeader (name , value );
184
+ if (name == Marc21EventNames .LEADER_ENTITY ) {
185
+ processLeaderAsOneLiteral (value );
186
+ }
187
+ else {
188
+ processLeaderAsSubfields (name , value );
189
+ }
184
190
break ;
185
191
case IN_RECORD :
186
192
processTopLevelLiteral (name , value );
@@ -190,12 +196,30 @@ public void literal(final String name, final String value) {
190
196
}
191
197
}
192
198
193
- private void processLiteralInLeader (final String name , final String value ) {
199
+ private void processLeaderAsOneLiteral (final String value ) {
200
+ if (value .length () != Iso2709Constants .RECORD_LABEL_LENGTH ) {
201
+ throw new FormatException (
202
+ "leader literal must contain " + Iso2709Constants .RECORD_LABEL_LENGTH + " characters: " + value );
203
+ }
204
+ processLeaderAsSubfields (Marc21EventNames .RECORD_STATUS_LITERAL , value .charAt (Iso2709Constants .RECORD_STATUS_POS ));
205
+ processLeaderAsSubfields (Marc21EventNames .RECORD_TYPE_LITERAL , value .charAt (Iso2709Constants .IMPL_CODES_START ));
206
+ processLeaderAsSubfields (Marc21EventNames .BIBLIOGRAPHIC_LEVEL_LITERAL , value .charAt (Iso2709Constants .IMPL_CODES_START + 1 ));
207
+ processLeaderAsSubfields (Marc21EventNames .TYPE_OF_CONTROL_LITERAL , value .charAt (Iso2709Constants .IMPL_CODES_START + 2 ));
208
+ processLeaderAsSubfields (Marc21EventNames .CHARACTER_CODING_LITERAL , value .charAt (Iso2709Constants .RECORD_STATUS_POS + Iso2709Constants .IMPL_CODES_LENGTH ));
209
+ processLeaderAsSubfields (Marc21EventNames .ENCODING_LEVEL_LITERAL , value .charAt (Iso2709Constants .SYSTEM_CHARS_START ));
210
+ processLeaderAsSubfields (Marc21EventNames .CATALOGING_FORM_LITERAL , value .charAt (Iso2709Constants .SYSTEM_CHARS_START + 1 ));
211
+ processLeaderAsSubfields (Marc21EventNames .MULTIPART_LEVEL_LITERAL , value .charAt (Iso2709Constants .SYSTEM_CHARS_START + 2 ));
212
+ }
213
+
214
+ private void processLeaderAsSubfields (final String name , final String value ) {
194
215
if (value .length () != 1 ) {
195
216
throw new FormatException (
196
217
"literal must only contain a single character:" + name );
197
218
}
198
- final char code = value .charAt (0 );
219
+ processLeaderAsSubfields (name , value .charAt (0 ));
220
+ }
221
+
222
+ private void processLeaderAsSubfields (final String name , final char code ) {
199
223
switch (name ) {
200
224
case Marc21EventNames .RECORD_STATUS_LITERAL :
201
225
requireValidCode (code , Marc21Constants .RECORD_STATUS_CODES );
@@ -251,7 +275,12 @@ private void processTopLevelLiteral(final String name, final String value) {
251
275
// these literals here.
252
276
return ;
253
277
}
254
- builder .appendReferenceField (name .toCharArray (), value );
278
+ if (Marc21EventNames .LEADER_ENTITY .equals (name )) {
279
+ processLeaderAsOneLiteral (value );
280
+ }
281
+ else {
282
+ builder .appendReferenceField (name .toCharArray (), value );
283
+ }
255
284
}
256
285
257
286
@ Override
0 commit comments