org.apache.camel.dataformat.bindy
Class BindyAbstractFactory

java.lang.Object
  extended by org.apache.camel.dataformat.bindy.BindyAbstractFactory
All Implemented Interfaces:
BindyFactory
Direct Known Subclasses:
BindyCsvFactory, BindyFixedLengthFactory, BindyKeyValuePairFactory

public abstract class BindyAbstractFactory
extends java.lang.Object
implements BindyFactory

The BindyAbstractFactory implements what its common to all the formats supported by Camel Bindy


Field Summary
protected  java.util.Map<java.lang.String,java.util.List<java.lang.reflect.Field>> annotatedLinkFields
           
protected  java.lang.String crlf
           
protected  java.util.Set<java.lang.Class<?>> models
           
 
Constructor Summary
BindyAbstractFactory(org.apache.camel.spi.PackageScanClassResolver resolver, java.lang.String... packageNames)
           
 
Method Summary
abstract  void bind(java.util.List<java.lang.String> data, java.util.Map<java.lang.String,java.lang.Object> model, int line)
          The bind allow to read the content of a record (expressed as a List) and map it to the model classes.
 java.util.Map<java.lang.String,java.lang.Object> factory()
          Factory method generating new instances of the model and adding them to a HashMap
 java.lang.String formatString(Format format, java.lang.Object value)
          Format the object into a string according to the format rue defined
protected static java.lang.Integer generateKey(java.lang.Integer key1, java.lang.Integer key2)
          Generate a unique key
 java.lang.String getCarriageReturn()
          Find the carriage return set
static java.lang.Object getDefaultValueForPrimitive(java.lang.Class<?> clazz)
           
 java.lang.String getLocale()
           
abstract  void initAnnotatedFields()
          Find fields annotated in each class of the model
 void initModel()
          method uses to initialize the model representing the classes who will bind the data.
 void link(java.util.Map<java.lang.String,java.lang.Object> model)
          Link objects together
 void setLocale(java.lang.String locale)
           
abstract  java.lang.String unbind(java.util.Map<java.lang.String,java.lang.Object> model)
          The unbind is used to transform the content of the classes model objects into a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

annotatedLinkFields

protected final java.util.Map<java.lang.String,java.util.List<java.lang.reflect.Field>> annotatedLinkFields

models

protected java.util.Set<java.lang.Class<?>> models

crlf

protected java.lang.String crlf
Constructor Detail

BindyAbstractFactory

public BindyAbstractFactory(org.apache.camel.spi.PackageScanClassResolver resolver,
                            java.lang.String... packageNames)
                     throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

initModel

public void initModel()
               throws java.lang.Exception
method uses to initialize the model representing the classes who will bind the data. This process will scan for classes according to the package name provided, check the annotated classes and fields.

Specified by:
initModel in interface BindyFactory
Throws:
java.lang.Exception

initAnnotatedFields

public abstract void initAnnotatedFields()
                                  throws java.lang.Exception
Find fields annotated in each class of the model

Throws:
java.lang.Exception

bind

public abstract void bind(java.util.List<java.lang.String> data,
                          java.util.Map<java.lang.String,java.lang.Object> model,
                          int line)
                   throws java.lang.Exception
Description copied from interface: BindyFactory
The bind allow to read the content of a record (expressed as a List) and map it to the model classes.

Specified by:
bind in interface BindyFactory
Parameters:
data - List represents the csv, ... data to transform
model - Map is a collection of objects used to bind data. String is the the key name of the class link to POJO objects
line - is the position of the record into the file
Throws:
java.lang.Exception - can be thrown

unbind

public abstract java.lang.String unbind(java.util.Map<java.lang.String,java.lang.Object> model)
                                 throws java.lang.Exception
Description copied from interface: BindyFactory
The unbind is used to transform the content of the classes model objects into a string. The string represents a record of a CSV file

Specified by:
unbind in interface BindyFactory
Parameters:
model - Map is a collection of objects used to create csv, ... records. String is the the key name of the class link to POJO objects
Returns:
String represents a csv record created
Throws:
java.lang.Exception - can be thrown

link

public void link(java.util.Map<java.lang.String,java.lang.Object> model)
          throws java.lang.Exception
Link objects together

Throws:
java.lang.Exception

factory

public java.util.Map<java.lang.String,java.lang.Object> factory()
                                                         throws java.lang.Exception
Factory method generating new instances of the model and adding them to a HashMap

Returns:
Map is a collection of the objects used to bind data from records, messages
Throws:
java.lang.Exception - can be thrown

generateKey

protected static java.lang.Integer generateKey(java.lang.Integer key1,
                                               java.lang.Integer key2)
Generate a unique key

Parameters:
key1 - The key of the section number
key2 - The key of the position of the field
Returns:
the key generated

getDefaultValueForPrimitive

public static java.lang.Object getDefaultValueForPrimitive(java.lang.Class<?> clazz)
                                                    throws java.lang.Exception
Throws:
java.lang.Exception

getCarriageReturn

public java.lang.String getCarriageReturn()
Find the carriage return set


formatString

public java.lang.String formatString(Format format,
                                     java.lang.Object value)
                              throws java.lang.Exception
Format the object into a string according to the format rue defined

Throws:
java.lang.Exception

getLocale

public java.lang.String getLocale()

setLocale

public void setLocale(java.lang.String locale)


Apache CAMEL