Package net.sf.anupam.csv.mapping
Class CSVFieldMapping
java.lang.Object
net.sf.anupam.csv.mapping.CSVFieldMapping
- All Implemented Interfaces:
Comparable<CSVFieldMapping>
Represents a single CSV field to Java Bean attribute mapping. The mapping can
be for basic data types, or point to other referenced CSV bean mappings for
representing nested beans.
- Since:
- 1.8
- Version:
- $Revision$
- Author:
- Anupam Sengupta
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(CSVFieldMapping other) Compares this field mapping to another mapping.booleanCompares this field mapping with another for equality.Returns the mapped POJO bean's attribute name corresponding to this field.Returns the referenced bean mapping, if one is present.Returns the declarative name of the referenced bean mapping for this field, ornullif no bean mapping if referenced by this field.Returns the user defined name of this field.intReturns this field's position in the CSV line.Returns the fully qualified Java type name of this field.Returns the CSV formatter attached to this field.Returns the declarative name of the formatter attached to this field.inthashCode()Returns the hash code for this field mapping.voidsetAttributeName(String attributeName) Sets the mapped POJO's attribute name corresponding to this field.voidsetBeanReference(CSVBeanMapping beanReference) Sets the referenced bean mapping for this field.voidsetBeanReferenceName(String beanReferenceName) Sets the declarative name of a referenced bean mapping for this field.voidsetFieldName(String fieldName) Sets the user defined name of this field.voidsetFieldPosition(int fieldPosition) Sets this field's position in the CSV line.voidsetFieldType(String fieldType) Sets the fully qualified Java type name of this field.voidsetFormatter(CSVFieldFormatter formatter) Sets the formatter attached to this field.voidsetReformatterName(String reformatterName) Sets the declarative name of the formatter attached to this field.toString()Dumps the contents of this field mapping as a string.
-
Constructor Details
-
CSVFieldMapping
public CSVFieldMapping()Constructor for CSVFieldMapping.
-
-
Method Details
-
hashCode
public int hashCode()Returns the hash code for this field mapping. The hash code is based on the field name and the field position. -
equals
Compares this field mapping with another for equality. Field mappings are compared for the name and the field position. -
toString
Dumps the contents of this field mapping as a string. This is meant for debugging only. -
compareTo
Compares this field mapping to another mapping. The comparison is based on the field position.- Specified by:
compareToin interfaceComparable<CSVFieldMapping>- Parameters:
other- the other field mapping to compare to- Returns:
0if the two field mappings are equal,-1if this field mapping position is less than the other's, and+1if this field mapping position is higher than the others.- See Also:
-
getAttributeName
Returns the mapped POJO bean's attribute name corresponding to this field.- Returns:
- Returns the mapped POJO attribute name
-
setAttributeName
Sets the mapped POJO's attribute name corresponding to this field. The name has to exactly match the attribute name (including the case).- Parameters:
attributeName- The mapped POJO' attribute name
-
getFieldName
Returns the user defined name of this field.- Returns:
- Returns the name of this field.
-
setFieldName
Sets the user defined name of this field. This need not be the same as the CSV field name (if defined on the CSV header row).- Parameters:
fieldName- The name of this field
-
getFieldPosition
public int getFieldPosition()Returns this field's position in the CSV line. Field positions start at 0.- Returns:
- Returns the field's position
-
setFieldPosition
public void setFieldPosition(int fieldPosition) Sets this field's position in the CSV line. Field positions start at 0.- Parameters:
fieldPosition- The field's position in the CSV line
-
getFieldType
Returns the fully qualified Java type name of this field.- Returns:
- Returns the Java type name of this field
-
setFieldType
Sets the fully qualified Java type name of this field.- Parameters:
fieldType- The Java type name of this field
-
getFormatter
Returns the CSV formatter attached to this field.- Returns:
- Returns the formatter
-
setFormatter
Sets the formatter attached to this field.- Parameters:
formatter- The formatter to set
-
getReformatterName
Returns the declarative name of the formatter attached to this field.- Returns:
- Returns the declarative formatter name
-
setReformatterName
Sets the declarative name of the formatter attached to this field.- Parameters:
reformatterName- The declarative formatter name to set
-
getBeanReferenceName
Returns the declarative name of the referenced bean mapping for this field, ornullif no bean mapping if referenced by this field.- Returns:
- Returns name of the referenced bean mapping
-
setBeanReferenceName
Sets the declarative name of a referenced bean mapping for this field.- Parameters:
beanReferenceName- The declarative name of the referenced bean
-
setBeanReference
Sets the referenced bean mapping for this field.- Parameters:
beanReference- The bean mapping reference to set
-
getBeanReference
Returns the referenced bean mapping, if one is present. Returnsnullif this field does not have any bean reference.- Returns:
- Returns the bean mapping reference
-