Class DatevUnivocityWriters

java.lang.Object
io.github.mrtyldr.datev.advanced.univocity.DatevUnivocityWriters

public final class DatevUnivocityWriters extends Object
Univocity writers configured for a DatevFile.

datev-exporter-advanced writes DATEV files on its own and pulls in no third-party dependencies. This class exists for applications that already route their CSV output through Univocity and want a CsvWriter that agrees with DATEV's quoting, delimiter, line separator and charset rules:


 CsvWriter writer = DatevUnivocityWriters.newCsvWriter(file, outputStream);
 DatevUnivocityWriters.writeTo(file, writer);
 

A CsvWriter emits one uniformly shaped record type and therefore cannot produce the differently shaped 31-field EXTF management record. writeTo(DatevFile, CsvWriter) refuses a file that carries metadata; use DatevFile.writeTo(OutputStream) for a complete file, or writeDataTo(DatevFile, CsvWriter) when only the heading and booking rows are intended.

  • Method Summary

    Modifier and Type
    Method
    Description
    static com.univocity.parsers.csv.CsvWriterSettings
    csvWriterSettings(io.github.mrtyldr.datev.advanced.DatevFile file)
    Creates a fresh Univocity configuration for a file.
    static com.univocity.parsers.csv.CsvWriter
    newCsvWriter(io.github.mrtyldr.datev.advanced.DatevFile file, OutputStream output)
    Creates a configured writer using the file's charset.
    static com.univocity.parsers.csv.CsvWriter
    newCsvWriter(io.github.mrtyldr.datev.advanced.DatevFile file, OutputStream output, com.univocity.parsers.csv.CsvWriterSettings settings)
    Creates a writer with caller-customized settings while retaining strict charset handling and caller ownership of the output stream.
    static com.univocity.parsers.csv.CsvWriter
    newCsvWriter(io.github.mrtyldr.datev.advanced.DatevFile file, Writer output)
    Creates a configured writer around a caller-provided character writer.
    static com.univocity.parsers.csv.CsvWriter
    newCsvWriter(io.github.mrtyldr.datev.advanced.DatevFile file, Writer output, com.univocity.parsers.csv.CsvWriterSettings settings)
    Creates a writer around a caller-provided character writer and customized settings.
    static void
    writeDataTo(io.github.mrtyldr.datev.advanced.DatevFile file, com.univocity.parsers.csv.CsvWriter writer)
    Writes only the DATEV heading and booking rows through a caller-provided writer.
    static void
    writeTo(io.github.mrtyldr.datev.advanced.DatevFile file, com.univocity.parsers.csv.CsvWriter writer)
    Writes a data-only file to a fresh, compatibly configured writer and flushes it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • csvWriterSettings

      public static com.univocity.parsers.csv.CsvWriterSettings csvWriterSettings(io.github.mrtyldr.datev.advanced.DatevFile file)
      Creates a fresh Univocity configuration for a file.

      The returned settings may be customized without affecting the file. A fresh CsvWriter writes the configured heading automatically before its first data row; for an empty file call AbstractWriter.writeHeaders() explicitly. These settings describe only the heading and booking-row section.

      Parameters:
      file - the file whose header and quoting rules apply
      Returns:
      a fresh writer configuration
    • newCsvWriter

      public static com.univocity.parsers.csv.CsvWriter newCsvWriter(io.github.mrtyldr.datev.advanced.DatevFile file, OutputStream output)
      Creates a configured writer using the file's charset.

      Unmappable characters are reported instead of being silently replaced. Closing the returned writer flushes but does not close the supplied stream.

      Parameters:
      file - the file whose header and charset apply
      output - the caller-owned output stream
      Returns:
      a configured writer that writes to output
    • newCsvWriter

      public static com.univocity.parsers.csv.CsvWriter newCsvWriter(io.github.mrtyldr.datev.advanced.DatevFile file, OutputStream output, com.univocity.parsers.csv.CsvWriterSettings settings)
      Creates a writer with caller-customized settings while retaining strict charset handling and caller ownership of the output stream.
      Parameters:
      file - the file whose charset applies
      output - the caller-owned output stream
      settings - the writer settings to use
      Returns:
      a writer that writes to output using settings
    • newCsvWriter

      public static com.univocity.parsers.csv.CsvWriter newCsvWriter(io.github.mrtyldr.datev.advanced.DatevFile file, Writer output)
      Creates a configured writer around a caller-provided character writer.
      Parameters:
      file - the file whose header and quoting rules apply
      output - the caller-owned character writer
      Returns:
      a configured writer that writes to output
    • newCsvWriter

      public static com.univocity.parsers.csv.CsvWriter newCsvWriter(io.github.mrtyldr.datev.advanced.DatevFile file, Writer output, com.univocity.parsers.csv.CsvWriterSettings settings)
      Creates a writer around a caller-provided character writer and customized settings.
      Parameters:
      file - the file whose header applies
      output - the caller-owned character writer
      settings - the writer settings to use
      Returns:
      a writer that writes to output using settings
    • writeTo

      public static void writeTo(io.github.mrtyldr.datev.advanced.DatevFile file, com.univocity.parsers.csv.CsvWriter writer)
      Writes a data-only file to a fresh, compatibly configured writer and flushes it.

      The writer is not closed. It must not already contain records and should have been created from csvWriterSettings(DatevFile).

      Parameters:
      file - the file to write
      writer - the fresh, compatibly configured destination writer
      Throws:
      IllegalStateException - if the file carries EXTF metadata
    • writeDataTo

      public static void writeDataTo(io.github.mrtyldr.datev.advanced.DatevFile file, com.univocity.parsers.csv.CsvWriter writer)
      Writes only the DATEV heading and booking rows through a caller-provided writer.

      This deliberately omits the EXTF management record even when metadata is configured. The writer is flushed but not closed.

      Parameters:
      file - the file to write
      writer - the fresh, compatibly configured destination writer