Class CsvMarshaller


  • public abstract class CsvMarshaller
    extends Object
    This class marshal data into a CSV format.
    • Constructor Detail

      • CsvMarshaller

        protected CsvMarshaller​(org.apache.commons.csv.CSVFormat format)
    • Method Detail

      • create

        public static CsvMarshaller create​(org.apache.commons.csv.CSVFormat format,
                                           CsvDataFormat dataFormat)
        Creates a new instance.
        Parameters:
        format - CSV format
        dataFormat - Camel CSV data format
        Returns:
        New instance
      • marshal

        public void marshal​(org.apache.camel.Exchange exchange,
                            Object object,
                            OutputStream outputStream)
                     throws org.apache.camel.NoTypeConversionAvailableException,
                            IOException
        Marshals the given object into the given stream.
        Parameters:
        exchange - Exchange (used for access to type conversion)
        object - Body to marshal
        outputStream - Output stream of the CSV
        Throws:
        org.apache.camel.NoTypeConversionAvailableException - if the body cannot be converted
        IOException - if we cannot write into the given stream
      • createPrinter

        protected org.apache.commons.csv.CSVPrinter createPrinter​(org.apache.camel.Exchange exchange,
                                                                  OutputStream outputStream)
                                                           throws IOException
        Creates and returns a CSVPrinter.
        Parameters:
        exchange - Exchange (used for access to type conversion). Could NOT be null.
        outputStream - Output stream of the CSV. Could NOT be null.
        Returns:
        a new CSVPrinter. Never null.
        Throws:
        IOException
      • getMapRecordValues

        protected abstract Iterable<?> getMapRecordValues​(Map<?,​?> map)
        Gets the CSV record values of the given map.
        Parameters:
        map - Input map
        Returns:
        CSV record values of the given map