Class CsvClientImpl<T>

    • Constructor Detail

      • CsvClientImpl

        public CsvClientImpl​(Writer writer)
      • CsvClientImpl

        public CsvClientImpl​(Writer writer,
                             Class<T> beanClass)
      • CsvClientImpl

        public CsvClientImpl​(Reader reader)
      • CsvClientImpl

        public CsvClientImpl​(Reader reader,
                             Class<T> beanClass)
    • Method Detail

      • writeBeans

        public void writeBeans​(Collection<T> beans)
        Description copied from interface: CsvClient
        Writes a collection of Beans to the table
        Specified by:
        writeBeans in interface CsvClient<T>
        Parameters:
        beans - beans to write to the table
      • writeBean

        public void writeBean​(T bean)
        Description copied from interface: CsvClient
        Writes a single Bean to the table
        Specified by:
        writeBean in interface CsvClient<T>
        Parameters:
        bean - bean to write to the table
      • writeRow

        public void writeRow​(Row row)
        Description copied from interface: CsvClient
        Writes a single row to the table
        Specified by:
        writeRow in interface CsvClient<T>
        Parameters:
        row - single row
      • writeRow

        public Row writeRow​(String[] row)
        Description copied from interface: CsvClient
        Writes a single row (consisting of String cells) to the table
        Specified by:
        writeRow in interface CsvClient<T>
        Parameters:
        row - single row
        Returns:
        the written row
      • writeRows

        public void writeRows​(Collection<Row> rows)
        Description copied from interface: CsvClient
        Writes a collection of rows to the table
        Specified by:
        writeRows in interface CsvClient<T>
        Parameters:
        rows - collections of rows
      • writeRows

        public void writeRows​(String[][] rows)
        Description copied from interface: CsvClient
        Writes a two-dimensional array of cells (rows with cells) to the table
        Specified by:
        writeRows in interface CsvClient<T>
        Parameters:
        rows - two-dimensional array of cells
      • writeHeader

        public Header writeHeader​(String[] header)
        Description copied from interface: CsvClient
        Writes the header to the table
        Specified by:
        writeHeader in interface CsvClient<T>
        Parameters:
        header - the header row
        Returns:
        the converted Header
      • writeHeader

        public void writeHeader​(Header header)
        Description copied from interface: CsvClient
        Writes the header to the table
        Specified by:
        writeHeader in interface CsvClient<T>
        Parameters:
        header - the header row
      • writeHeader

        public void writeHeader()
        Description copied from interface: CsvClient
        Writes a header based on the bean properties to the table
        Specified by:
        writeHeader in interface CsvClient<T>
      • readBeans

        public List<T> readBeans()
        Description copied from interface: CsvClient
        Reads all rows from the file and return these as beans.
        Specified by:
        readBeans in interface CsvClient<T>
        Returns:
        all beans read from the Reader
      • readBean

        public T readBean()
        Description copied from interface: CsvClient
        Reads a single row and returns this as a bean. The RowReader will keep track of its state.
        Specified by:
        readBean in interface CsvClient<T>
        Returns:
        Bean read from the Reader
      • readRows

        public List<Row> readRows()
        Description copied from interface: CsvClient
        Reads all rows from the file and returns them as a List. After this, the RowReader will be finished
        Specified by:
        readRows in interface CsvClient<T>
        Returns:
        all Rows read from the Reader
      • readRow

        public Row readRow()
        Description copied from interface: CsvClient
        Reads a single row from the file and returns this. The RowReader will keep track of its state.
        Specified by:
        readRow in interface CsvClient<T>
        Returns:
        Row read from the Reader
      • readHeader

        public Header readHeader()
        Description copied from interface: CsvClient
        Returns the header of the CSV file. Only possibly returns a value when useHeader==true
        Specified by:
        readHeader in interface CsvClient<T>
        Returns:
        header or null if the useHeader==false
      • getCurrentLine

        public int getCurrentLine()
        Description copied from interface: CsvClient
        Returns the line from which the row was read. Note that a line is seen as a legitimate CSV row, not necessarily a printable line (unless multi-lines are used, these values are the same).
        Specified by:
        getCurrentLine in interface CsvClient<T>
        Returns:
        current line number
      • isFinished

        public boolean isFinished()
        Description copied from interface: CsvClient
        States whether the Reader is done with the file
        Specified by:
        isFinished in interface CsvClient<T>
        Returns:
        true if file is finished
      • setUseHeader

        public CsvClient<T> setUseHeader​(boolean useHeader)
        Description copied from interface: CsvClient
        Makes sure that the first readable line is interpreted as the header line. That line will not be read as content. This method is called whenever CsvFile.useHeader() is used. The default value for this setting is true. This call is a facade for RowInstructions.setUseHeader(boolean).
        Specified by:
        setUseHeader in interface CsvClient<T>
        Parameters:
        useHeader - true if the header is interpreted and used
        Returns:
        convenience for chaining
      • setEscape

        public CsvClient<T> setEscape​(char symbol)
        Description copied from interface: CsvClient
        Sets the character that will be interpreted as an escape symbol while within a quoted field. This method is called whenever CsvFile.escape() is used. The default value for this setting is a double quote (") symbol. This call is a facade for RowInstructions.setEscape(char).
        Specified by:
        setEscape in interface CsvClient<T>
        Parameters:
        symbol - the symbol to use for escaping characters within a quoted field
        Returns:
        convenience for chaining
      • setQuote

        public CsvClient<T> setQuote​(char symbol)
        Description copied from interface: CsvClient
        Sets the character that will be interpreted as a quote symbol, signifying either the start or the end of a quoted field. This method is called whenever CsvFile.quote() is used. The default value for this setting is a double quote (") symbol. This call is a facade for RowInstructions.setQuote(char).
        Specified by:
        setQuote in interface CsvClient<T>
        Parameters:
        symbol - the symbol to use for indicating start/end of a quoted field
        Returns:
        convenience for chaining
      • setSeparator

        public CsvClient<T> setSeparator​(char symbol)
        Description copied from interface: CsvClient
        Sets the character that will be interpreted as a separator between cells. This method is called whenever CsvFile.separator() is used. The default value for this setting is a semi-colon (;). This call is a facade for RowInstructions.setSeparator(char).
        Specified by:
        setSeparator in interface CsvClient<T>
        Parameters:
        symbol - the symbol to use as a separator between cells
        Returns:
        convenience for chaining
      • setComment

        public CsvClient<T> setComment​(char symbol)
        Description copied from interface: CsvClient
        Sets the character that will be interpreted as a comment field on the first position of a row. This method is called whenever CsvFile.comment() is used. The default value for this setting is a hashtag (#).
        Specified by:
        setComment in interface CsvClient<T>
        Parameters:
        symbol - the symbol to use as the 0-position comment marker
        Returns:
        convenience for chaining
      • setEndOfLine

        public CsvClient<T> setEndOfLine​(char[] symbols)
        Description copied from interface: CsvClient
        Sets the characters (plural) that will be interpreted as end-of-line markers (unless within a quoted field). This method is called whenever CsvFile.endOfLine() is used. The default values for this setting are \r and \n. This call is a facade for RowInstructions.setEndOfLine(char[]).
        Specified by:
        setEndOfLine in interface CsvClient<T>
        Parameters:
        symbols - the symbol to interpret as end-of-line markers (unless within a quoted field)
        Returns:
        convenience for chaining
      • skipEmptyLines

        public CsvClient<T> skipEmptyLines​(boolean skip)
        Description copied from interface: CsvClient
        Determines whether empty lines must be skipped or treated as single-column rows. This method is called whenever CsvFile.skipEmptyLines() is used. The default value for this setting is to skip the empty lines.
        Specified by:
        skipEmptyLines in interface CsvClient<T>
        Parameters:
        skip - true to skip empty lines, false to treat as single-column rows
        Returns:
        convenience for chaining
      • skipCommentLines

        public CsvClient<T> skipCommentLines​(boolean skip)
        Description copied from interface: CsvClient
        Determines whether comment lines must be skipped. This method is called whenever CsvFile.skipCommentLines() is used. The default value for this setting is to skip comment lines. This method exists to guarantee that lines are not accidentally treated as comment lines.
        Specified by:
        skipCommentLines in interface CsvClient<T>
        Parameters:
        skip - true to skip comment lines, identified as starting with a comment marker
        Returns:
        convenience for chaining
      • setDate

        public CsvClient<T> setDate​(String propertyName,
                                    String dateFormat)
        Description copied from interface: CsvClient
        Determines what dateformat to apply to the cell value before storing it as a date. This method is called whenever CsvDate is used. The default for date format is dd-MM-yyyy.
        Specified by:
        setDate in interface CsvClient<T>
        Parameters:
        propertyName - the name of the property to write the date to
        dateFormat - the date format to apply for parsing the date value
        Returns:
        convenience for chaining
      • setLocalizedNumber

        public CsvClient<T> setLocalizedNumber​(String propertyName,
                                               Locale locale)
        Description copied from interface: CsvClient
        Determines what Locale to apply to the cell value before converting it to a number. This method is called whenever CsvLocalizedNumber is used. The default for Locale is the Locale of the server.
        Specified by:
        setLocalizedNumber in interface CsvClient<T>
        Parameters:
        propertyName - the name of the property to write the data to
        locale - the Locale to apply for converting the number
        Returns:
        convenience for chaining
      • setRequired

        public CsvClient<T> setRequired​(String propertyName,
                                        boolean required)
        Description copied from interface: CsvClient
        Determines if the field is required. If so, the cell may not be empty and a CsvException will be thrown if this occurs. This method is called whenever CsvCell.required() is used. The default for a property is false.
        Specified by:
        setRequired in interface CsvClient<T>
        Parameters:
        propertyName - property for which the requirement applies
        required - whether the cell must be not-null
        Returns:
        convenience for chaining
      • setConverter

        public CsvClient<T> setConverter​(String propertyName,
                                         Converter converter)
        Description copied from interface: CsvClient
        Sets a custom PropertyEditor for the property. This PropertyEditor is called to convert the text to the type of the property and set it on the bean. This method is called whenever CsvConverter.converter() is used. The default for a property is based on the wonderful set of PropertyEditors that Spring offers, which is all basics and some extras as well.
        Specified by:
        setConverter in interface CsvClient<T>
        Parameters:
        propertyName - property to which the converter must be applied
        converter - PropertyEditor to apply to the property
        Returns:
        convenience for chaining
      • ignoreProperty

        public CsvClient<T> ignoreProperty​(String propertyName)
        Description copied from interface: CsvClient
        Sets a field to be ignored for purposes of mapping. This method is called whenever CsvIgnore is used. By default none of the fields are ignored unless, custom instructions are used. In this case, all fields are ignored by default.
        Specified by:
        ignoreProperty in interface CsvClient<T>
        Parameters:
        propertyName - property which must be ignored for mapping
        Returns:
        convenience for chaining
      • mapColumnIndexToProperty

        public CsvClient<T> mapColumnIndexToProperty​(int columnIndex,
                                                     String propertyName)
        Description copied from interface: CsvClient
        Maps a column in the CSV to a specific property. This method is called whenever CsvCell.columnIndex() is used. By default there is NO mapping when custom instructions are used, so you should roll your own. Note that column indexes are 1-based, not 0-based.
        Specified by:
        mapColumnIndexToProperty in interface CsvClient<T>
        Parameters:
        columnIndex - index of the column for which the property mapping must be applied
        propertyName - property to which the index-based mapping must be applied
        Returns:
        convenience for chaining
      • mapColumnNameToProperty

        public CsvClient<T> mapColumnNameToProperty​(String columnName,
                                                    String propertyName)
        Description copied from interface: CsvClient
        Maps a column name (which is found in the header) to a specific property. Note that to use this, headers must be enabled. This method is called whenever CsvCell.columnName() is used. By default there is NO mapping when custom instructions are used, so you should roll your own. Also, don't forget to CsvClient.setMapper(Class) to ColumnNameMapper for this to work.
        Specified by:
        mapColumnNameToProperty in interface CsvClient<T>
        Parameters:
        columnName - name of the column for which the property mapping must be applied
        propertyName - property to which the name-based mapping must be applied
        Returns:
        convenience for chaining
      • setStartIndexDynamicColumns

        public CsvClient<T> setStartIndexDynamicColumns​(int startIndex)
        Description copied from interface: CsvClient
        A file can have a special layout with a dynamic number of columns. If the intention is to duplicate rows for every separate column, this is the method you require. It will remember the start position of the dynamic columns and treat every column after that as dynamic. For every dynamic column a row will be created. If a bean has fields annotated with @CsvHeaderName or @CsvHeaderValue, it will store the values of the header or the cell for that index column in the fields.
        Specified by:
        setStartIndexDynamicColumns in interface CsvClient<T>
        Parameters:
        startIndex - the index where the dynamic columns start
        Returns:
        convenience for chaining
      • setHeaderNameToProperty

        public CsvClient<T> setHeaderNameToProperty​(String propertyName)
        Description copied from interface: CsvClient
        Determines what property will receive the header name in the currently active dynamic column
        Specified by:
        setHeaderNameToProperty in interface CsvClient<T>
        Parameters:
        propertyName - property in which the active dynamic header name must be stored
        Returns:
        convenience for chaining
      • setHeaderValueToProperty

        public CsvClient<T> setHeaderValueToProperty​(String propertyName)
        Description copied from interface: CsvClient
        Determines what property will receive the cell value in the currently active dynamic column
        Specified by:
        setHeaderValueToProperty in interface CsvClient<T>
        Parameters:
        propertyName - property in which the active dynamic column value must be stored
        Returns:
        convenience for chaining
      • getRowWriter

        public RowWriter getRowWriter()