Class DatevFile
The implementation uses a strict single-record CSV parser and a StringBuilder-based
serializer. It does not perform DATEV field-semantic validation unless a
BiConsumer validator is explicitly supplied. The validator receives the DATEV format
version and an immutable, aligned row without linking either side to an implementation-specific
validator type. Instances are mutable and not thread-safe. Use DatevStreamWriter when
booking rows should be written once without being retained.
Attach a DatevMetadata through builder() to emit the mandatory EXTF
management record and produce a complete, importable Buchungsstapel file.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classConfigures a fixed-schema file, including the optional EXTF management record. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CharsetDefault encoding used by DATEV accounting imports.static final charSeparator required by DATEV CSV files.static final StringRecord separator required by DATEV CSV files.static final intMaximum number of booking records in a DATEV Buchungsstapel file. -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(io.github.mrtyldr.datev.core.DatevColumn<?>... columns) Appends a sparse formatted row addressed by exact official heading names.voidAppends formatted columns from an iterable.voidParses and appends exactly one strict semicolon-delimited CSV record.voidAppends a complete positional row from a defensively copied array.voidappend(Collection<String> orderedValues) Appends a complete positional row from a defensively copied collection.voidAppends a sparse row addressed by exact official heading names.voidappendColumns(Collection<? extends io.github.mrtyldr.datev.core.DatevColumn<?>> columns) Appends a sparse formatted row from a collection.voidappendValues(Object... orderedValues) Appends a complete positional row, converting non-null values withString.valueOf(Object).static DatevFile.Builderbuilder()Creates a builder for the current v13 schema.static DatevFile.Builderbuilder(io.github.mrtyldr.datev.core.DatevSchema schema) Creates a builder for an explicit fixed schema.charset()Returns the output encoding.static DatevFileforSchema(io.github.mrtyldr.datev.core.DatevSchema schema) Creates an unvalidated file using one of the fixed schemas.static DatevFileforSchema(io.github.mrtyldr.datev.core.DatevSchema schema, BiConsumer<Integer, List<String>> validator) Creates a file using one fixed schema and an explicitly supplied validator.headers()Returns the immutable official headings in output order.booleanReturns whether output contains the mandatory EXTF management record.booleanisEmpty()Returns whether no data rows have been appended.iterator()Returns an iterator over an immutable snapshot of the current rows.static DatevFileCreates an unvalidated file using the legacy v12 schema.static DatevFilelegacyV12(BiConsumer<Integer, List<String>> validator) Creates a legacy v12 file using an explicitly supplied validator.Optional<io.github.mrtyldr.datev.core.DatevMetadata>metadata()Returns the configured EXTF management record, if any.introwCount()Returns the number of appended data rows.rows()Returns an immutable snapshot of immutable header-aligned rows.io.github.mrtyldr.datev.core.DatevSchemaschema()Returns the fixed schema selected for this file.byte[]Returns the complete fixed-header CSV encoded as Windows-1252 bytes.Returns the complete fixed-header CSV as characters.Returns the explicitly configured validator, if any.static DatevFileCreates an unvalidated file using the current v13 schema.static DatevFilewithDefaults(BiConsumer<Integer, List<String>> validator) Creates a current v13 file using an explicitly supplied validator.voidwrite(OutputStream output) Alias forwriteTo(OutputStream).voidAlias forwriteTo(Writer).voidwriteTo(OutputStream output) Writes the header and all current rows without closing the caller-owned stream.voidWrites the header and all current rows one record at a time without closing the caller-owned writer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
DEFAULT_DELIMITER
public static final char DEFAULT_DELIMITERSeparator required by DATEV CSV files.- See Also:
-
DEFAULT_LINE_SEPARATOR
Record separator required by DATEV CSV files.- See Also:
-
DEFAULT_CHARSET
Default encoding used by DATEV accounting imports. -
MAX_DATA_ROWS
public static final int MAX_DATA_ROWSMaximum number of booking records in a DATEV Buchungsstapel file.- See Also:
-
-
Method Details
-
builder
Creates a builder for the current v13 schema.- Returns:
- a new builder
-
builder
Creates a builder for an explicit fixed schema.- Parameters:
schema- the fixed schema to use- Returns:
- a new builder
-
withDefaults
Creates an unvalidated file using the current v13 schema.- Returns:
- a new v13 file
-
withDefaults
Creates a current v13 file using an explicitly supplied validator.- Parameters:
validator- validator invoked for each append- Returns:
- a new validated v13 file
-
legacyV12
Creates an unvalidated file using the legacy v12 schema.- Returns:
- a new v12 file
-
legacyV12
Creates a legacy v12 file using an explicitly supplied validator.- Parameters:
validator- validator invoked for each append- Returns:
- a new validated v12 file
-
forSchema
Creates an unvalidated file using one of the fixed schemas.- Parameters:
schema- fixed schema to use- Returns:
- a new file
-
forSchema
public static DatevFile forSchema(io.github.mrtyldr.datev.core.DatevSchema schema, BiConsumer<Integer, List<String>> validator) Creates a file using one fixed schema and an explicitly supplied validator.- Parameters:
schema- fixed schema to usevalidator- validator invoked for each append- Returns:
- a new validated file
-
schema
public io.github.mrtyldr.datev.core.DatevSchema schema()Returns the fixed schema selected for this file.- Returns:
- the selected schema
-
headers
Returns the immutable official headings in output order.- Returns:
- fixed ordered headings
-
charset
Returns the output encoding.- Returns:
- Windows-1252
-
validator
Returns the explicitly configured validator, if any.- Returns:
- the configured validator
-
metadata
Returns the configured EXTF management record, if any.- Returns:
- the configured metadata
-
isCompleteExtf
public boolean isCompleteExtf()Returns whether output contains the mandatory EXTF management record.Without metadata this file emits only the heading and booking records, which is not a complete DATEV-Format file.
- Returns:
trueif metadata is configured
-
rowCount
public int rowCount()Returns the number of appended data rows.- Returns:
- row count
-
isEmpty
public boolean isEmpty()Returns whether no data rows have been appended.- Returns:
truewhen empty
-
rows
Returns an immutable snapshot of immutable header-aligned rows.- Returns:
- immutable row snapshot
-
iterator
Returns an iterator over an immutable snapshot of the current rows. -
append
Parses and appends exactly one strict semicolon-delimited CSV record.Quoted values, doubled quote escaping and trailing empty cells are supported. Newlines, malformed quotes and a number of cells different from the fixed schema are rejected.
- Parameters:
semicolonSeparatedRow- exactly one complete CSV row
-
append
Appends a complete positional row from a defensively copied array.- Parameters:
orderedValues- values in fixed heading order
-
append
Appends a complete positional row from a defensively copied collection.- Parameters:
orderedValues- values in fixed heading order
-
appendValues
Appends a complete positional row, converting non-null values withString.valueOf(Object).- Parameters:
orderedValues- values in fixed heading order
-
append
Appends a sparse row addressed by exact official heading names.Missing headings become empty cells. Unknown and null headings are rejected.
- Parameters:
valuesByHeader- values addressed by exact official headings
-
append
public void append(io.github.mrtyldr.datev.core.DatevColumn<?>... columns) Appends a sparse formatted row addressed by exact official heading names.- Parameters:
columns- columns to align by heading
-
append
Appends formatted columns from an iterable.The different raw parameter type avoids erasure conflict with
append(Collection).- Parameters:
columns- columns to align by heading
-
appendColumns
public void appendColumns(Collection<? extends io.github.mrtyldr.datev.core.DatevColumn<?>> columns) Appends a sparse formatted row from a collection.All headings are resolved before any formatter runs. Formatting and validation finish before the row is committed.
- Parameters:
columns- columns to align by heading
-
writeTo
Writes the header and all current rows without closing the caller-owned stream.- Parameters:
output- destination stream
-
write
Alias forwriteTo(OutputStream).- Parameters:
output- destination stream
-
writeTo
Writes the header and all current rows one record at a time without closing the caller-owned writer. Appended rows remain retained by this file.- Parameters:
output- destination writer
-
write
Alias forwriteTo(Writer).- Parameters:
output- destination writer
-
toByteArray
public byte[] toByteArray()Returns the complete fixed-header CSV encoded as Windows-1252 bytes.- Returns:
- encoded CSV
-
toCsvString
Returns the complete fixed-header CSV as characters.- Returns:
- CSV text
-