Class NamedCsvRecordHandler
java.lang.Object
de.siegmar.fastcsv.reader.CsvCallbackHandler<NamedCsvRecord>
de.siegmar.fastcsv.reader.AbstractInternalCsvCallbackHandler<NamedCsvRecord>
de.siegmar.fastcsv.reader.NamedCsvRecordHandler
A callback handler that returns a NamedCsvRecord for each record.
Example:
NamedCsvRecordHandler handler = NamedCsvRecordHandler.builder()
.fieldModifier(FieldModifiers.TRIM)
.header("foo", "bar")
.build();
This implementation is stateful and must not be reused.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class de.siegmar.fastcsv.reader.AbstractInternalCsvCallbackHandler
AbstractInternalCsvCallbackHandler.AbstractInternalCsvCallbackHandlerBuilder<T extends AbstractInternalCsvCallbackHandler.AbstractInternalCsvCallbackHandlerBuilder<?>> -
Field Summary
Fields inherited from class de.siegmar.fastcsv.reader.AbstractInternalCsvCallbackHandler
comment, emptyLine, fieldIdx, fieldModifier, fields, maxFields, maxFieldSize, maxRecordSize, recordSize, startingLineNumber -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.NamedCsvRecordHandler(FieldModifier fieldModifier) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()orof(Consumer)instead.NamedCsvRecordHandler(FieldModifier fieldModifier, String... header) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()orof(Consumer)instead.NamedCsvRecordHandler(FieldModifier fieldModifier, List<String> header) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()orof(Consumer)instead.NamedCsvRecordHandler(String... header) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()orof(Consumer)instead.NamedCsvRecordHandler(List<String> header) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()orof(Consumer)instead. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Constructs a new builder instance for this class.protected RecordWrapper<NamedCsvRecord> Called at the end of each CSV record to build an object representation of the record.static NamedCsvRecordHandlerof()Constructs a new instance of this class with default settings.static NamedCsvRecordHandlerof(Consumer<NamedCsvRecordHandler.NamedCsvRecordHandlerBuilder> configurer) Constructs a new instance of this class with the given configuration.Methods inherited from class de.siegmar.fastcsv.reader.AbstractInternalCsvCallbackHandler
addField, beginRecord, buildWrapper, compactFields, modifyComment, modifyField, setCommentMethods inherited from class de.siegmar.fastcsv.reader.CsvCallbackHandler
terminate
-
Constructor Details
-
NamedCsvRecordHandler
Deprecated, for removal: This API element is subject to removal in a future version.Useof()instead.Constructs a newNamedCsvRecordHandlerwith an empty header. -
NamedCsvRecordHandler
Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()orof(Consumer)instead.Constructs a newNamedCsvRecordHandlerwith the given header.- Parameters:
header- the header, must not benullor containnullelements- Throws:
NullPointerException- ifnullis passed
-
NamedCsvRecordHandler
Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()orof(Consumer)instead.Constructs a newNamedCsvRecordHandlerwith the given header.- Parameters:
header- the header, must not benullor containnullelements- Throws:
NullPointerException- ifnullis passed
-
NamedCsvRecordHandler
@Deprecated(since="3.6.0", forRemoval=true) public NamedCsvRecordHandler(FieldModifier fieldModifier) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()orof(Consumer)instead.Constructs a newNamedCsvRecordHandlerwith the given field modifier.- Parameters:
fieldModifier- the field modifier, must not benull- Throws:
NullPointerException- ifnullis passed
-
NamedCsvRecordHandler
@Deprecated(since="3.6.0", forRemoval=true) public NamedCsvRecordHandler(FieldModifier fieldModifier, List<String> header) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()orof(Consumer)instead.Constructs a newNamedCsvRecordHandlerwith the given header and field modifier.- Parameters:
fieldModifier- the field modifier, must not benullheader- the header, must not benullor containnullelements- Throws:
NullPointerException- ifnullis passed
-
NamedCsvRecordHandler
@Deprecated(since="3.6.0", forRemoval=true) public NamedCsvRecordHandler(FieldModifier fieldModifier, String... header) Deprecated, for removal: This API element is subject to removal in a future version.Usebuilder()orof(Consumer)instead.Constructs a newNamedCsvRecordHandlerwith the given header and field modifier.- Parameters:
fieldModifier- the field modifier, must not benullheader- the header, must not benullor containnullelements- Throws:
NullPointerException- ifnullis passed
-
-
Method Details
-
builder
Constructs a new builder instance for this class.- Returns:
- the builder
- See Also:
-
of
Constructs a new instance of this class with default settings.- Returns:
- the new instance
- See Also:
-
of
public static NamedCsvRecordHandler of(Consumer<NamedCsvRecordHandler.NamedCsvRecordHandlerBuilder> configurer) Constructs a new instance of this class with the given configuration.
This is an alternative to the builder pattern for convenience.
- Parameters:
configurer- the configuration, must not benull- Returns:
- the new instance
- Throws:
NullPointerException- ifnullis passedIllegalArgumentException- if argument constraints are violated- See Also:
-
buildRecord
Description copied from class:CsvCallbackHandlerCalled at the end of each CSV record to build an object representation of the record.
The returned wrapper is used by the
CsvReaderin order to determine how to process the record.- Specified by:
buildRecordin classCsvCallbackHandler<NamedCsvRecord>- Returns:
- the record wrapper or
nullif the record should be ignored/skipped
-
of()instead.