Package net.sf.anupam.csv.mapping
Class CSVBeanMapping
java.lang.Object
net.sf.anupam.csv.mapping.CSVBeanMapping
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFieldMapping(CSVFieldMapping fieldMapping) Adds a new field mapping for this bean mapping.booleanCompares this bean mapping to another for equality.Returns the mapped bean's fully qualified class name.Returns the user defined name of the mapped bean.intReturns the maximum (i.e.inthashCode()Returns the hash code for this bean mapping.booleanIndicates whether a header row is present in the CSV mapping.iterator()Provides an iterator over the CSV field mappings present in this bean mapping.voidsetBeanClass(String beanClass) Sets the mapped bean's fully qualified class name.voidsetBeanName(String beanName) Sets the mapped bean's user defined name.voidsetCsvHeaderPresent(boolean csvHeaderPresent) Sets the flag which indicates whether a header row is present in the mapped CSV file or stream.toString()Dumps content of the bean mapping.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
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. -
equals
Compares this bean mapping to another for equality. The comparison is based on the declarative bean name. -
toString
Dumps content of the bean mapping. This is meant for debugging only. -
iterator
Provides an iterator over the CSV field mappings present in this bean mapping.- Specified by:
iteratorin interfaceIterable<CSVFieldMapping>- Returns:
- returns an iterator over the field mappings present in this bean mapping
- See Also:
-
getBeanClass
Returns the mapped bean's fully qualified class name.- Returns:
- Returns the mapped bean's class name
-
setBeanClass
Sets the mapped bean's fully qualified class name.- Parameters:
beanClass- The mapped bean's class name
-
getBeanName
Returns the user defined name of the mapped bean.- Returns:
- Returns the mapped bean's name
-
setBeanName
Sets the mapped bean's user defined name.- Parameters:
beanName- The mapped bean's user defined name
-
addFieldMapping
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
trueif 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
-