You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cm...@apache.org on 2009/06/25 15:33:27 UTC

svn commit: r788355 - in /camel/trunk/components/camel-bindy: ./ src/main/java/org/apache/camel/dataformat/bindy/ src/main/java/org/apache/camel/dataformat/bindy/annotation/ src/main/java/org/apache/camel/dataformat/bindy/csv/ src/main/java/org/apache/...

Author: cmoulliard
Date: Thu Jun 25 13:33:26 2009
New Revision: 788355

URL: http://svn.apache.org/viewvc?rev=788355&view=rev
Log:
Add a new annotation @section to allow users to define how message will be build based on the different classes of the model (header = section 1, body = section 2, Trailer = section 3)
Add a new property positions in DataField.java and KeyValuePairField.java defining the position of the field in the message generated
BindyCsvDataFormat, BindyKeyValuePairDataFormat and BindyKeyValuePairFactory have been modified to accept list of packages
version of junit used has been defined to 4.4 (due to bug in Spring 5.5 with Junit4)
New test has been added : BindySimpleKeyValuePairSortedMarshallTest.java

Added:
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Section.java   (with props)
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairSortedMarshallTest.java   (with props)
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/body/
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/body/Order.java   (with props)
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/header/
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/header/Header.java   (with props)
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/trailer/
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/trailer/Trailer.java   (with props)
Modified:
    camel/trunk/components/camel-bindy/pom.xml
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyKeyValuePairFactory.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/KeyValuePairField.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Message.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/util/AnnotationModelLoader.java
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairMarshallTest.java
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairTabMarshallTest.java

Modified: camel/trunk/components/camel-bindy/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/pom.xml?rev=788355&r1=788354&r2=788355&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/pom.xml (original)
+++ camel/trunk/components/camel-bindy/pom.xml Thu Jun 25 13:33:26 2009
@@ -63,6 +63,7 @@
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>            
             <scope>test</scope>
+            <version>4.4</version>
         </dependency>
         <dependency>
             <groupId>log4j</groupId>
@@ -90,7 +91,9 @@
                     <useFile>true</useFile>
                     <forkMode>pertest</forkMode>
                     <excludes>
-                        <!-- <exclude>**/XXXTest.*</exclude> -->
+                        <!-- <exclude>**/*Csv*Test.*</exclude>
+                        <exclude>**/*Tab*Test.*</exclude>
+                        <exclude>**/*Unmarshall*Test.*</exclude> -->
                     </excludes>
                 </configuration>
             </plugin>

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java?rev=788355&r1=788354&r2=788355&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java Thu Jun 25 13:33:26 2009
@@ -17,6 +17,7 @@
 package org.apache.camel.dataformat.bindy;
 
 import java.lang.reflect.Field;
+import java.text.NumberFormat;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -30,102 +31,142 @@
 import org.apache.commons.logging.LogFactory;
 
 /**
- * The BindyAbstractFactory implements what its common to all the 
- * formats supported by camel bindy
+ * The BindyAbstractFactory implements what its common to all the formats
+ * supported by camel bindy
  */
 public abstract class BindyAbstractFactory implements BindyFactory {
-    private static final transient Log LOG = LogFactory.getLog(BindyAbstractFactory.class);
-    protected Set<Class> models;
-    protected Map<String, Field> mapAnnotedLinkField = new LinkedHashMap<String, Field>();    
-    protected String crlf;
-    
-    private AnnotationModelLoader modelsLoader;
-    
-    private String packageName;
-
-    public BindyAbstractFactory(PackageScanClassResolver resolver, String packageName) throws Exception {
-        this.modelsLoader = new AnnotationModelLoader(resolver);
-        this.packageName = packageName;
-        initModel();
-    }
-
-    /**
-     * 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 classes and fields annoted.
-     * 
-     * @throws Exception
-     */
-    public void initModel() throws Exception {
-
-        // Find classes defined as Model
-        initModelClasses(packageName);
-
-    }
-
-    /**
-     * Find all the classes defined as model
-     */
-    private void initModelClasses(String packageName) throws Exception {
-        models = modelsLoader.loadModels(packageName);
-    }
-
-    /**
-     * Find fields annoted in each class of the model
-     */
-    public abstract void initAnnotedFields() throws Exception;
-
-    public abstract void bind(List<String> data, Map<String, Object> model) throws Exception;
-
-    public abstract String unbind(Map<String, Object> model) throws Exception;
-
-    /**
-     * Link objects together (Only 1to1 relation is allowed)
-     */
-    public void link(Map<String, Object> model) throws Exception {
-
-        for (String link : mapAnnotedLinkField.keySet()) {
-
-            Field field = mapAnnotedLinkField.get(link);
-            field.setAccessible(true);
-
-            // Retrieve linked object
-            String toClassName = field.getType().getName();
-            Object to = model.get(toClassName);
-
-            ObjectHelper.notNull(to, "No @link annotation has been defined for the oject to link");
-            field.set(model.get(field.getDeclaringClass().getName()), to);
-
-        }
-    }
-
-    /**
-     * Factory method generating new instances of the model and adding them to a
-     * HashMap
-     * 
-     * @return Map is a collection of the objects used to bind data from records, messages
-     * @throws Exception can be thrown
-     */
-    public Map<String, Object> factory() throws Exception {
-
-        Map<String, Object> mapModel = new HashMap<String, Object>();
-
-        for (Class<?> cl : models) {
-
-            Object obj = ObjectHelper.newInstance(cl);
-
-            // Add instance of the class to the Map Model
-            mapModel.put(obj.getClass().getName(), obj);
-
-        }
-
-        return mapModel;
-    }
-    
-    /**
-     * Find the carriage return set
-     */
-    public String getCarriageReturn() {
-        return crlf;
-    }
+	private static final transient Log LOG = LogFactory.getLog(BindyAbstractFactory.class);
+	protected Set<Class> models;
+	protected Map<String, Field> mapAnnotedLinkField = new LinkedHashMap<String, Field>();
+	protected String crlf;
+
+	private AnnotationModelLoader modelsLoader;
+	private String[] packageNames;
+
+	public BindyAbstractFactory(PackageScanClassResolver resolver, String... packageNames) throws Exception {
+		this.modelsLoader = new AnnotationModelLoader(resolver);
+		this.packageNames = packageNames;
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("Package(s) name : " + packageNames.toString());
+		}
+
+		initModel();
+	}
+
+	/**
+	 * 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 classes and fields annoted.
+	 * 
+	 * @throws Exception
+	 */
+	public void initModel() throws Exception {
+
+		// Find classes defined as Model
+		initModelClasses(this.packageNames);
+
+	}
+
+	/**
+	 * Find all the classes defined as model
+	 */
+	private void initModelClasses(String... packageNames) throws Exception {
+		models = modelsLoader.loadModels(packageNames);
+	}
+
+	/**
+	 * Find fields annoted in each class of the model
+	 */
+	public abstract void initAnnotedFields() throws Exception;
+
+	public abstract void bind(List<String> data, Map<String, Object> model) throws Exception;
+
+	public abstract String unbind(Map<String, Object> model) throws Exception;
+
+	/**
+	 * Link objects together (Only 1to1 relation is allowed)
+	 */
+	public void link(Map<String, Object> model) throws Exception {
+
+		for (String link : mapAnnotedLinkField.keySet()) {
+
+			Field field = mapAnnotedLinkField.get(link);
+			field.setAccessible(true);
+
+			// Retrieve linked object
+			String toClassName = field.getType().getName();
+			Object to = model.get(toClassName);
+
+			ObjectHelper.notNull(to, "No @link annotation has been defined for the oject to link");
+			field.set(model.get(field.getDeclaringClass().getName()), to);
+
+		}
+	}
+
+	/**
+	 * Factory method generating new instances of the model and adding them to a
+	 * HashMap
+	 * 
+	 * @return Map is a collection of the objects used to bind data from
+	 *         records, messages
+	 * @throws Exception
+	 *             can be thrown
+	 */
+	public Map<String, Object> factory() throws Exception {
+
+		Map<String, Object> mapModel = new HashMap<String, Object>();
+
+		for (Class<?> cl : models) {
+
+			Object obj = ObjectHelper.newInstance(cl);
+
+			// Add instance of the class to the Map Model
+			mapModel.put(obj.getClass().getName(), obj);
+
+		}
+
+		return mapModel;
+	}
+
+	/**
+	 * Generate a unique key
+	 * 
+	 * @param key1
+	 *            The key of the section number
+	 * @param key2
+	 *            The key of the position of the field
+	 * @return the key generated
+	 */
+	protected static Integer generateKey(Integer key1, Integer key2) {
+		
+		String key2Formated = getNumberFormat().format((long)key2);
+		String keyGenerated = String.valueOf(key1) + key2Formated;
+		
+		return Integer.valueOf(keyGenerated);
+
+	}
+
+	/**
+	 * 
+	 * @return NumberFormat
+	 */
+	private static NumberFormat getNumberFormat() {
+		
+		// Get instance of NumberFormat
+		NumberFormat nf = NumberFormat.getInstance();
+	
+		// set max number of digits to 3 (thousands) 
+		nf.setMaximumIntegerDigits(3);
+		nf.setMinimumIntegerDigits(3);
+		
+		return nf;
+	}
+
+	/**
+	 * Find the carriage return set
+	 */
+	public String getCarriageReturn() {
+		return crlf;
+	}
 }

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java?rev=788355&r1=788354&r2=788355&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java Thu Jun 25 13:33:26 2009
@@ -17,6 +17,7 @@
 package org.apache.camel.dataformat.bindy;
 
 import java.lang.reflect.Field;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -26,117 +27,140 @@
 import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
 import org.apache.camel.dataformat.bindy.annotation.DataField;
 import org.apache.camel.dataformat.bindy.annotation.Link;
+import org.apache.camel.dataformat.bindy.annotation.Section;
+import org.apache.camel.dataformat.bindy.util.Converter;
 import org.apache.camel.spi.PackageScanClassResolver;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 /**
- * The BindyCsvFactory is the class who allows to :
- * Generate a model associated to a CSV record, bind data from a record
- * to the POJOs, export data of POJOs to a CSV record and format data
- * into String, Date, Double, ... according to the format/pattern defined
+ * The BindyCsvFactory is the class who allows to : Generate a model associated
+ * to a CSV record, bind data from a record to the POJOs, export data of POJOs
+ * to a CSV record and format data into String, Date, Double, ... according to
+ * the format/pattern defined
  */
-public class BindyCsvFactory extends BindyAbstractFactory implements BindyFactory  {
+public class BindyCsvFactory extends BindyAbstractFactory implements BindyFactory {
 
-    private static final transient Log LOG = LogFactory.getLog(BindyCsvFactory.class);
+	private static final transient Log LOG = LogFactory.getLog(BindyCsvFactory.class);
 
-    private Map<Integer, DataField> mapDataField = new LinkedHashMap<Integer, DataField>();
-    private Map<Integer, Field> mapAnnotedField = new LinkedHashMap<Integer, Field>();
+	private Map<Integer, DataField> mapDataField = new LinkedHashMap<Integer, DataField>();
+	private Map<Integer, Field> mapAnnotedField = new LinkedHashMap<Integer, Field>();
+	private Map<String, Integer> sections = new HashMap<String, Integer>();
+
+	private String separator;
+	private boolean skipFirstLine;
+	private boolean messageOrdered;
+
+	public BindyCsvFactory(PackageScanClassResolver resolver, String... packageNames) throws Exception {
+
+		super(resolver, packageNames);
+
+		// initialize specific parameters of the csv model
+		initCsvModel();
+	}
+
+	/**
+	 * 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 classes and fields annoted and retrieve the
+	 * separator of the CSV record
+	 * 
+	 * @throws Exception
+	 */
+	public void initCsvModel() throws Exception {
+
+		// Find annotated Datafields declared in the Model classes
+		initAnnotedFields();
+
+		// initialize Csv parameter(s)
+		// separator and skip first line from @CSVrecord annotation
+		initCsvRecordParameters();
+	}
+
+	public void initAnnotedFields() {
+
+		for (Class<?> cl : models) {
+
+			if (LOG.isDebugEnabled()) {
+				LOG.debug("Class retrieved : " + cl.getName());
+			}
+
+			for (Field field : cl.getDeclaredFields()) {
+				DataField dataField = field.getAnnotation(DataField.class);
+				if (dataField != null) {
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Position defined in the class : " + cl.getName() + ", position : " + dataField.pos()
+								+ ", Field : " + dataField.toString());
+					}
+					mapDataField.put(dataField.pos(), dataField);
+					mapAnnotedField.put(dataField.pos(), field);
+				}
+
+				Link linkField = field.getAnnotation(Link.class);
+
+				if (linkField != null) {
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Class linked  : " + cl.getName() + ", Field" + field.toString());
+					}
+					mapAnnotedLinkField.put(cl.getName(), field);
+				}
+			}
+		}
+	}
+
+	public void bind(List<String> data, Map<String, Object> model) throws Exception {
+
+		int pos = 0;
+		while (pos < data.size()) {
+
+			// Set the field with the data received
+			// Only when no empty line is provided
+			// Data is transformed according to the pattern defined or by
+			// default the type of the field (int, double, String, ...)
+
+			if (!data.get(pos).equals("")) {
+
+				DataField dataField = mapDataField.get(pos);
+				ObjectHelper.notNull(dataField, "No position defined for the field positoned : " + pos);
+				Field field = mapAnnotedField.get(pos);
+				field.setAccessible(true);
+
+				if (LOG.isDebugEnabled()) {
+					LOG.debug("Pos : " + pos + ", Data : " + data.get(pos) + ", Field type : " + field.getType());
+				}
+
+				Format<?> format;
+				String pattern = dataField.pattern();
+
+				format = FormatFactory.getFormat(field.getType(), pattern, dataField.precision());
+				field.set(model.get(field.getDeclaringClass().getName()), format.parse(data.get(pos)));
+			}
+			pos++;
+		}
+	}
 
-    private String separator;
-    private boolean skipFirstLine;
-
-    public BindyCsvFactory(PackageScanClassResolver resolver, String packageName) throws Exception {
-        super(resolver, packageName);
-        
-        // initialize specific parameters of the csv model
-        initCsvModel();
-    }
-
-    /**
-     * 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 classes and fields annoted and retrieve the
-     * separator of the CSV record
-     * 
-     * @throws Exception
-     */
-    public void initCsvModel() throws Exception {
-        
-        // Find annotated Datafields declared in the Model classes
-        initAnnotedFields();
-        
-        // initialize Csv parameter(s)
-        // separator and skip first line from @CSVrecord annotation
-        initCsvRecordParameters();
-    }
-    
-    public void initAnnotedFields() {
-        for (Class<?> cl : models) {
-            for (Field field : cl.getDeclaredFields()) {
-                DataField dataField = field.getAnnotation(DataField.class);
-                if (dataField != null) {
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Position defined in the class : " + cl.getName() + ", position : "
-                            + dataField.pos() + ", Field : " + dataField.toString());
-                    }
-                    mapDataField.put(dataField.pos(), dataField);
-                    mapAnnotedField.put(dataField.pos(), field);
-                }
-
-                Link linkField = field.getAnnotation(Link.class);
-
-                if (linkField != null) {
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Class linked  : " + cl.getName() + ", Field" + field.toString());
-                    }
-                    mapAnnotedLinkField.put(cl.getName(), field);
-                }
-            }
-        }
-    }
-
-    public void bind(List<String> data, Map<String, Object> model) throws Exception {
-
-        int pos = 0;
-        while (pos < data.size()) {
-
-            // Set the field with the data received
-            // Only when no empty line is provided
-            // Data is transformed according to the pattern defined or by
-            // default the type of the field (int, double, String, ...)
-
-            if (!data.get(pos).equals("")) {
-
-                DataField dataField = mapDataField.get(pos);
-                ObjectHelper.notNull(dataField, "No position defined for the field positoned : " + pos);
-                Field field = mapAnnotedField.get(pos);
-                field.setAccessible(true);
-                
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Pos : " + pos + ", Data : " + data.get(pos) + ", Field type : " + field.getType());
-                }
-
-                Format<?> format;
-                String pattern = dataField.pattern();
-
-                format = FormatFactory.getFormat(field.getType(), pattern, dataField.precision());
-                field.set(model.get(field.getDeclaringClass().getName()), format.parse(data.get(pos)));
-            }
-            pos++;
-        }
-    }
-
-    public String unbind(Map<String, Object> model) throws Exception {
+	public String unbind(Map<String, Object> model) throws Exception {
 
         StringBuilder builder = new StringBuilder();
 
         Map<Integer, DataField> dataFields = new TreeMap<Integer, DataField>(mapDataField);
         Iterator<Integer> it = dataFields.keySet().iterator();
+        
+		// Map containing the OUT position of the field
+		// The key is double and is created using the position of the field and 
+		// location of the class in the message (using section)
+		Map<Integer, String> positions = new TreeMap<Integer, String>();
 
         // Check if separator exists
         ObjectHelper.notNull(this.separator, "The separator has not been instantiated or property not defined in the @CsvRecord annotation");
+        
+		char separator = Converter.getCharDelimitor(this.getSeparator());
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("Separator converted : '0x" + Integer.toHexString(separator) + "', from : "
+					+ this.getSeparator());
+		}
 
         while (it.hasNext()) {
 
@@ -149,63 +173,143 @@
 
             // Retrieve the format associated to the type
             Format format = FormatFactory.getFormat(field.getType(), dataField.pattern(), dataField.precision());
-            Object obj = model.get(field.getDeclaringClass().getName());
-
-            // Convert the content to a String and append it to the builder
-            builder.append(format.format(field.get(obj)));
-            if (it.hasNext()) {
-                builder.append(this.getSeparator());
-            }
+            
+			// Get object to be formatted
+			Object obj = model.get(field.getDeclaringClass().getName());
+			
+			if (obj != null) {
+
+				if ( this.isMessageOrdered() ) {
+
+					// Generate a key using the number of the section
+					// and the position of the field
+					Integer key1 = sections.get(obj.getClass().getName());
+					Integer key2 = dataField.position();
+					Integer keyGenerated = generateKey(key1, key2);
+					
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Key generated : " + String.valueOf(keyGenerated) + ", for section : " + key1);
+					}					
+
+					// Add the content to the TreeMap according to the position
+					// defined
+					
+					String value = format.format(field.get(obj));
+					positions.put( keyGenerated , value );
+			
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Positions size : " + positions.size());
+					}
+					
+				} else {
+
+					// Convert the content to a String and append it to the builder
+					builder.append(format.format(field.get(obj)));
+					if (it.hasNext()) {
+						builder.append(separator);
+					}
+				}
+			}
         }
+        
+		// Iterate through the list to generate
+		// the message according to the order/position
+		if ( this.isMessageOrdered() ) {
+
+			Iterator<Integer> posit = positions.keySet().iterator();
+			
+			while (posit.hasNext()) {
+				String value = positions.get(posit.next());
+				
+				if (LOG.isDebugEnabled()) {
+					LOG.debug("Value added at the position (" + posit + ") : " + value + separator);
+				}
+				
+				builder.append(value);
+				if (it.hasNext()) {
+					builder.append(separator);
+				}
+			}
+		}
+        
         return builder.toString();
     }
 
-    /**
-     * Find the separator used to delimit the CSV fields
-     */
-    public String getSeparator() {
-        return separator;
-    }
-    
-    /**
-     * Find the separator used to delimit the CSV fields
-     */
-    public boolean getSkipFirstLine() {
-        return skipFirstLine;
-    }
-
-    /**
-     * Get paramaters defined in @Csvrecord annotation
-     */
-    private void initCsvRecordParameters() {
-        if (separator == null) {
-            for (Class<?> cl : models) {
-                // Get annotation @CsvRecord from the class
-                CsvRecord record = cl.getAnnotation(CsvRecord.class);
-
-                if (record != null) {
-
-                    // Get skipFirstLine parameter
-                    skipFirstLine = record.skipFirstLine();
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Skip First Line parameter of the CSV : " + skipFirstLine);
-                    }
-
-                    // Get Separator parameter
-                    ObjectHelper.notNull(record.separator(),
-                        "No separator has been defined in the @Record annotation !");
-                    separator = record.separator();
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Separator defined for the CSV : " + separator);
-                    }
-                    
-                    // Get carriage return parameter
-                    crlf = record.crlf();
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Carriage return defined for the CSV : " + crlf);
-                    }
-                }
-            }
-        }
-    }
+	/**
+	 * Find the separator used to delimit the CSV fields
+	 */
+	public String getSeparator() {
+		return separator;
+	}
+
+	/**
+	 * Find the separator used to delimit the CSV fields
+	 */
+	public boolean getSkipFirstLine() {
+		return skipFirstLine;
+	}
+
+	/**
+	 * Flag indicating if the message must be ordered
+	 * 
+	 * @return boolean
+	 */
+	public boolean isMessageOrdered() {
+		return messageOrdered;
+	}
+
+	/**
+	 * 
+	 * Get paramaters defined in @Csvrecord annotation
+	 * 
+	 */
+	private void initCsvRecordParameters() {
+		if (separator == null) {
+			for (Class<?> cl : models) {
+
+				// Get annotation @CsvRecord from the class
+				CsvRecord record = cl.getAnnotation(CsvRecord.class);
+
+				// Get annotation @Section from the class
+				Section section = cl.getAnnotation(Section.class);
+
+				if (record != null) {
+
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Csv record : " + record.toString());
+					}
+
+					// Get skipFirstLine parameter
+					skipFirstLine = record.skipFirstLine();
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Skip First Line parameter of the CSV : " + skipFirstLine);
+					}
+
+					// Get Separator parameter
+					ObjectHelper.notNull(record.separator(),
+							"No separator has been defined in the @Record annotation !");
+					separator = record.separator();
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Separator defined for the CSV : " + separator);
+					}
+
+					// Get carriage return parameter
+					crlf = record.crlf();
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Carriage return defined for the CSV : " + crlf);
+					}
+				}
+
+				if (section != null) {
+
+					// Test if section number is not null
+					ObjectHelper.notNull(section.nber(), "No number has been defined for the section !");
+
+					// Get section number and add it to the sections
+					sections.put(cl.getName(), section.nber());
+
+				}
+			}
+		}
+	}
 }

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyKeyValuePairFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyKeyValuePairFactory.java?rev=788355&r1=788354&r2=788355&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyKeyValuePairFactory.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyKeyValuePairFactory.java Thu Jun 25 13:33:26 2009
@@ -17,6 +17,7 @@
 package org.apache.camel.dataformat.bindy;
 
 import java.lang.reflect.Field;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -26,6 +27,7 @@
 import org.apache.camel.dataformat.bindy.annotation.KeyValuePairField;
 import org.apache.camel.dataformat.bindy.annotation.Link;
 import org.apache.camel.dataformat.bindy.annotation.Message;
+import org.apache.camel.dataformat.bindy.annotation.Section;
 import org.apache.camel.dataformat.bindy.util.Converter;
 import org.apache.camel.spi.PackageScanClassResolver;
 import org.apache.camel.util.ObjectHelper;
@@ -33,231 +35,316 @@
 import org.apache.commons.logging.LogFactory;
 
 /**
- * The BindyKeyValuePairFactory is the class who allows to bind data of type
- * key value pair. Such format exist in financial messages FIX.
- * This class allows to generate a model associated to message, bind data from a message
- * to the POJOs, export data of POJOs to a message and format data
- * into String, Date, Double, ... according to the format/pattern defined
+ * The BindyKeyValuePairFactory is the class who allows to bind data of type key
+ * value pair. Such format exist in financial messages FIX. This class allows to
+ * generate a model associated to message, bind data from a message to the
+ * POJOs, export data of POJOs to a message and format data into String, Date,
+ * Double, ... according to the format/pattern defined
  */
-public class BindyKeyValuePairFactory extends BindyAbstractFactory implements BindyFactory  {
+public class BindyKeyValuePairFactory extends BindyAbstractFactory implements BindyFactory {
 
-    private static final transient Log LOG = LogFactory.getLog(BindyKeyValuePairFactory.class);
+	private static final transient Log LOG = LogFactory.getLog(BindyKeyValuePairFactory.class);
 
-    private Map<Integer, KeyValuePairField> mapKeyValuePairField = new LinkedHashMap<Integer, KeyValuePairField>();
-    private Map<Integer, Field> mapAnnotedField = new LinkedHashMap<Integer, Field>();
+	private Map<Integer, KeyValuePairField> mapKeyValuePairField = new LinkedHashMap<Integer, KeyValuePairField>();
+	private Map<Integer, Field> mapAnnotedField = new LinkedHashMap<Integer, Field>();
+	private Map<String, Integer> sections = new HashMap<String, Integer>();
+
+	private String keyValuePairSeparator;
+	private String pairSeparator;
+	private boolean messageOrdered;
+
+	public BindyKeyValuePairFactory(PackageScanClassResolver resolver, String... packageNames) throws Exception {
+
+		super(resolver, packageNames);
+
+		// Initialize what is specific to Key Value Pair model
+		initKeyValuePairModel();
+	}
+
+	/**
+	 * 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 classes and fields annoted. Next, we retrieve
+	 * the parameters required like : Pair Separator & key value pair separator
+	 * 
+	 * @throws Exception
+	 */
+	public void initKeyValuePairModel() throws Exception {
+
+		// Find annotated KeyValuePairfields declared in the Model classes
+		initAnnotedFields();
+
+		// Initialize key value pair parameter(s)
+		initMessageParameters();
+
+	}
+
+	public void initAnnotedFields() {
+
+		for (Class<?> cl : models) {
+
+			for (Field field : cl.getDeclaredFields()) {
+				KeyValuePairField keyValuePairField = field.getAnnotation(KeyValuePairField.class);
+				if (keyValuePairField != null) {
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Key declared in the class : " + cl.getName() + ", key : " + keyValuePairField.tag()
+								+ ", Field : " + keyValuePairField.toString());
+					}
+					mapKeyValuePairField.put(keyValuePairField.tag(), keyValuePairField);
+					mapAnnotedField.put(keyValuePairField.tag(), field);
+				}
+
+				Link linkField = field.getAnnotation(Link.class);
+
+				if (linkField != null) {
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Class linked  : " + cl.getName() + ", Field" + field.toString());
+					}
+					mapAnnotedLinkField.put(cl.getName(), field);
+				}
+			}
+
+		}
+	}
+
+	public void bind(List<String> data, Map<String, Object> model) throws Exception {
+
+		int pos = 0;
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("Data : " + data);
+		}
+
+		while (pos < data.size()) {
+
+			if (!data.get(pos).equals("")) {
+
+				// Separate the key from its value
+				// e.g 8=FIX 4.1 --> key = 8 and Value = FIX 4.1
+				ObjectHelper.notNull(this.keyValuePairSeparator,
+						"Key Value Pair not defined in the @Message annotation");
+				String[] keyValuePair = data.get(pos).split(this.getKeyValuePairSeparator());
+
+				int tag = Integer.parseInt(keyValuePair[0]);
+				String value = keyValuePair[1];
+
+				if (LOG.isDebugEnabled()) {
+					LOG.debug("Key : " + tag + ", value : " + value);
+				}
+
+				KeyValuePairField keyValuePairField = mapKeyValuePairField.get(tag);
+				ObjectHelper.notNull(keyValuePairField, "No tag defined for the field : " + tag);
+
+				Field field = mapAnnotedField.get(tag);
+				field.setAccessible(true);
+
+				if (LOG.isDebugEnabled()) {
+					LOG.debug("Tag : " + tag + ", Data : " + value + ", Field type : " + field.getType());
+				}
+
+				Format<?> format;
+				String pattern = keyValuePairField.pattern();
+
+				format = FormatFactory.getFormat(field.getType(), pattern, keyValuePairField.precision());
+				field.set(model.get(field.getDeclaringClass().getName()), format.parse(value));
+
+			}
+
+			pos++;
+		}
+
+	}
+
+	public String unbind(Map<String, Object> model) throws Exception {
+
+		StringBuilder builder = new StringBuilder();
+
+		Map<Integer, KeyValuePairField> keyValuePairFields = new TreeMap<Integer, KeyValuePairField>(mapKeyValuePairField);
+		Iterator<Integer> it = keyValuePairFields.keySet().iterator();
+		
+		// Map containing the OUT position of the field
+		// The key is double and is created using the position of the field and 
+		// location of the class in the message (using section)
+		Map<Integer, String> positions = new TreeMap<Integer, String>();
+
+		// Check if separator exists
+		ObjectHelper.notNull(this.pairSeparator,
+				"The pair separator has not been instantiated or property not defined in the @Message annotation");
+
+		char separator = Converter.getCharDelimitor(this.getPairSeparator());
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("Separator converted : '0x" + Integer.toHexString(separator) + "', from : "
+					+ this.getPairSeparator());
+		}
+
+		while (it.hasNext()) {
+
+			KeyValuePairField keyValuePairField = mapKeyValuePairField.get(it.next());
+			ObjectHelper.notNull(keyValuePairField, "KeyValuePair is null !");
+
+			// Retrieve the field
+			Field field = mapAnnotedField.get(keyValuePairField.tag());
+			// Change accessibility to allow to read protected/private fields
+			field.setAccessible(true);
+
+			if (LOG.isDebugEnabled()) {
+				LOG.debug("Tag : " + keyValuePairField.tag() + ", Field type : " + field.getType() + ", class : " + field.getDeclaringClass().getName());
+			}
+
+			// Retrieve the format associated to the type
+			Format format;
+			String pattern = keyValuePairField.pattern();
+			format = FormatFactory.getFormat(field.getType(), pattern, keyValuePairField.precision());
+
+			// Get object to be formatted
+			Object obj = model.get(field.getDeclaringClass().getName());
+			
+			if (obj != null) {
+
+				if ( this.isMessageOrdered() ) {
+
+					
+					// Generate a key using the number of the section
+					// and the position of the field
+					Integer key1 = sections.get(obj.getClass().getName());
+					Integer key2 = keyValuePairField.position();
+					Integer keyGenerated = generateKey(key1, key2);
+					
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Key generated : " + String.valueOf(keyGenerated) + ", for section : " + key1);
+					}					
+
+					// Add the content to the TreeMap according to the position
+					// defined
+					
+					String value = keyValuePairField.tag() + this.getKeyValuePairSeparator() + format.format(field.get(obj));
+					positions.put( keyGenerated , value );
+
+			
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Positions size : " + positions.size());
+					}
+					
+				} else {
+					// Convert the content to a String and append it to the
+					// builder
+					// Add the tag followed by its key value pair separator
+					// the data and finish by the pair separator
+					String value = keyValuePairField.tag() + this.getKeyValuePairSeparator() + format.format(field.get(obj)) + separator;
+					builder.append(value);
+					
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Value added : " + keyValuePairField.tag() + this.getKeyValuePairSeparator()
+								+ format.format(field.get(obj)) + separator);
+					}
+				}
+			}
+
+		}
+
+		// Iterate through the list to generate
+		// the message according to the order/position
+		if ( this.isMessageOrdered() ) {
+
+			Iterator<Integer> posit = positions.keySet().iterator();
+			
+			while (posit.hasNext()) {
+				String value = positions.get(posit.next());
+				
+				if (LOG.isDebugEnabled()) {
+					LOG.debug("Value added at the position (" + posit + ") : " + value + separator);
+				}
+				
+				builder.append(value + separator);
+			}
+		}
+
+
+		return builder.toString();
+	}
+
+	/**
+	 * Find the pair separator used to delimit the key value pair fields
+	 */
+	public String getPairSeparator() {
+		return pairSeparator;
+	}
+
+	/**
+	 * Find the key value pair separator used to link the key with its value
+	 */
+	public String getKeyValuePairSeparator() {
+		return keyValuePairSeparator;
+	}
+	
+	/**
+	 * Flag indicating if the message must be ordered
+	 * 
+	 * @return boolean
+	 */
+	public boolean isMessageOrdered() {
+		return messageOrdered;
+	}
+	
+
+	/**
+	 * Get parameters defined in @Message annotation
+	 */
+	private void initMessageParameters() {
+
+		if ((pairSeparator == null) || (keyValuePairSeparator == null)) {
+
+			for (Class<?> cl : models) {
+
+				// Get annotation @Message from the class
+				Message message = cl.getAnnotation(Message.class);
+				
+				// Get annotation @Section from the class
+				Section section = cl.getAnnotation(Section.class);
+
+				if (message != null) {
+
+					// Get Pair Separator parameter
+					ObjectHelper.notNull(message.pairSeparator(),
+							"No Pair Separator has been defined in the @Message annotation !");
+					pairSeparator = message.pairSeparator();
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Pair Separator defined for the message : " + pairSeparator);
+					}
+
+					// Get KeyValuePair Separator parameter
+					ObjectHelper.notNull(message.keyValuePairSeparator(),
+							"No Key Value Pair Separator has been defined in the @Message annotation !");
+					keyValuePairSeparator = message.keyValuePairSeparator();
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Key Value Pair Separator defined for the message : " + keyValuePairSeparator);
+					}
+
+					// Get carriage return parameter
+					crlf = message.crlf();
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Carriage return defined for the message : " + crlf);
+					}
+
+					// Get isOrderer parameter
+					messageOrdered = message.isOrdered();
+					if (LOG.isDebugEnabled()) {
+						LOG.debug("Is the message ordered in output : " + messageOrdered);
+					}
+				}
+				
+				if (section != null) {
+					
+					// Test if section number is not null
+					ObjectHelper.notNull(section.nber(), "No number has been defined for the section !");
+					
+					// Get section number and add it to the sections
+					sections.put(cl.getName(), section.nber());
+					
+				}
+			}
+		}
+	}
 
-    private String keyValuePairSeparator;
-    private String pairSeparator;
-
-    public BindyKeyValuePairFactory(PackageScanClassResolver resolver, String packageName) throws Exception {
-        
-        super(resolver, packageName);
-        
-        // Initialize what is specific to Key Value Pair model
-        initKeyValuePairModel();
-    }
-
-    /**
-     * 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 classes and fields annoted. Next, we retrieve the
-     * parameters required like : Pair Separator & key value pair separator
-     * 
-     * @throws Exception
-     */
-    public void initKeyValuePairModel() throws Exception {
-        
-        // Find annotated KeyValuePairfields declared in the Model classes
-        initAnnotedFields();
-        
-        // Initialize key value pair parameter(s) 
-        initMessageParameters();
-
-    }
-    
-    
-    public void initAnnotedFields() {
-
-        for (Class<?> cl : models) {
-
-            for (Field field : cl.getDeclaredFields()) {
-                KeyValuePairField keyValuePairField = field.getAnnotation(KeyValuePairField.class);
-                if (keyValuePairField != null) {
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Key declared in the class : " + cl.getName() + ", key : "
-                            + keyValuePairField.tag() + ", Field : " + keyValuePairField.toString());
-                    }
-                    mapKeyValuePairField.put(keyValuePairField.tag(), keyValuePairField);
-                    mapAnnotedField.put(keyValuePairField.tag(), field);
-                }
-
-                Link linkField = field.getAnnotation(Link.class);
-
-                if (linkField != null) {
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Class linked  : " + cl.getName() + ", Field" + field.toString());
-                    }
-                    mapAnnotedLinkField.put(cl.getName(), field);
-                }
-            }
-
-        }
-    }
-    
-
-    public void bind(List<String> data, Map<String, Object> model) throws Exception {
-
-        int pos = 0;
-        
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Data : " + data);
-        }
-
-        while (pos < data.size()) {
-        
-            if (!data.get(pos).equals("")) {
-           
-                // Separate the key from its value
-                // e.g 8=FIX 4.1 --> key = 8 and Value = FIX 4.1
-                ObjectHelper.notNull(this.keyValuePairSeparator, "Key Value Pair not defined in the @Message annotation");
-                String[] keyValuePair = data.get(pos).split(this.getKeyValuePairSeparator());
-                
-                int tag = Integer.parseInt(keyValuePair[0]);
-                String value = keyValuePair[1];
-                
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Key : " + tag + ", value : " + value);
-                }
-
-                KeyValuePairField keyValuePairField = mapKeyValuePairField.get(tag);
-                ObjectHelper.notNull(keyValuePairField, "No tag defined for the field : " + tag);
-
-                Field field = mapAnnotedField.get(tag);
-                field.setAccessible(true);
-
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Tag : " + tag + ", Data : " + value + ", Field type : " + field.getType());
-                }
-
-                Format<?> format;
-                String pattern = keyValuePairField.pattern();
-
-                format = FormatFactory.getFormat(field.getType(), pattern, keyValuePairField.precision());
-                field.set(model.get(field.getDeclaringClass().getName()), format.parse(value));
-
-            }
-
-            pos++;
-        }
-
-    }
-
-    public String unbind(Map<String, Object> model) throws Exception {
-
-        StringBuilder builder = new StringBuilder();
-
-        Map<Integer, KeyValuePairField> keyValuePairFields = new TreeMap<Integer, KeyValuePairField>(mapKeyValuePairField);
-        Iterator<Integer> it = keyValuePairFields.keySet().iterator();
-
-        // Check if separator exists
-        ObjectHelper.notNull(this.pairSeparator,
-             "The pair separator has not been instantiated or property not defined in the @Message annotation");
-
-        char separator = Converter.getCharDelimitor(this.getPairSeparator());
-
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Separator converted : '0x" + Integer.toHexString(separator) + "', from : " + this.getPairSeparator());
-        }
-
-        while (it.hasNext()) {
-
-            KeyValuePairField keyValuePairField = mapKeyValuePairField.get(it.next());
-            ObjectHelper.notNull(keyValuePairField, "KeyValuePair is null !");
-
-            // Retrieve the field
-            Field field = mapAnnotedField.get(keyValuePairField.tag());
-            // Change accessibility to allow to read protected/private fields
-            field.setAccessible(true);
-
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Tag : " + keyValuePairField.tag() + ", Field type : " + field.getType()
-                    + ", class : " + field.getDeclaringClass().getName());
-            }
-
-            // Retrieve the format associated to the type
-            Format format;
-
-            String pattern = keyValuePairField.pattern();
-            format = FormatFactory.getFormat(field.getType(), pattern, keyValuePairField.precision());
-
-            Object obj = model.get(field.getDeclaringClass().getName());
-
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Model object : " + obj.toString());
-            }
-
-            // Convert the content to a String and append it to the builder
-            // Add the tag followed by its key value pair separator
-            // the data and finish by the pair separator
-            builder.append(keyValuePairField.tag() + this.getKeyValuePairSeparator() 
-                           + format.format(field.get(obj)) + separator);
-        }
-
-        return builder.toString();
-    }
-
-    /**
-     * Find the pair separator used to delimit the key value pair fields
-     */
-    public String getPairSeparator() {
-        return pairSeparator;
-    }
-    
-    /**
-     * Find the key value pair separator used to link the key with its value
-     */
-    public String getKeyValuePairSeparator() {
-        return keyValuePairSeparator;
-    }
-
-    /**
-     * Get parameters defined in @Message annotation
-     */
-    private void initMessageParameters() {
-
-        if ((pairSeparator == null) || (keyValuePairSeparator == null)) {
-
-            for (Class<?> cl : models) {
-                
-                // Get annotation @Message from the class
-                Message message = cl.getAnnotation(Message.class);
-
-                if (message != null) {
-                    
-                    // Get Pair Separator parameter
-                    ObjectHelper.notNull(message.pairSeparator(),
-                        "No Pair Separator has been defined in the @Message annotation !");
-                    pairSeparator = message.pairSeparator();
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Pair Separator defined for the message : " + pairSeparator);
-                    }
-
-                    // Get KeyValuePair Separator parameter
-                    ObjectHelper.notNull(message.keyValuePairSeparator(),
-                        "No Key Value Pair Separator has been defined in the @Message annotation !");
-                    keyValuePairSeparator = message.keyValuePairSeparator();
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Key Value Pair Separator defined for the message : "
-                            + keyValuePairSeparator);
-                    }
-
-                    // Get carriage return parameter
-                    crlf = message.crlf();
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Carriage return defined for the message : " + crlf);
-                    }
-                }
-            }
-        }
-    }
 }

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java?rev=788355&r1=788354&r2=788355&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java Thu Jun 25 13:33:26 2009
@@ -23,11 +23,12 @@
 /**
  * An annotation used to identify in a POJO which property is link to a field of
  * a record (csv, ...).
- * The position (mandatory) identifies the position of the data in the record
+ * The pos (mandatory) identifies the position of the data in the record
  * The name is optional and could be used in the future to bind a property which a different name
  * The pattern (optional) allows to define the pattern of the data (useful for Date, ...)
  * The length (optional) allows to define for fixed length message the size of the data's block
  * The precision(optional) reflects the precision to be used with BigDecimal number
+ * The position (optional) identify the position of the field in the CSV generated
  */
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
@@ -68,5 +69,13 @@
      * @return int
      */
     int precision() default 0;
+    
+    /**
+     * 
+     * Position of the field in the message generated
+     * 
+     * @return int 
+     */
+    int position() default 0;
 
 }

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/KeyValuePairField.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/KeyValuePairField.java?rev=788355&r1=788354&r2=788355&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/KeyValuePairField.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/KeyValuePairField.java Thu Jun 25 13:33:26 2009
@@ -28,6 +28,7 @@
  * The precision (optional) reflects the precision to be used with BigDecimal number
  * The required (optional) field allows to define if the field is required or not. This property is
  * not yet used but will be useful in the future with the validation
+ * The position (optional) field is used to order the tags during the creation of the message
  */
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
@@ -53,6 +54,14 @@
      * @return String
      */
     String pattern() default "";
+    
+    /**
+     * 
+     * Position of the field in the message generated
+     * 
+     * @return int 
+     */
+    int position() default 0;
 
     /**
      * precision of the BigDecimal number to be created

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Message.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Message.java?rev=788355&r1=788354&r2=788355&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Message.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Message.java Thu Jun 25 13:33:26 2009
@@ -21,60 +21,71 @@
 import java.lang.annotation.RetentionPolicy;
 
 /**
- * This annotation represents the root class of the model. When a message (FIX message
- * containing key-value pairs) must be described in the model, we will use this
- * annotation.
-
- * The key pair separator (mandatory) defines the separator between the key and the value
- * The pair separator (mandatory) allows to define which character separate the pairs from each other
- * The name is optional and could be used in the future to bind a property which a different name
- * The type (optional) allow to define the type of the message (e.g. FIX, EMX, ...)
- * The version (optional) defines the version of the message (e.g. 4.1, ...)
- * The crlf (optional) is used to add a new line after a record. By default, the value is WINDOWS 
- * (line feed and carriage return on windows 
+ * This annotation represents the root class of the model. When a message (FIX
+ * message containing key-value pairs) must be described in the model, we will
+ * use this annotation.
+ * 
+ * The key pair separator (mandatory) defines the separator between the key and
+ * the value The pair separator (mandatory) allows to define which character
+ * separate the pairs from each other The name is optional and could be used in
+ * the future to bind a property which a different name The type (optional)
+ * allow to define the type of the message (e.g. FIX, EMX, ...) The version
+ * (optional) defines the version of the message (e.g. 4.1, ...) The crlf
+ * (optional) is used to add a new line after a record. By default, the value is
+ * WINDOWS The isOrdered (optional) boolean is used to ordered the message
+ * generated in output (line feed and carriage return on windows
  */
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Message {
 
-    /**
-     * Name describing the message (optional)
-     * 
-     * @return String
-     */
-    String name() default "";
-
-    /**
-     * Pair separator used to split the key value pairs in tokens (mandatory)
-     * 
-     * @return String
-     */
-    String pairSeparator();
-    
-    /**
-     * Key value pair separator is used to split the values from their keys (mandatory)
-     * 
-     * @return String
-     */
-    String keyValuePairSeparator();
-    
-    
-    /**
-     * type is used to define the type of the message (e.g. FIX, EMX, ...) (optional)
-     */
-    String type() default "FIX";
-    
-    /**
-     * version defines the version of the message (e.g. 4.1, ...) (optional)
-     */
-    String version() default "4.1";
-    
-    /**
-     * Character to be used to add a carriage return after each record (optional)
-     * Three values can be used : WINDOWS, UNIX or MAC
-     * 
-     * @return String
-     */
-    String crlf() default "WINDOWS";
+	/**
+	 * Name describing the message (optional)
+	 * 
+	 * @return String
+	 */
+	String name() default "";
+
+	/**
+	 * Pair separator used to split the key value pairs in tokens (mandatory)
+	 * 
+	 * @return String
+	 */
+	String pairSeparator();
+
+	/**
+	 * Key value pair separator is used to split the values from their keys
+	 * (mandatory)
+	 * 
+	 * @return String
+	 */
+	String keyValuePairSeparator();
+
+	/**
+	 * type is used to define the type of the message (e.g. FIX, EMX, ...)
+	 * (optional)
+	 */
+	String type() default "FIX";
+
+	/**
+	 * version defines the version of the message (e.g. 4.1, ...) (optional)
+	 */
+	String version() default "4.1";
+
+	/**
+	 * Character to be used to add a carriage return after each record
+	 * (optional) Three values can be used : WINDOWS, UNIX or MAC
+	 * 
+	 * @return String
+	 */
+	String crlf() default "WINDOWS";
+
+	/**
+	 * 
+	 * Indicates if the message must be ordered in output
+	 * 
+	 * @return boolean
+	 */
+	boolean isOrdered() default false;
 
 }

Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Section.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Section.java?rev=788355&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Section.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Section.java Thu Jun 25 13:33:26 2009
@@ -0,0 +1,40 @@
+package org.apache.camel.dataformat.bindy.annotation;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * This annotation allows to define during
+ * the marshaling process how a message
+ * must be reconstruct
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Section {
+
+	/**
+	 * 	 * N° of the section
+	 * 
+	 * @return 
+	 */
+	int nber();
+
+}

Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Section.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java?rev=788355&r1=788354&r2=788355&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java Thu Jun 25 13:33:26 2009
@@ -55,6 +55,8 @@
     public void marshal(Exchange exchange, Object body, OutputStream outputStream) throws Exception {
     
         BindyCsvFactory factory = getFactory(exchange.getContext().getPackageScanClassResolver());
+        ObjectHelper.notNull(factory, "not instantiated");
+        
         List<Map<String, Object>> models = (ArrayList<Map<String, Object>>) body;
         byte[] bytesCRLF;
      
@@ -73,6 +75,7 @@
 
     public Object unmarshal(Exchange exchange, InputStream inputStream) throws Exception {
         BindyCsvFactory factory = getFactory(exchange.getContext().getPackageScanClassResolver());
+        ObjectHelper.notNull(factory, "not instantiated");
 
         // List of Pojos
         List<Map<String, Object>> models = new ArrayList<Map<String, Object>>();
@@ -87,7 +90,7 @@
 
         // Retrieve the separator defined to split the record
         String separator = factory.getSeparator();
-        ObjectHelper.notEmpty(separator, "The separator has not been defined in the annotation @Record or not instantiated during initModel.");
+        ObjectHelper.notEmpty(separator, "The separator has not been defined in the annotation @CsvRecord or not instantiated during initModel.");
 
         int count = 0;
         try {

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java?rev=788355&r1=788354&r2=788355&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java Thu Jun 25 13:33:26 2009
@@ -43,14 +43,14 @@
     
     private static final transient Log LOG = LogFactory.getLog(BindyKeyValuePairDataFormat.class);
     
-    private String packageName;
+    private String[] packageNames;
     private BindyKeyValuePairFactory modelFactory;
 
     public BindyKeyValuePairDataFormat() {
     }
 
-    public BindyKeyValuePairDataFormat(String packageName) {
-        this.packageName = packageName;
+    public BindyKeyValuePairDataFormat(String... packageNames) {
+        this.packageNames = packageNames;
     }
 
     @SuppressWarnings("unchecked")
@@ -142,7 +142,7 @@
      */
     public BindyKeyValuePairFactory getFactory(PackageScanClassResolver resolver) throws Exception {
         if (modelFactory == null) {
-            modelFactory = new BindyKeyValuePairFactory(resolver, this.packageName);
+            modelFactory = new BindyKeyValuePairFactory(resolver, this.packageNames);
         }
         return modelFactory;
     }
@@ -151,12 +151,12 @@
         this.modelFactory = modelFactory;
     }
 
-    public String getPackageName() {
-        return packageName;
+    public String[] getPackageNames() {
+        return packageNames;
     }
 
-    public void setPackageName(String packageName) {
-        this.packageName = packageName;
+    public void setPackageNames(String... packageNames) {
+        this.packageNames = packageNames;
     }
 
 }

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/util/AnnotationModelLoader.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/util/AnnotationModelLoader.java?rev=788355&r1=788354&r2=788355&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/util/AnnotationModelLoader.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/util/AnnotationModelLoader.java Thu Jun 25 13:33:26 2009
@@ -23,6 +23,7 @@
 import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
 import org.apache.camel.dataformat.bindy.annotation.Link;
 import org.apache.camel.dataformat.bindy.annotation.Message;
+import org.apache.camel.dataformat.bindy.annotation.Section;
 import org.apache.camel.spi.PackageScanClassResolver;
 
 /**
@@ -40,10 +41,11 @@
         annotations.add(CsvRecord.class);
         annotations.add(Link.class);
         annotations.add(Message.class);
+        annotations.add(Section.class);
     }
 
-    public Set<Class> loadModels(String packageName) throws Exception {
-        return resolver.findAnnotated(annotations, packageName);
+    public Set<Class> loadModels(String... packageNames) throws Exception {
+        return resolver.findAnnotated(annotations, packageNames);
     }
 
 }

Modified: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairMarshallTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairMarshallTest.java?rev=788355&r1=788354&r2=788355&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairMarshallTest.java (original)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairMarshallTest.java Thu Jun 25 13:33:26 2009
@@ -52,8 +52,8 @@
 
     @Test
     public void testMarshallMessage() throws Exception {
-        resultEndpoint.expectedBodiesReceived(result);
-
+ 
+    	resultEndpoint.expectedBodiesReceived(result);
         template.sendBody(generateModel());
 
         resultEndpoint.assertIsSatisfied();

Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairSortedMarshallTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairSortedMarshallTest.java?rev=788355&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairSortedMarshallTest.java (added)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairSortedMarshallTest.java Thu Jun 25 13:33:26 2009
@@ -0,0 +1,120 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.bindy.fix;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.bindy.kvp.BindyKeyValuePairDataFormat;
+import org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header;
+import org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order;
+import org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer;
+import org.apache.camel.spring.javaconfig.SingleRouteCamelConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Test;
+import org.springframework.config.java.annotation.Bean;
+import org.springframework.config.java.annotation.Configuration;
+import org.springframework.config.java.test.JavaConfigContextLoader;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+@ContextConfiguration(locations = "org.apache.camel.dataformat.bindy.fix.BindySimpleKeyValuePairSortedMarshallTest$ContextConfig", loader = JavaConfigContextLoader.class)
+public class BindySimpleKeyValuePairSortedMarshallTest extends AbstractJUnit4SpringContextTests {
+
+	private static final transient Log LOG = LogFactory.getLog(BindySimpleKeyValuePairSortedMarshallTest.class);
+
+	private List<Map<String, Object>> models = new ArrayList<Map<String, Object>>();
+	private String result = "8=FIX 4.19=2035=034=149=INVMGR56=BRKR1=BE.CHM.00122=411=CHM0001-0148=BE000124567854=158=this is a camel - bindy test10=220\r\n";
+
+	@Produce(uri = "direct:start")
+	private ProducerTemplate template;
+
+	@EndpointInject(uri = "mock:result")
+	private MockEndpoint resultEndpoint;
+
+	@Test
+	public void testMarshallMessage() {
+
+		resultEndpoint.expectedBodiesReceived(result);
+		template.sendBody(generateModel());
+
+		try {
+			resultEndpoint.assertIsSatisfied();
+		} catch (InterruptedException e) {
+			LOG.error("Unit test error : ", e);
+		}
+	}
+
+	public List<Map<String, Object>> generateModel() {
+		Map<String, Object> modelObjects = new HashMap<String, Object>();
+
+		Header header = new Header();
+		header.setBeginString("FIX 4.1");
+		header.setBodyLength(20);
+		header.setMsgSeqNum(1);
+		header.setMsgType("0");
+		header.setSendCompId("INVMGR");
+		header.setTargetCompId("BRKR");
+
+		Trailer trailer = new Trailer();
+		trailer.setCheckSum(220);
+
+		Order order = new Order();
+		order.setAccount("BE.CHM.001");
+		order.setClOrdId("CHM0001-01");
+		order.setIDSource("4");
+		order.setSecurityId("BE0001245678");
+		order.setSide("1");
+		order.setText("this is a camel - bindy test");
+
+		order.setHeader(header);
+		order.setTrailer(trailer);
+
+		modelObjects.put(order.getClass().getName(), order);
+		modelObjects.put(header.getClass().getName(), header);
+		modelObjects.put(trailer.getClass().getName(), trailer);
+
+		models.add(modelObjects);
+
+		return models;
+	}
+
+	@Configuration
+	public static class ContextConfig extends SingleRouteCamelConfiguration {
+		BindyKeyValuePairDataFormat camelDataFormat = new BindyKeyValuePairDataFormat(
+				"org.apache.camel.dataformat.bindy.model.fix.sorted");
+
+		@Override
+		@Bean
+		public RouteBuilder route() {
+			return new RouteBuilder() {
+				@Override
+				public void configure() {
+					from("direct:start").marshal(camelDataFormat).to("mock:result");
+				}
+			};
+		}
+	}
+}

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairSortedMarshallTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairTabMarshallTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairTabMarshallTest.java?rev=788355&r1=788354&r2=788355&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairTabMarshallTest.java (original)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairTabMarshallTest.java Thu Jun 25 13:33:26 2009
@@ -53,8 +53,8 @@
 
     @Test
     public void testMarshallMessage() throws Exception {
-        resultEndpoint.expectedBodiesReceived(result);
-
+ 
+    	resultEndpoint.expectedBodiesReceived(result);
         template.sendBody(generateModel());
 
         resultEndpoint.assertIsSatisfied();

Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/body/Order.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/body/Order.java?rev=788355&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/body/Order.java (added)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/body/Order.java Thu Jun 25 13:33:26 2009
@@ -0,0 +1,123 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.bindy.model.fix.sorted.body;
+
+import org.apache.camel.dataformat.bindy.annotation.KeyValuePairField;
+import org.apache.camel.dataformat.bindy.annotation.Link;
+import org.apache.camel.dataformat.bindy.annotation.Message;
+import org.apache.camel.dataformat.bindy.annotation.Section;
+import org.apache.camel.dataformat.bindy.model.fix.sorted.header.Header;
+import org.apache.camel.dataformat.bindy.model.fix.sorted.trailer.Trailer;
+
+@Section(nber = 2)
+@Message(keyValuePairSeparator = "=", pairSeparator = "\\u0001", type = "FIX", version = "4.1", isOrdered = true)
+public class Order {
+    
+    @Link Header header;
+    
+    @Link Trailer trailer;
+
+    @KeyValuePairField(tag = 1, position = 1) // Client reference
+    private String account;
+
+    @KeyValuePairField(tag = 11, position = 3) // Order reference
+    private String clOrdId;
+    
+    @KeyValuePairField(tag = 22, position = 2) // Fund ID type (Sedol, ISIN, ...)
+    private String iDSource;
+    
+    @KeyValuePairField(tag = 48, position = 4) // Fund code
+    private String securityId;
+    
+    @KeyValuePairField(tag = 54, position = 5) // Movement type ( 1 = Buy, 2 = sell)
+    private String side;
+    
+    @KeyValuePairField(tag = 58, position = 6) // Free text
+    private String text;
+
+    public Header getHeader() {
+        return header;
+    }
+
+    public void setHeader(Header header) {
+        this.header = header;
+    }
+
+    public Trailer getTrailer() {
+        return trailer;
+    }
+
+    public void setTrailer(Trailer trailer) {
+        this.trailer = trailer;
+    }
+ 
+    public String getAccount() {
+        return account;
+    }
+
+    public void setAccount(String account) {
+        this.account = account;
+    }
+
+    public String getClOrdId() {
+        return clOrdId;
+    }
+
+    public void setClOrdId(String clOrdId) {
+        this.clOrdId = clOrdId;
+    }
+
+    public String getIDSource() {
+        return iDSource;
+    }
+
+    public void setIDSource(String source) {
+        this.iDSource = source;
+    }
+
+    public String getSecurityId() {
+        return securityId;
+    }
+
+    public void setSecurityId(String securityId) {
+        this.securityId = securityId;
+    }
+
+    public String getSide() {
+        return side;
+    }
+
+    public void setSide(String side) {
+        this.side = side;
+    }
+
+    public String getText() {
+        return this.text;
+    }
+
+    public void setText(String text) {
+        this.text = text;
+    }
+    
+    @Override
+    public String toString() {
+        return "Model : " + Order.class.getName() + ", " + this.account
+            + ", " + this.clOrdId + ", " + this.iDSource + ", " + this.securityId
+            + ", " + this.side + ", " + this.text;
+    }
+
+}

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/body/Order.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/header/Header.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/header/Header.java?rev=788355&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/header/Header.java (added)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/header/Header.java Thu Jun 25 13:33:26 2009
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.bindy.model.fix.sorted.header;
+
+import org.apache.camel.dataformat.bindy.annotation.KeyValuePairField;
+import org.apache.camel.dataformat.bindy.annotation.Link;
+import org.apache.camel.dataformat.bindy.annotation.Message;
+import org.apache.camel.dataformat.bindy.annotation.Section;
+
+@Link
+@Section(nber = 1)
+public class Header {
+
+    @KeyValuePairField(tag = 8, position = 1) // Message Header
+    private String beginString;
+
+    @KeyValuePairField(tag = 9, position = 2) // Checksum
+    private int bodyLength;
+    
+    @KeyValuePairField(tag = 34, position = 4) // Sequence number
+    private int msgSeqNum;
+    
+    @KeyValuePairField(tag = 35, position = 3) // Message Type
+    private String msgType;
+
+    @KeyValuePairField(tag = 49, position = 5) // Company sender Id
+    private String sendCompId;
+    
+    @KeyValuePairField(tag = 56, position = 6) // target company id
+    private String targetCompId;
+
+    public String getBeginString() {
+        return beginString;
+    }
+
+    public void setBeginString(String beginString) {
+        this.beginString = beginString;
+    }
+
+    public int getBodyLength() {
+        return bodyLength;
+    }
+
+    public void setBodyLength(int bodyLength) {
+        this.bodyLength = bodyLength;
+    }
+
+    public int getMsgSeqNum() {
+        return msgSeqNum;
+    }
+
+    public void setMsgSeqNum(int msgSeqNum) {
+        this.msgSeqNum = msgSeqNum;
+    }
+
+    public String getMsgType() {
+        return msgType;
+    }
+
+    public void setMsgType(String msgType) {
+        this.msgType = msgType;
+    }
+
+    public String getSendCompId() {
+        return sendCompId;
+    }
+
+    public void setSendCompId(String sendCompId) {
+        this.sendCompId = sendCompId;
+    }
+
+    public String getTargetCompId() {
+        return targetCompId;
+    }
+
+    public void setTargetCompId(String targetCompId) {
+        this.targetCompId = targetCompId;
+    }
+    
+    @Override
+    public String toString() {
+        return "Model : " + Header.class.getName()
+            + ", " + this.beginString + ", " + this.bodyLength + ", " + this.msgSeqNum
+            + this.msgType + ", " + this.sendCompId + ", " + this.targetCompId;
+    }
+
+}

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/header/Header.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/trailer/Trailer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/trailer/Trailer.java?rev=788355&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/trailer/Trailer.java (added)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/trailer/Trailer.java Thu Jun 25 13:33:26 2009
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.bindy.model.fix.sorted.trailer;
+
+import org.apache.camel.dataformat.bindy.annotation.KeyValuePairField;
+import org.apache.camel.dataformat.bindy.annotation.Link;
+import org.apache.camel.dataformat.bindy.annotation.Message;
+import org.apache.camel.dataformat.bindy.annotation.Section;
+
+@Link
+@Section(nber = 3)
+public class Trailer {
+
+    @KeyValuePairField(tag = 10, position = 1)
+    // CheckSum
+    private int checkSum;
+
+    public int getCheckSum() {
+        return checkSum;
+    }
+
+    public void setCheckSum(int checkSum) {
+        this.checkSum = checkSum;
+    }
+
+    @Override
+    public String toString() {
+        return "Model : " + Trailer.class.getName() + ", " + this.checkSum;
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/fix/sorted/trailer/Trailer.java
------------------------------------------------------------------------------
    svn:eol-style = native