You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/05/21 10:39:04 UTC

[3/4] camel git commit: CAMEL-9954: FormatFactory should be real Factory-pattern

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ShortPatternFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ShortPatternFormat.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ShortPatternFormat.java
deleted file mode 100755
index 6d16bbd..0000000
--- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ShortPatternFormat.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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.format;
-
-import java.util.Locale;
-
-public class ShortPatternFormat extends NumberPatternFormat<Short> {
-
-    public ShortPatternFormat() {
-    }
-
-    public ShortPatternFormat(String pattern, Locale locale) {
-        super(pattern, locale);
-    }
-
-    @Override
-    public Short parse(String string) throws Exception {
-        if (getNumberFormat() != null) {
-            return getNumberFormat().parse(string).shortValue();
-        } else {
-            return Short.valueOf(string);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/StringFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/StringFormat.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/StringFormat.java
deleted file mode 100755
index 7323906..0000000
--- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/StringFormat.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.format;
-
-import org.apache.camel.dataformat.bindy.Format;
-
-public class StringFormat implements Format<String> {
-
-    public String format(String object) throws Exception {
-        return object;
-    }
-
-    public String parse(String string) throws Exception {
-        return string;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/AbstractFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/AbstractFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/AbstractFormatFactory.java
new file mode 100644
index 0000000..39c89ab
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/AbstractFormatFactory.java
@@ -0,0 +1,37 @@
+/**
+ * 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.format.factories;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+
+public abstract class AbstractFormatFactory implements FormatFactoryInterface {
+    protected final List<Class<?>> supportedClasses = new ArrayList<>();
+
+    @Override
+    public Collection<Class<?>> supportedClasses() {
+        return Collections.unmodifiableList(supportedClasses);
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return supportedClasses.contains(formattingOptions.getClazz());
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BigDecimalFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BigDecimalFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BigDecimalFormatFactory.java
new file mode 100644
index 0000000..3159c36
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BigDecimalFormatFactory.java
@@ -0,0 +1,70 @@
+/**
+ * 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.format.factories;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.Locale;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.AbstractNumberFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class BigDecimalFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(BigDecimal.class);
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions) && ObjectHelper.isEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new BigDecimalFormat(formattingOptions.isImpliedDecimalSeparator(),
+                formattingOptions.getPrecision(),
+                formattingOptions.getLocale());
+    }
+
+    private static class BigDecimalFormat extends AbstractNumberFormat<BigDecimal> {
+
+        BigDecimalFormat(boolean impliedDecimalPosition, int precision, Locale locale) {
+            super(impliedDecimalPosition, precision, locale);
+        }
+
+        public String format(BigDecimal object) throws Exception {
+            return !super.hasImpliedDecimalPosition()
+                    ? super.getFormat().format(object)
+                    : super.getFormat().format(object.multiply(new BigDecimal(super.getMultiplier())));
+        }
+
+        public BigDecimal parse(String string) throws Exception {
+            BigDecimal result = new BigDecimal(string.trim());
+            if (super.hasImpliedDecimalPosition()) {
+                result = result.divide(new BigDecimal(super.getMultiplier()), super.getPrecision(), RoundingMode.HALF_EVEN);
+            } else {
+                if (super.getPrecision() != -1) {
+                    result = result.setScale(super.getPrecision());
+                }
+            }
+            return result;
+        }
+
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BigDecimalPatternFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BigDecimalPatternFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BigDecimalPatternFormatFactory.java
new file mode 100644
index 0000000..c294be3
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BigDecimalPatternFormatFactory.java
@@ -0,0 +1,71 @@
+/**
+ * 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.format.factories;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.DecimalFormat;
+import java.util.Locale;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.NumberPatternFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class BigDecimalPatternFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(BigDecimal.class);
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions) && ObjectHelper.isNotEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new BigDecimalPatternFormat(formattingOptions.getPattern(),
+                formattingOptions.getLocale(),
+                formattingOptions.getPrecision(),
+                formattingOptions.getRounding(),
+                formattingOptions.getDecimalSeparator(),
+                formattingOptions.getGroupingSeparator());
+    }
+
+    private static class BigDecimalPatternFormat extends NumberPatternFormat<BigDecimal> {
+
+        BigDecimalPatternFormat(String pattern, Locale locale, int precision, String rounding, String decimalSeparator, String groupingSeparator) {
+            super(pattern, locale, precision, rounding, decimalSeparator, groupingSeparator);
+        }
+
+        @Override
+        public BigDecimal parse(String string) throws Exception {
+            if (getNumberFormat() != null) {
+                DecimalFormat df = (DecimalFormat)getNumberFormat();
+                df.setParseBigDecimal(true);
+                BigDecimal bd = (BigDecimal)df.parse(string.trim());
+                if (super.getPrecision() != -1) {
+                    bd = bd.setScale(super.getPrecision(), RoundingMode.valueOf(super.getRounding()));
+                }
+                return bd;
+            } else {
+                return new BigDecimal(string.trim());
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BigIntegerFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BigIntegerFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BigIntegerFormatFactory.java
new file mode 100644
index 0000000..a8a72fb
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BigIntegerFormatFactory.java
@@ -0,0 +1,53 @@
+/**
+ * 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.format.factories;
+
+import java.math.BigInteger;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.AbstractNumberFormat;
+
+public class BigIntegerFormatFactory extends AbstractFormatFactory {
+
+    private static final BigIntegerFormat BIG_INTEGER_FORMAT = new BigIntegerFormat();
+
+    {
+        supportedClasses.add(BigInteger.class);
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions);
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return BIG_INTEGER_FORMAT;
+    }
+
+    private static class BigIntegerFormat extends AbstractNumberFormat<BigInteger> {
+
+        public String format(BigInteger object) throws Exception {
+            return object.toString();
+        }
+
+        public BigInteger parse(String string) throws Exception {
+            return new BigInteger(string);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BooleanFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BooleanFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BooleanFormatFactory.java
new file mode 100755
index 0000000..bc150e8
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BooleanFormatFactory.java
@@ -0,0 +1,47 @@
+/**
+ * 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.format.factories;
+
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+
+public class BooleanFormatFactory extends AbstractFormatFactory {
+
+    private static final BooleanFormat BOOLEAN_FORMAT = new BooleanFormat();
+
+    {
+        supportedClasses.add(boolean.class);
+        supportedClasses.add(Boolean.class);
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return BOOLEAN_FORMAT;
+    }
+
+    private static class BooleanFormat implements Format<Boolean> {
+
+        public String format(Boolean object) throws Exception {
+            return object.toString();
+        }
+
+        public Boolean parse(String string) throws Exception {
+            return Boolean.valueOf(string);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ByteFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ByteFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ByteFormatFactory.java
new file mode 100644
index 0000000..457270f
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ByteFormatFactory.java
@@ -0,0 +1,54 @@
+/**
+ * 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.format.factories;
+
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.util.ObjectHelper;
+
+public class ByteFormatFactory extends AbstractFormatFactory {
+
+    private static final ByteFormat BYTE_FORMAT = new ByteFormat();
+
+    {
+        supportedClasses.add(byte.class);
+        supportedClasses.add(Byte.class);
+    }
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions)
+                && ObjectHelper.isEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return BYTE_FORMAT;
+    }
+
+    private static class ByteFormat implements Format<Byte> {
+
+        public String format(Byte object) throws Exception {
+            return object.toString();
+        }
+
+        public Byte parse(String string) throws Exception {
+            return new Byte(string);
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BytePatternFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BytePatternFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BytePatternFormatFactory.java
new file mode 100644
index 0000000..b795c35
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/BytePatternFormatFactory.java
@@ -0,0 +1,60 @@
+/**
+ * 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.format.factories;
+
+import java.util.Locale;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.NumberPatternFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class BytePatternFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(byte.class);
+        supportedClasses.add(Byte.class);
+    }
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions)
+                && ObjectHelper.isNotEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new BytePatternFormat(formattingOptions.getPattern(),
+                formattingOptions.getLocale());
+    }
+
+    private static class BytePatternFormat extends NumberPatternFormat<Byte> {
+
+        BytePatternFormat(String pattern, Locale locale) {
+            super(pattern, locale);
+        }
+
+        @Override
+        public Byte parse(String string) throws Exception {
+            if (getNumberFormat() != null) {
+                return getNumberFormat().parse(string).byteValue();
+            } else {
+                return Byte.valueOf(string);
+            }
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/CharacterFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/CharacterFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/CharacterFormatFactory.java
new file mode 100644
index 0000000..83786c7
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/CharacterFormatFactory.java
@@ -0,0 +1,51 @@
+/**
+ * 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.format.factories;
+
+import java.text.ParseException;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+
+public class CharacterFormatFactory extends AbstractFormatFactory {
+
+    private static final CharacterFormat CHARACTER_FORMAT = new CharacterFormat();
+
+    {
+        supportedClasses.add(char.class);
+        supportedClasses.add(Character.class);
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return CHARACTER_FORMAT;
+    }
+
+    private static class CharacterFormat implements Format<Character> {
+
+        public String format(Character object) throws Exception {
+            return object.toString();
+        }
+
+        public Character parse(String string) throws Exception {
+            if (string.length() > 1) {
+                throw new ParseException("The string \"" + string + "\" cannot be parsed to a character (size > 1).", 1);
+            }
+            return string.charAt(0);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/DateFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/DateFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/DateFormatFactory.java
new file mode 100644
index 0000000..40582f3
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/DateFormatFactory.java
@@ -0,0 +1,114 @@
+/**
+ * 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.format.factories;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.PatternFormat;
+import org.apache.camel.dataformat.bindy.format.FormatException;
+import org.apache.camel.util.ObjectHelper;
+
+public class DateFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(Date.class);
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new DatePatternFormat(formattingOptions.getPattern(),
+                formattingOptions.getTimezone(),
+                formattingOptions.getLocale());
+    }
+
+    private static class DatePatternFormat implements PatternFormat<Date> {
+
+        private String pattern;
+        private Locale locale;
+        private TimeZone timezone;
+
+        DatePatternFormat(String pattern, String timezone, Locale locale) {
+            this.pattern = pattern;
+            this.locale = locale;
+            if (!timezone.isEmpty()) {
+                this.timezone = TimeZone.getTimeZone(timezone);
+            }
+        }
+
+        public String format(Date object) throws Exception {
+            ObjectHelper.notNull(this.pattern, "pattern");
+            return this.getDateFormat().format(object);
+        }
+
+        public Date parse(String string) throws Exception {
+
+            Date date;
+            DateFormat df = this.getDateFormat();
+
+            ObjectHelper.notNull(this.pattern, "pattern");
+
+            // Check length of the string with date pattern
+            // To avoid to parse a string date : 20090901-10:32:30 when
+            // the pattern is yyyyMMdd
+
+            if (string.length() <= this.pattern.length()) {
+
+                // Force the parser to be strict in the syntax of the date to be
+                // converted
+                df.setLenient(false);
+                date = df.parse(string);
+
+                return date;
+
+            } else {
+                throw new FormatException("Date provided does not fit the pattern defined");
+            }
+
+        }
+
+        protected java.text.DateFormat getDateFormat() {
+            SimpleDateFormat result;
+            if (locale != null) {
+                result = new SimpleDateFormat(pattern, locale);
+            } else {
+                result = new SimpleDateFormat(pattern);
+            }
+            if (timezone != null) {
+                result.setTimeZone(timezone);
+            }
+            return result;
+        }
+
+        public String getPattern() {
+            return pattern;
+        }
+
+        /**
+         * Sets the pattern
+         *
+         * @param pattern the pattern
+         */
+        public void setPattern(String pattern) {
+            this.pattern = pattern;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/DoubleFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/DoubleFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/DoubleFormatFactory.java
new file mode 100644
index 0000000..9cb44b1
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/DoubleFormatFactory.java
@@ -0,0 +1,71 @@
+/**
+ * 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.format.factories;
+
+import java.math.BigDecimal;
+import java.util.Locale;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.AbstractNumberFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class DoubleFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(double.class);
+        supportedClasses.add(Double.class);
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions)
+                && ObjectHelper.isEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new DoubleFormat(formattingOptions.isImpliedDecimalSeparator(),
+                formattingOptions.getPrecision(),
+                formattingOptions.getLocale());
+    }
+
+    private static class DoubleFormat extends AbstractNumberFormat<Double> {
+
+        DoubleFormat(boolean impliedDecimalPosition, int precision, Locale locale) {
+            super(impliedDecimalPosition, precision, locale);
+        }
+
+        public String format(Double object) throws Exception {
+            return !super.hasImpliedDecimalPosition()
+                    ? super.getFormat().format(object)
+                    : super.getFormat().format(object * super.getMultiplier());
+        }
+
+        public Double parse(String string) throws Exception {
+            Double value = null;
+            if (!super.hasImpliedDecimalPosition()) {
+                value = Double.parseDouble(string.trim());
+            } else {
+                BigDecimal tmp = new BigDecimal(string.trim());
+                BigDecimal div = BigDecimal.valueOf(super.getMultiplier());
+                value = tmp.divide(div).doubleValue();
+            }
+
+            return value;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/DoublePatternFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/DoublePatternFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/DoublePatternFormatFactory.java
new file mode 100644
index 0000000..0aade73
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/DoublePatternFormatFactory.java
@@ -0,0 +1,61 @@
+/**
+ * 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.format.factories;
+
+import java.util.Locale;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.NumberPatternFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class DoublePatternFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(double.class);
+        supportedClasses.add(Double.class);
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions)
+                && ObjectHelper.isNotEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new DoublePatternFormat(formattingOptions.getPattern(),
+                formattingOptions.getLocale());
+    }
+
+    private static class DoublePatternFormat extends NumberPatternFormat<Double> {
+
+        DoublePatternFormat(String pattern, Locale locale) {
+            super(pattern, locale);
+        }
+
+        @Override
+        public Double parse(String string) throws Exception {
+            if (getNumberFormat() != null) {
+                return getNumberFormat().parse(string).doubleValue();
+            } else {
+                return Double.valueOf(string);
+            }
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/EnumFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/EnumFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/EnumFormatFactory.java
new file mode 100644
index 0000000..a5639da
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/EnumFormatFactory.java
@@ -0,0 +1,53 @@
+/**
+ * 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.format.factories;
+
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+
+public class EnumFormatFactory extends AbstractFormatFactory {
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return formattingOptions.getClazz().isEnum();
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        @SuppressWarnings({"rawtypes", "unchecked"})
+        EnumFormat enumFormat = new EnumFormat(formattingOptions.getClazz());
+        return enumFormat;
+    }
+
+    private static class EnumFormat<T extends Enum<T>> implements Format<T> {
+
+        private final Class<T> clazz;
+
+        EnumFormat(Class<T> clazz) {
+            this.clazz = clazz;
+        }
+
+        public String format(final T object) throws Exception {
+            return object.name();
+        }
+
+        public T parse(final String string) throws Exception {
+            return Enum.valueOf(clazz, string);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FloatFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FloatFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FloatFormatFactory.java
new file mode 100644
index 0000000..f2a3031
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FloatFormatFactory.java
@@ -0,0 +1,72 @@
+/**
+ * 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.format.factories;
+
+import java.math.BigDecimal;
+import java.util.Locale;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.AbstractNumberFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class FloatFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(float.class);
+        supportedClasses.add(Float.class);
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions)
+                && ObjectHelper.isEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new FloatFormat(formattingOptions.isImpliedDecimalSeparator(),
+                formattingOptions.getPrecision(),
+                formattingOptions.getLocale());
+    }
+
+    private static class FloatFormat extends AbstractNumberFormat<Float> {
+
+        FloatFormat(boolean impliedDecimalPosition, int precision, Locale locale) {
+            super(impliedDecimalPosition, precision, locale);
+        }
+
+        public String format(Float object) throws Exception {
+            return !super.hasImpliedDecimalPosition()
+                    ? super.getFormat().format(object)
+                    : super.getFormat().format(object * super.getMultiplier());
+        }
+
+        public Float parse(String string) throws Exception {
+            Float value;
+            if (!super.hasImpliedDecimalPosition()) {
+                value = Float.parseFloat(string.trim());
+            } else {
+                BigDecimal tmp = new BigDecimal(string.trim());
+                BigDecimal div = BigDecimal.valueOf(super.getMultiplier());
+                value = tmp.divide(div).floatValue();
+            }
+
+            return value;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FloatPatternFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FloatPatternFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FloatPatternFormatFactory.java
new file mode 100644
index 0000000..1d5bd1f
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FloatPatternFormatFactory.java
@@ -0,0 +1,61 @@
+/**
+ * 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.format.factories;
+
+import java.util.Locale;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.NumberPatternFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class FloatPatternFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(float.class);
+        supportedClasses.add(Float.class);
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions)
+                && ObjectHelper.isNotEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new FloatPatternFormat(formattingOptions.getPattern(),
+                formattingOptions.getLocale());
+    }
+
+    private static class FloatPatternFormat extends NumberPatternFormat<Float> {
+
+        FloatPatternFormat(String pattern, Locale locale) {
+            super(pattern, locale);
+        }
+
+        @Override
+        public Float parse(String string) throws Exception {
+            if (getNumberFormat() != null) {
+                return getNumberFormat().parse(string).floatValue();
+            } else {
+                return Float.valueOf(string);
+            }
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FormatFactories.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FormatFactories.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FormatFactories.java
new file mode 100644
index 0000000..2b9eec8
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FormatFactories.java
@@ -0,0 +1,99 @@
+/**
+ * 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.format.factories;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+
+/**
+ * This class manages all FormatFactoryInterfaces.
+ * This class is a singleton class.
+ * FormatFactoryInterfaces can declare to support one or more classes or
+ * can declare to be generic (e.g. {@link EnumFormatFactory}).
+ * The factories that support one or more classes are stored in a Map.
+ * The generic factories are stored in a list.
+ * The build method first tries to find a factory using the map.
+ * If it doesn't find one it uses the generic list.
+ * If it can't find a factory it throws an IllegalArgumentException.
+ */
+public final class FormatFactories extends AbstractFormatFactory {
+
+    private static final FormatFactories INSTANCE = new FormatFactories();
+    private static final Map<Class<?>, List<FormatFactoryInterface>> CLASS_BASED_FACTORIES = new HashMap<>();
+    private static final List<FormatFactoryInterface> OTHER_FACTORIES = new ArrayList<>();
+
+    private FormatFactories() {
+    }
+
+    public static FormatFactories getInstance() {
+        return INSTANCE;
+    }
+
+    /**
+     * Registers a {@link FormatFactoryInterface}.
+     * Two types of factories exist:
+     * <ul>
+     * <li>Factories that support one or more classes</li>
+     * <li>Factories that support no specific class (e.g. {@link EnumFormatFactory})</li>
+     * </ul>
+     * @param formatFactory
+     * @return the FormatFactories instance
+     */
+    public synchronized FormatFactories register(FormatFactoryInterface formatFactory) {
+        if (formatFactory.supportedClasses().isEmpty()) {
+            OTHER_FACTORIES.add(formatFactory);
+        } else {
+            for (Class<?> clazz : formatFactory.supportedClasses()) {
+                getByClass(clazz).add(formatFactory);
+            }
+        }
+        return this;
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return true;
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        for (FormatFactoryInterface formatFactory : getByClass(formattingOptions.getClazz())) {
+            if (formatFactory.canBuild(formattingOptions)) {
+                return formatFactory.build(formattingOptions);
+            }
+        }
+        for (FormatFactoryInterface formatFactory : OTHER_FACTORIES) {
+            if (formatFactory.canBuild(formattingOptions)) {
+                return formatFactory.build(formattingOptions);
+            }
+        }
+        throw new IllegalArgumentException("Can not find a suitable formatter for the type: " + formattingOptions.getClazz().getCanonicalName());
+    }
+
+    private List<FormatFactoryInterface> getByClass(Class<?> clazz) {
+        List<FormatFactoryInterface> result = CLASS_BASED_FACTORIES.get(clazz);
+        if (result == null) {
+            result = new ArrayList<>();
+            CLASS_BASED_FACTORIES.put(clazz, result);
+        }
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FormatFactoryInterface.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FormatFactoryInterface.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FormatFactoryInterface.java
new file mode 100644
index 0000000..1e0347a
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/FormatFactoryInterface.java
@@ -0,0 +1,48 @@
+/**
+ * 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.format.factories;
+
+import java.util.Collection;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+
+public interface FormatFactoryInterface {
+    /**
+     * Returns the list of supported classes.
+     * When the list doesn't contain elements the factory is supposed
+     * to support all kinds of classes. The factory must decide on other
+     * criteria whether it can build a {@link Format}.
+     * @return the list of supported classes
+     */
+    Collection<Class<?>> supportedClasses();
+
+    /**
+     * Can it build a {@link Format}.
+     * Answers the question about whether it can
+     * build a {@link Format}.
+     * @param formattingOptions
+     * @return can build
+     */
+    boolean canBuild(FormattingOptions formattingOptions);
+
+    /**
+     * Builds the {@link Format}.
+     * @param formattingOptions
+     * @return the format
+     */
+    Format<?> build(FormattingOptions formattingOptions);
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/IntegerFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/IntegerFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/IntegerFormatFactory.java
new file mode 100644
index 0000000..5335dbf
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/IntegerFormatFactory.java
@@ -0,0 +1,56 @@
+/**
+ * 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.format.factories;
+
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.AbstractNumberFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class IntegerFormatFactory extends AbstractFormatFactory {
+
+    private static final IntegerFormat INTEGER_FORMAT = new IntegerFormat();
+
+    {
+        supportedClasses.add(int.class);
+        supportedClasses.add(Integer.class);
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions)
+                && ObjectHelper.isEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return  INTEGER_FORMAT;
+    }
+
+    private static class IntegerFormat extends AbstractNumberFormat<Integer> {
+
+        public String format(Integer object) throws Exception {
+            return object.toString();
+        }
+
+        public Integer parse(String string) throws Exception {
+            return new Integer(string);
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/IntegerPatternFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/IntegerPatternFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/IntegerPatternFormatFactory.java
new file mode 100644
index 0000000..7c81df9
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/IntegerPatternFormatFactory.java
@@ -0,0 +1,61 @@
+/**
+ * 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.format.factories;
+
+import java.util.Locale;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.NumberPatternFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class IntegerPatternFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(int.class);
+        supportedClasses.add(Integer.class);
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions)
+                && ObjectHelper.isNotEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new IntegerPatternFormat(formattingOptions.getPattern(),
+                formattingOptions.getLocale());
+    }
+
+    private static class IntegerPatternFormat extends NumberPatternFormat<Integer> {
+
+        IntegerPatternFormat(String pattern, Locale locale) {
+            super(pattern, locale);
+        }
+
+        @Override
+        public Integer parse(String string) throws Exception {
+            if (getNumberFormat() != null) {
+                return getNumberFormat().parse(string).intValue();
+            } else {
+                return Integer.valueOf(string);
+            }
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LocalDateFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LocalDateFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LocalDateFormatFactory.java
new file mode 100644
index 0000000..64b8606
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LocalDateFormatFactory.java
@@ -0,0 +1,98 @@
+/**
+ * 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.format.factories;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.Locale;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.PatternFormat;
+import org.apache.camel.dataformat.bindy.format.FormatException;
+import org.apache.camel.util.ObjectHelper;
+
+public class LocalDateFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(LocalDate.class);
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new LocalDatePatternFormat(formattingOptions.getPattern(), formattingOptions.getLocale());
+    }
+
+    private static class LocalDatePatternFormat implements PatternFormat<LocalDate> {
+
+        private String pattern;
+        private Locale locale;
+
+        LocalDatePatternFormat(String pattern, Locale locale) {
+            this.pattern = pattern;
+            this.locale = locale;
+        }
+
+        public String format(LocalDate object) throws Exception {
+            ObjectHelper.notNull(this.pattern, "pattern");
+            return this.getDateFormat().format(object);
+        }
+
+        public LocalDate parse(String string) throws Exception {
+
+            LocalDate date;
+            DateTimeFormatter df = this.getDateFormat();
+
+            ObjectHelper.notNull(this.pattern, "pattern");
+
+            if (doesStringFitLengthOfPattern(string)) {
+                date = LocalDate.parse(string, df);
+                return date;
+            } else {
+                throw new FormatException("Date provided does not fit the pattern defined");
+            }
+
+        }
+
+        private boolean doesStringFitLengthOfPattern(String string) {
+            return string.length() <= this.pattern.length();
+        }
+
+        DateTimeFormatter getDateFormat() {
+            DateTimeFormatter result;
+            if (locale != null) {
+                result = DateTimeFormatter.ofPattern(pattern, locale);
+            } else {
+                result = DateTimeFormatter.ofPattern(pattern);
+            }
+            return result;
+        }
+
+        public String getPattern() {
+            return pattern;
+        }
+
+        /**
+         * Sets the pattern
+         *
+         * @param pattern the pattern
+         */
+        public void setPattern(String pattern) {
+            this.pattern = pattern;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LocalDateTimeFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LocalDateTimeFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LocalDateTimeFormatFactory.java
new file mode 100644
index 0000000..109168b
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LocalDateTimeFormatFactory.java
@@ -0,0 +1,109 @@
+/**
+ * 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.format.factories;
+
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Locale;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.PatternFormat;
+import org.apache.camel.dataformat.bindy.format.FormatException;
+import org.apache.camel.util.ObjectHelper;
+
+public class LocalDateTimeFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(LocalDateTime.class);
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new LocalDateTimePatternFormat(formattingOptions.getPattern(),
+                formattingOptions.getTimezone(),
+                formattingOptions.getLocale());
+    }
+
+    private static class LocalDateTimePatternFormat implements PatternFormat<LocalDateTime> {
+
+        private String pattern;
+        private Locale locale;
+        private ZoneId zone;
+
+        LocalDateTimePatternFormat(String pattern, String timezone, Locale locale) {
+            this.pattern = pattern;
+            this.locale = locale;
+            if (timezone.isEmpty()) {
+                this.zone = ZoneId.systemDefault();
+            } else {
+                this.zone = ZoneId.of(timezone);
+            }
+        }
+
+        public String format(LocalDateTime object) throws Exception {
+            ObjectHelper.notNull(this.pattern, "pattern");
+            return this.getDateFormat().format(object);
+        }
+
+        public LocalDateTime parse(String string) throws Exception {
+
+            LocalDateTime date;
+            DateTimeFormatter df = this.getDateFormat();
+
+            ObjectHelper.notNull(this.pattern, "pattern");
+
+            if (doesStringFitLengthOfPattern(string)) {
+                date = LocalDateTime.parse(string, df);
+                return date;
+            } else {
+                throw new FormatException("Date provided does not fit the pattern defined");
+            }
+
+        }
+
+        private boolean doesStringFitLengthOfPattern(String string) {
+            return string.length() <= this.pattern.length();
+        }
+
+        DateTimeFormatter getDateFormat() {
+            DateTimeFormatter result;
+            if (locale != null) {
+                result = DateTimeFormatter.ofPattern(pattern, locale)
+                        .withZone(zone);
+            } else {
+                result = DateTimeFormatter.ofPattern(pattern)
+                        .withZone(zone);
+            }
+            return result;
+        }
+
+        public String getPattern() {
+            return pattern;
+        }
+
+        /**
+         * Sets the pattern
+         *
+         * @param pattern the pattern
+         */
+        public void setPattern(String pattern) {
+            this.pattern = pattern;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LocalTimeFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LocalTimeFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LocalTimeFormatFactory.java
new file mode 100644
index 0000000..aa177ab
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LocalTimeFormatFactory.java
@@ -0,0 +1,109 @@
+/**
+ * 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.format.factories;
+
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Locale;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.PatternFormat;
+import org.apache.camel.dataformat.bindy.format.FormatException;
+import org.apache.camel.util.ObjectHelper;
+
+public class LocalTimeFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(LocalTime.class);
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new LocalTimePatternFormat(formattingOptions.getPattern(),
+                formattingOptions.getTimezone(),
+                formattingOptions.getLocale());
+    }
+
+    private static class LocalTimePatternFormat implements PatternFormat<LocalTime> {
+
+        private String pattern;
+        private Locale locale;
+        private ZoneId zone;
+
+        LocalTimePatternFormat(String pattern, String timezone, Locale locale) {
+            this.pattern = pattern;
+            this.locale = locale;
+            if (timezone.isEmpty()) {
+                this.zone = ZoneId.systemDefault();
+            } else {
+                this.zone = ZoneId.of(timezone);
+            }
+        }
+
+        public String format(LocalTime object) throws Exception {
+            ObjectHelper.notNull(this.pattern, "pattern");
+            return this.getDateFormat().format(object);
+        }
+
+        public LocalTime parse(String string) throws Exception {
+
+            LocalTime date;
+            DateTimeFormatter df = this.getDateFormat();
+
+            ObjectHelper.notNull(this.pattern, "pattern");
+
+            if (doesStringFitLengthOfPattern(string)) {
+                date = LocalTime.parse(string, df);
+                return date;
+            } else {
+                throw new FormatException("Date provided does not fit the pattern defined");
+            }
+
+        }
+
+        private boolean doesStringFitLengthOfPattern(String string) {
+            return string.length() <= this.pattern.length();
+        }
+
+        DateTimeFormatter getDateFormat() {
+            DateTimeFormatter result;
+            if (locale != null) {
+                result = DateTimeFormatter.ofPattern(pattern, locale)
+                        .withZone(zone);
+            } else {
+                result = DateTimeFormatter.ofPattern(pattern)
+                        .withZone(zone);
+            }
+            return result;
+        }
+
+        public String getPattern() {
+            return pattern;
+        }
+
+        /**
+         * Sets the pattern
+         *
+         * @param pattern the pattern
+         */
+        public void setPattern(String pattern) {
+            this.pattern = pattern;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LongFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LongFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LongFormatFactory.java
new file mode 100644
index 0000000..0b3a192
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LongFormatFactory.java
@@ -0,0 +1,55 @@
+/**
+ * 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.format.factories;
+
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.AbstractNumberFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class LongFormatFactory extends AbstractFormatFactory {
+
+    private static final LongFormat LONG_FORMAT = new LongFormat();
+
+    {
+        supportedClasses.add(long.class);
+        supportedClasses.add(Long.class);
+    }
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions)
+                && ObjectHelper.isEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return LONG_FORMAT;
+    }
+
+    private static class LongFormat extends AbstractNumberFormat<Long> {
+
+        public String format(Long object) throws Exception {
+            return object.toString();
+        }
+
+        public Long parse(String string) throws Exception {
+            return new Long(string);
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LongPatternFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LongPatternFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LongPatternFormatFactory.java
new file mode 100644
index 0000000..07d126f
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/LongPatternFormatFactory.java
@@ -0,0 +1,61 @@
+/**
+ * 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.format.factories;
+
+import java.util.Locale;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.NumberPatternFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class LongPatternFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(long.class);
+        supportedClasses.add(Long.class);
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions)
+                && ObjectHelper.isNotEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new LongPatternFormat(formattingOptions.getPattern(),
+                formattingOptions.getLocale());
+    }
+
+    private static class LongPatternFormat extends NumberPatternFormat<Long> {
+
+        LongPatternFormat(String pattern, Locale locale) {
+            super(pattern, locale);
+        }
+
+        @Override
+        public Long parse(String string) throws Exception {
+            if (getNumberFormat() != null) {
+                return getNumberFormat().parse(string).longValue();
+            } else {
+                return Long.valueOf(string);
+            }
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ShortFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ShortFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ShortFormatFactory.java
new file mode 100644
index 0000000..1475dd3
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ShortFormatFactory.java
@@ -0,0 +1,56 @@
+/**
+ * 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.format.factories;
+
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.AbstractNumberFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class ShortFormatFactory extends AbstractFormatFactory {
+
+    private static final ShortFormat SHORT_FORMAT = new ShortFormat();
+
+    {
+        supportedClasses.add(short.class);
+        supportedClasses.add(Short.class);
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions)
+                && ObjectHelper.isEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return SHORT_FORMAT;
+    }
+
+    private static class ShortFormat extends AbstractNumberFormat<Short> {
+
+        public String format(Short object) throws Exception {
+            return object.toString();
+        }
+
+        public Short parse(String string) throws Exception {
+            return new Short(string);
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ShortPatternFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ShortPatternFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ShortPatternFormatFactory.java
new file mode 100644
index 0000000..a193822
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/ShortPatternFormatFactory.java
@@ -0,0 +1,60 @@
+/**
+ * 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.format.factories;
+
+import java.util.Locale;
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.format.NumberPatternFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class ShortPatternFormatFactory extends AbstractFormatFactory {
+
+    {
+        supportedClasses.add(short.class);
+        supportedClasses.add(Short.class);
+    }
+
+    @Override
+    public boolean canBuild(FormattingOptions formattingOptions) {
+        return super.canBuild(formattingOptions)
+                && ObjectHelper.isNotEmpty(formattingOptions.getPattern());
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return new ShortPatternFormat(formattingOptions.getPattern(),
+                formattingOptions.getLocale());
+    }
+
+    private static class ShortPatternFormat extends NumberPatternFormat<Short> {
+
+        ShortPatternFormat(String pattern, Locale locale) {
+            super(pattern, locale);
+        }
+
+        @Override
+        public Short parse(String string) throws Exception {
+            if (getNumberFormat() != null) {
+                return getNumberFormat().parse(string).shortValue();
+            } else {
+                return Short.valueOf(string);
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/StringFormatFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/StringFormatFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/StringFormatFactory.java
new file mode 100644
index 0000000..670440e
--- /dev/null
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/factories/StringFormatFactory.java
@@ -0,0 +1,47 @@
+/**
+ * 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.format.factories;
+
+import org.apache.camel.dataformat.bindy.Format;
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+
+public class StringFormatFactory extends AbstractFormatFactory {
+
+    private static final StringFormat STRING_FORMAT = new StringFormat();
+
+    {
+        supportedClasses.add(String.class);
+    }
+
+    @Override
+    public Format<?> build(FormattingOptions formattingOptions) {
+        return STRING_FORMAT;
+    }
+
+    private static class StringFormat implements Format<String> {
+
+        public String format(String object) throws Exception {
+            return object;
+        }
+
+        public String parse(String string) throws Exception {
+            return string;
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java
index b27c6d8..65bc353 100644
--- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java
@@ -137,7 +137,7 @@ public class BindyKeyValuePairDataFormat extends BindyAbstractDataFormat {
                 }
             }
 
-            // Test if models list is empty or not
+            // BigIntegerFormatFactory if models list is empty or not
             // If this is the case (correspond to an empty stream, ...)
             if (models.size() == 0) {
                 throw new java.lang.IllegalArgumentException("No records have been defined in the CSV");

http://git-wip-us.apache.org/repos/asf/camel/blob/311d429c/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/util/ConverterUtils.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/util/ConverterUtils.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/util/ConverterUtils.java
index 323fdea..778e803 100644
--- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/util/ConverterUtils.java
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/util/ConverterUtils.java
@@ -16,6 +16,11 @@
  */
 package org.apache.camel.dataformat.bindy.util;
 
+import org.apache.camel.dataformat.bindy.FormattingOptions;
+import org.apache.camel.dataformat.bindy.annotation.BindyConverter;
+import org.apache.camel.dataformat.bindy.annotation.DataField;
+import org.apache.camel.dataformat.bindy.annotation.KeyValuePairField;
+
 /**
  * To help return the char associated to the unicode string
  */
@@ -60,4 +65,29 @@ public final class ConverterUtils {
             return returnCharacter;
         }
     }
+
+    public static FormattingOptions convert(DataField dataField, Class<?> clazz, BindyConverter converter, String locale) {
+        return new FormattingOptions()
+                .forClazz(clazz)
+                .withPattern(dataField.pattern())
+                .withLocale(locale)
+                .withTimezone(dataField.timezone())
+                .withPrecision(dataField.precision())
+                .withRounding(dataField.rounding())
+                .withImpliedDecimalSeparator(dataField.impliedDecimalSeparator())
+                .withDecimalSeparator(dataField.decimalSeparator())
+                .withBindyConverter(converter)
+                .withGroupingSeparator(dataField.groupingSeparator());
+    }
+
+    public static FormattingOptions convert(KeyValuePairField dataField, Class<?> clazz, BindyConverter converter, String locale) {
+        return new FormattingOptions()
+                .forClazz(clazz)
+                .withPattern(dataField.pattern())
+                .withLocale(locale)
+                .withTimezone(dataField.timezone())
+                .withPrecision(dataField.precision())
+                .withBindyConverter(converter)
+                .withImpliedDecimalSeparator(dataField.impliedDecimalSeparator());
+    }
 }