Class CSVBeanMapping

java.lang.Object
net.sf.anupam.csv.mapping.CSVBeanMapping
All Implemented Interfaces:
Iterable<CSVFieldMapping>

public class CSVBeanMapping extends Object implements Iterable<CSVFieldMapping>
Represents the CSV to Java Bean mapping for a single Java bean. Instances of this class store the bean name, fully qualified class name, CSV header indicator, as well as individual CSV field mappings.

The bean name (which is user defined) acts as the name of the mapping as well, and is used for looking up or accessing the specific parsers for this mapping.

Since:
1.8
Version:
$Revision$
Author:
Anupam Sengupta
See Also:
  • Constructor Details

    • CSVBeanMapping

      public CSVBeanMapping()
      Constructor for CSVBeanMapping.
  • Method Details

    • hashCode

      public int hashCode()
      Returns the hash code for this bean mapping. The hashcode is based on the bean name.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
    • equals

      public boolean equals(Object other)
      Compares this bean mapping to another for equality. The comparison is based on the declarative bean name.
      Overrides:
      equals in class Object
      Parameters:
      other - the other bean mapping to compare against
      Returns:
      true if equal, false otherwise
    • toString

      public String toString()
      Dumps content of the bean mapping. This is meant for debugging only.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this bean mapping
      See Also:
    • iterator

      public Iterator<CSVFieldMapping> iterator()
      Provides an iterator over the CSV field mappings present in this bean mapping.
      Specified by:
      iterator in interface Iterable<CSVFieldMapping>
      Returns:
      returns an iterator over the field mappings present in this bean mapping
      See Also:
    • getBeanClass

      public String getBeanClass()
      Returns the mapped bean's fully qualified class name.
      Returns:
      Returns the mapped bean's class name
    • setBeanClass

      public void setBeanClass(String beanClass)
      Sets the mapped bean's fully qualified class name.
      Parameters:
      beanClass - The mapped bean's class name
    • getBeanName

      public String getBeanName()
      Returns the user defined name of the mapped bean.
      Returns:
      Returns the mapped bean's name
    • setBeanName

      public void setBeanName(String beanName)
      Sets the mapped bean's user defined name.
      Parameters:
      beanName - The mapped bean's user defined name
    • addFieldMapping

      public void addFieldMapping(CSVFieldMapping fieldMapping)
      Adds a new field mapping for this bean mapping.
      Parameters:
      fieldMapping - the field mapping to add
    • getMaxFieldPosition

      public int getMaxFieldPosition()
      Returns the maximum (i.e. highest) field position present in this bean mapping. All field positions start from zero.
      Returns:
      Returns the highest field position
    • isCsvHeaderPresent

      public boolean isCsvHeaderPresent()
      Indicates whether a header row is present in the CSV mapping.
      Returns:
      Returns true if the mapped CSV file or stream has a header
    • setCsvHeaderPresent

      public void setCsvHeaderPresent(boolean csvHeaderPresent)
      Sets the flag which indicates whether a header row is present in the mapped CSV file or stream.
      Parameters:
      csvHeaderPresent - The flag value to set