Class FieldMapByPosition<T>

    • Constructor Detail

      • FieldMapByPosition

        public FieldMapByPosition​(java.util.Locale errorLocale)
        Initializes this FieldMap.
        Parameters:
        errorLocale - The locale to be used for error messages
    • Method Detail

      • generateHeader

        public java.lang.String[] generateHeader​(T bean)
                                          throws CsvRequiredFieldEmptyException
        This method generates a header that can be used for writing beans of the type provided back to a file. The ordering of the headers can be determined with the Comparator passed in to setColumnOrderOnWrite(Comparator). Otherwise, it is ascending according to position.
        Specified by:
        generateHeader in interface FieldMap<java.lang.String,​java.lang.Integer,​PositionToBeanField<T>,​T>
        Parameters:
        bean - One perfect, shining example of how the bean to be written should look. The most crucial thing is, for fields that result from joining multiple fields on reading and thus need to be split on writing, the MultiValuedMap in question must have the complete structure of the header to be generated, even if some values are empty.
        Returns:
        An array of header names for the output file
        Throws:
        CsvRequiredFieldEmptyException - If a required header is missing while attempting to write. Since every other header is hard-wired through the bean fields and their associated annotations, this can only happen with multi-valued fields.
      • putComplex

        public void putComplex​(java.lang.String rangeDefinition,
                               BeanField<T,​java.lang.Integer> field)
        Description copied from interface: FieldMap
        Adds a BeanField to this map indexed by the data in initializer. This is what makes this map special: It allows one to define characteristics of a method to match multiple keys.
        Specified by:
        putComplex in interface FieldMap<java.lang.String,​java.lang.Integer,​PositionToBeanField<T>,​T>
        Parameters:
        rangeDefinition - A string describing the column positions to be matched.
        field - The BeanField that is to be returned on a later match
        See Also:
        CsvBindAndJoinByPosition.position()
      • setMaxIndex

        public void setMaxIndex​(int maxIndex)
        Sets the maximum index for all ranges specified in the entire field map. No ranges or mappings are ever removed so as to preserve information about required fields, but upper boundries are shortened as much as possible. If ranges or individual column positions were specified that lie wholly above maxIndex, these are preserved, though ranges are shortened to a single value (the lower boundry).
        Parameters:
        maxIndex - The maximum index in the data being imported
      • iterator

        public java.util.Iterator<FieldMapByPositionEntry<T>> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>
      • setColumnOrderOnWrite

        public void setColumnOrderOnWrite​(java.util.Comparator<java.lang.Integer> writeOrder)
        Sets the Comparator to be used to sort columns when writing beans to a CSV file.
        Parameters:
        writeOrder - The Comparator to use. May be null, in which case the natural ordering is used.
        Since:
        4.3