Class BindyAbstractFactory
- java.lang.Object
-
- org.apache.camel.dataformat.bindy.BindyAbstractFactory
-
- All Implemented Interfaces:
BindyFactory
- Direct Known Subclasses:
BindyCsvFactory,BindyFixedLengthFactory,BindyKeyValuePairFactory
public abstract class BindyAbstractFactory extends Object implements BindyFactory
TheBindyAbstractFactoryimplements what its common to all the formats supported by Camel Bindy
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,List<Field>>annotatedLinkFieldsprotected Stringcrlfprotected Stringeolprotected FormatFactoryformatFactoryprotected Set<String>modelClassNamesprotected Set<Class<?>>models
-
Constructor Summary
Constructors Constructor Description BindyAbstractFactory(Class<?> type)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidbind(org.apache.camel.CamelContext camelContext, List<String> data, Map<String,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. Map<String,Object>factory()Factory method generating new instances of the model and adding them to a HashMapStringformatString(Format<?> format, Object value)Format the object into a string according to the format rule definedprotected static IntegergenerateKey(Integer key1, Integer key2)Generate a unique keyStringgetCarriageReturn()Find the carriage return setstatic ObjectgetDefaultValueForPrimitive(Class<?> clazz)StringgetEndOfLine()Find the carriage return setStringgetLocale()abstract voidinitAnnotatedFields()Find fields annotated in each class of the modelvoidinitModel()method uses to initialize the model representing the classes who will bind the data.voidlink(Map<String,Object> model)Link objects togethervoidsetFormatFactory(FormatFactory formatFactory)voidsetLocale(String locale)booleansupportsModel(Set<String> classes)Indicates whether this factory can support a row comprised of the identified classesabstract Stringunbind(org.apache.camel.CamelContext camelContext, Map<String,Object> model)The unbind is used to transform the content of the classes model objects into a string.
-
-
-
Method Detail
-
initModel
public void initModel() throws Exceptionmethod 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:
initModelin interfaceBindyFactory- Throws:
Exception
-
initAnnotatedFields
public abstract void initAnnotatedFields() throws ExceptionFind fields annotated in each class of the model- Throws:
Exception
-
bind
public abstract void bind(org.apache.camel.CamelContext camelContext, List<String> data, Map<String,Object> model, int line) throws ExceptionDescription copied from interface:BindyFactoryThe bind allow to read the content of a record (expressed as a List) and map it to the model classes. - Specified by:
bindin interfaceBindyFactorydata- Listrepresents the csv, ... data to transform model- Mapis a collection of objects used to bind data. String is the key name of the class link to POJO objects line- is the position of the record into the file- Throws:
Exception- can be thrown
-
unbind
public abstract String unbind(org.apache.camel.CamelContext camelContext, Map<String,Object> model) throws Exception
Description copied from interface:BindyFactoryThe 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:
unbindin interfaceBindyFactorymodel- Mapis a collection of objects used to create csv, ... records. String is the key name of the class link to POJO objects - Returns:
- String represents a csv record created
- Throws:
Exception- can be thrown
-
factory
public Map<String,Object> factory() throws 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:
Exception- can be thrown
-
supportsModel
public boolean supportsModel(Set<String> classes)
Indicates whether this factory can support a row comprised of the identified classes- Parameters:
classes- the names of the classes in the row- Returns:
- true if the model supports the identified classes
-
generateKey
protected static Integer generateKey(Integer key1, Integer key2)
Generate a unique key- Parameters:
key1- The key of the section numberkey2- The key of the position of the field- Returns:
- the key generated
-
getCarriageReturn
public String getCarriageReturn()
Find the carriage return set
-
getEndOfLine
public String getEndOfLine()
Find the carriage return set
-
formatString
public String formatString(Format<?> format, Object value) throws Exception
Format the object into a string according to the format rule defined- Throws:
Exception
-
getLocale
public String getLocale()
-
setLocale
public void setLocale(String locale)
-
setFormatFactory
public void setFormatFactory(FormatFactory formatFactory)
-
-