CSVObjects Framework

net.sf.anupam.csv.mapping
Class CSVBeanMapping

java.lang.Object
  extended by 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, the 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.5
Version:
$Revision: 1.5 $
Author:
Anupam Sengupta
See Also:
CSVFieldMapping

Constructor Summary
CSVBeanMapping()
          Constructor for CSVBeanMapping.
 
Method Summary
 void addFieldMapping(CSVFieldMapping fieldMapping)
          Adds a new field mapping for this bean mapping.
 boolean equals(Object other)
          Compares this bean mapping to another for equality.
 String getBeanClass()
          Returns the mapped bean's fully qualified class name.
 String getBeanName()
          Returns the user defined name of the mapped bean.
 int getMaxFieldPosition()
          Returns the maximum (i.e. highest) field position present in this bean mapping.
 int hashCode()
          Returns the hash code for this bean mapping.
 boolean isCsvHeaderPresent()
          Indicates whether a header row is present in the CSV mapping.
 Iterator<CSVFieldMapping> iterator()
          Provides an iterator over the CSV field mappings present in this bean mapping.
 void setBeanClass(String beanClass)
          Sets the mapped bean's fully qualified class name.
 void setBeanName(String beanName)
          Sets the mapped bean's user defined name.
 void setCsvHeaderPresent(boolean csvHeaderPresent)
          Sets the flag which indicates whether a header row is present in the mapped CSV file or stream.
 String toString()
          Dumps content of the bean mapping.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CSVBeanMapping

public CSVBeanMapping()
Constructor for CSVBeanMapping.

Method Detail

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 comparision 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:
Object.toString()

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 mappins present in this bean mapping
See Also:
Iterable.iterator()

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

SourceForge.net Logo

© Anupam Sengupta 2005