@@ -56,6 +56,12 @@ public final class RecordBuilder {
56
56
private AppendState appendState ;
57
57
private int fieldStart ;
58
58
59
+ /**
60
+ * Initializes the RecordBuilder based on a RecordFormat.
61
+ *
62
+ * @param recordFormat RecordFormat as base to configure the RecordBuilder
63
+ * @see RecordFormat
64
+ */
59
65
public RecordBuilder (final RecordFormat recordFormat ) {
60
66
Require .notNull (recordFormat );
61
67
label = new LabelBuilder (recordFormat );
@@ -82,6 +88,13 @@ private char[] arrayOfNSpaceChars(final int count) {
82
88
return chars ;
83
89
}
84
90
91
+ /**
92
+ * Sets the charset of the FieldsBuilder.
93
+ *
94
+ * @param charset Charset used by the FieldsBuilder
95
+ * @see FieldsBuilder
96
+ * @see Charset
97
+ */
85
98
public void setCharset (final Charset charset ) {
86
99
fields .setCharset (Require .notNull (charset ));
87
100
}
@@ -90,46 +103,101 @@ public Charset getCharset() {
90
103
return fields .getCharset ();
91
104
}
92
105
106
+ /**
107
+ * Sets the record status of the LabelBuilder.
108
+ *
109
+ * @param recordStatus 7 bit char record status
110
+ * @see Iso2709Constants.RECORD_STATUS_POS
111
+ * @see LabelBuilder
112
+ */
93
113
public void setRecordStatus (final char recordStatus ) {
94
114
require7BitAscii (recordStatus );
95
115
label .setRecordStatus (recordStatus );
96
116
}
97
117
118
+ /**
119
+ * Sets the impl codes in the LabelBuilder.
120
+ *
121
+ * @param implCodes char array of 7 bit impl codes
122
+ * @see Iso2709Constants
123
+ * @see LabelBuilder
124
+ */
98
125
public void setImplCodes (final char [] implCodes ) {
99
126
Require .notNull (implCodes );
100
127
Require .that (implCodes .length == Iso2709Constants .IMPL_CODES_LENGTH );
101
128
require7BitAscii (implCodes );
102
129
label .setImplCodes (implCodes );
103
130
}
104
131
132
+ /**
133
+ * Sets an impl code at a given position in the LabelBuilder.
134
+ *
135
+ * @param index index of the 7 bit impl code
136
+ * @param implCode char of a 7 bit impl code
137
+ * @see Iso2709Constants
138
+ * @see LabelBuilder
139
+ */
105
140
public void setImplCode (final int index , final char implCode ) {
106
141
Require .that (0 <= index && index < Iso2709Constants .IMPL_CODES_LENGTH );
107
142
require7BitAscii (implCode );
108
143
label .setImplCode (index , implCode );
109
144
}
110
145
146
+ /**
147
+ * Sets the system chars in the LabelBuilder.
148
+ *
149
+ * @param systemChars 7-bit char array to be set as system chars
150
+ * @see Iso2709Constants
151
+ * @see LabelBuilder
152
+ */
111
153
public void setSystemChars (final char [] systemChars ) {
112
154
Require .notNull (systemChars );
113
155
Require .that (systemChars .length == Iso2709Constants .SYSTEM_CHARS_LENGTH );
114
156
require7BitAscii (systemChars );
115
157
label .setSystemChars (systemChars );
116
158
}
117
159
160
+ /**
161
+ * Sets a system char at the given position in the LabelBuilder.
162
+ *
163
+ * @param systemChar 7-bit char to be set as the system char
164
+ * @param index position of the system char
165
+ * @see Iso2709Constants
166
+ * @see LabelBuilder
167
+ */
118
168
public void setSystemChar (final int index , final char systemChar ) {
119
169
Require .that (0 <= index && index < Iso2709Constants .SYSTEM_CHARS_LENGTH );
120
170
require7BitAscii (systemChar );
121
171
label .setSystemChar (index , systemChar );
122
172
}
123
173
174
+ /**
175
+ * Sets a reserved char in the LabelBuilder.
176
+ *
177
+ * @param reservedChar 7-bit char to be set as reserved char
178
+ * @see Iso2709Constants
179
+ * @see LabelBuilder
180
+ */
124
181
public void setReservedChar (final char reservedChar ) {
125
182
require7BitAscii (reservedChar );
126
183
label .setReservedChar (reservedChar );
127
184
}
128
185
186
+ /**
187
+ * Appends an identifier field.
188
+ *
189
+ * @param value String that is appended as an identfier field
190
+ */
129
191
public void appendIdentifierField (final String value ) {
130
192
appendIdentifierField (defaultImplDefinedPart , value );
131
193
}
132
194
195
+ /**
196
+ * Appends an identifier field in dependency of the current impl defined part.
197
+ *
198
+ * @param currentImplDefinedPart char array of the current impl defined part
199
+ * @param value String that is appended as an identfier field
200
+ */
133
201
public void appendIdentifierField (final char [] currentImplDefinedPart , final String value ) {
134
202
requireNotInDataField ();
135
203
requireNotAppendingReferenceFields ();
@@ -144,6 +212,14 @@ public void appendReferenceField(final char[] currentTag, final String value) {
144
212
appendReferenceField (currentTag , defaultImplDefinedPart , value );
145
213
}
146
214
215
+ /**
216
+ * Appends a reference field in dependency of the current tag and of the
217
+ * current impl defined part.
218
+ *
219
+ * @param currentTag char array of the current tag
220
+ * @param currentImplDefinedPart char array of the current impl defined part
221
+ * @param value String that is appended as a reference field
222
+ */
147
223
public void appendReferenceField (final char [] currentTag , final char [] currentImplDefinedPart , final String value ) {
148
224
requireNotInDataField ();
149
225
requireNotAppendingDataFields ();
@@ -181,6 +257,14 @@ public void startDataField(final char[] currentTag, final char[] indicators) {
181
257
startDataField (currentTag , indicators , defaultImplDefinedPart );
182
258
}
183
259
260
+ /**
261
+ * Starts a data field in dependency of the current tag, indicators and of the
262
+ * current impl defined part.
263
+ *
264
+ * @param currentTag char array of the current tag
265
+ * @param indicators char array of the current indicators
266
+ * @param currentImplDefinedPart char array of the current impl defined part
267
+ */
184
268
public void startDataField (final char [] currentTag , final char [] indicators , final char [] currentImplDefinedPart ) {
185
269
requireNotInDataField ();
186
270
Require .notNull (currentTag );
@@ -208,6 +292,9 @@ private void copyArray(final char[] source, final char[] destination) {
208
292
System .arraycopy (source , 0 , destination , 0 , destination .length );
209
293
}
210
294
295
+ /**
296
+ * Ends a data field.
297
+ */
211
298
public void endDataField () {
212
299
requireInDataField ();
213
300
final int fieldEnd = fields .endField ();
@@ -221,12 +308,23 @@ public void endDataField() {
221
308
}
222
309
}
223
310
311
+ /**
312
+ * Appends a subfield.
313
+ *
314
+ * @param value String of the to be appended subfield
315
+ */
224
316
public void appendSubfield (final String value ) {
225
317
requireInDataField ();
226
318
Require .notNull (value );
227
319
fields .appendSubfield (defaultIdentifier , value );
228
320
}
229
321
322
+ /**
323
+ * Appends a subfield in dependency of an identifier.
324
+ *
325
+ * @param identifier char array of an identifier
326
+ * @param value String of the to be appended subfield
327
+ */
230
328
public void appendSubfield (final char [] identifier , final String value ) {
231
329
requireInDataField ();
232
330
Require .notNull (identifier );
@@ -236,6 +334,11 @@ public void appendSubfield(final char[] identifier, final String value) {
236
334
fields .appendSubfield (identifier , value );
237
335
}
238
336
337
+ /**
338
+ * Builds the record.
339
+ *
340
+ * @return byte array of the record
341
+ */
239
342
public byte [] build () {
240
343
requireNotInDataField ();
241
344
final int baseAddress = Iso2709Constants .RECORD_LABEL_LENGTH + directory .length ();
@@ -286,6 +389,12 @@ private void require7BitAscii(final char charCode) {
286
389
Require .that (charCode != Iso646Constants .INFORMATION_SEPARATOR_3 );
287
390
}
288
391
392
+ /**
393
+ * Resets the label, directory and the fields. Sets the "append state" to "id
394
+ * field".
395
+ *
396
+ * @see AppendState.ID_FIELD
397
+ */
289
398
public void reset () {
290
399
label .reset ();
291
400
directory .reset ();
0 commit comments