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 2009/01/29 08:29:08 UTC
svn commit: r738783 [1/4] - in /camel/trunk: ./ apache-camel/
apache-camel/bundle/ components/ components/camel-bindy/
components/camel-bindy/src/ components/camel-bindy/src/main/
components/camel-bindy/src/main/java/ components/camel-bindy/src/main/ja...
Author: davsclaus
Date: Thu Jan 29 07:29:06 2009
New Revision: 738783
URL: http://svn.apache.org/viewvc?rev=738783&view=rev
Log:
CAMEL-398: Added camel-bindy as a new component. Big thanks to Charles Moulliard for donating this component to Apahce Camel.
Added:
camel/trunk/components/camel-bindy/ (with props)
camel/trunk/components/camel-bindy/pom.xml (with props)
camel/trunk/components/camel-bindy/src/
camel/trunk/components/camel-bindy/src/main/
camel/trunk/components/camel-bindy/src/main/java/
camel/trunk/components/camel-bindy/src/main/java/org/
camel/trunk/components/camel-bindy/src/main/java/org/apache/
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFactory.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/Format.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/PatternFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/CsvRecord.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Link.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/LinkType.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigIntegerFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ByteFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BytePatternFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/CharacterFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DatePatternFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoubleFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoublePatternFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatPatternFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerPatternFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/LongFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/LongPatternFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/NumberPatternFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ShortFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ShortPatternFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/StringFormat.java (with props)
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/util/
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/util/ClassHelper.java (with props)
camel/trunk/components/camel-bindy/src/main/resources/
camel/trunk/components/camel-bindy/src/main/resources/META-INF/
camel/trunk/components/camel-bindy/src/main/resources/META-INF/LICENSE.txt (with props)
camel/trunk/components/camel-bindy/src/main/resources/META-INF/NOTICE.txt (with props)
camel/trunk/components/camel-bindy/src/test/
camel/trunk/components/camel-bindy/src/test/data/
camel/trunk/components/camel-bindy/src/test/data/big/
camel/trunk/components/camel-bindy/src/test/data/big/csv.txt (with props)
camel/trunk/components/camel-bindy/src/test/data/csv.txt (with props)
camel/trunk/components/camel-bindy/src/test/data2/
camel/trunk/components/camel-bindy/src/test/data2/csv.txt (with props)
camel/trunk/components/camel-bindy/src/test/java/
camel/trunk/components/camel-bindy/src/test/java/org/
camel/trunk/components/camel-bindy/src/test/java/org/apache/
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvMarshallTest.java (with props)
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvUnmarshallTest.java (with props)
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCsvBigFileUnmarshallTest.java (with props)
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvMarshallTest.java (with props)
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvSkipFirstLineUnmarshallTest.java (with props)
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallTest.java (with props)
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/twoclassesandonelink/
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/twoclassesandonelink/Client.java (with props)
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/twoclassesandonelink/Order.java (with props)
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclass/
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclass/Order.java (with props)
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassandskipfirstline/
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassandskipfirstline/Order.java (with props)
camel/trunk/components/camel-bindy/src/test/resources/
camel/trunk/components/camel-bindy/src/test/resources/log4j.properties (with props)
camel/trunk/components/camel-bindy/src/test/resources/org/
camel/trunk/components/camel-bindy/src/test/resources/org/apache/
camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/
camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/
camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/
camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/
camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindyCSVUnmarshallTest-context.xml (with props)
Modified:
camel/trunk/apache-camel/bundle/pom.xml
camel/trunk/apache-camel/pom.xml
camel/trunk/components/pom.xml
camel/trunk/pom.xml
Modified: camel/trunk/apache-camel/bundle/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/apache-camel/bundle/pom.xml?rev=738783&r1=738782&r2=738783&view=diff
==============================================================================
--- camel/trunk/apache-camel/bundle/pom.xml (original)
+++ camel/trunk/apache-camel/bundle/pom.xml Thu Jan 29 07:29:06 2009
@@ -67,6 +67,10 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-bindy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-cometd</artifactId>
</dependency>
<dependency>
Modified: camel/trunk/apache-camel/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/apache-camel/pom.xml?rev=738783&r1=738782&r2=738783&view=diff
==============================================================================
--- camel/trunk/apache-camel/pom.xml (original)
+++ camel/trunk/apache-camel/pom.xml Thu Jan 29 07:29:06 2009
@@ -69,6 +69,10 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-bindy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-cometd</artifactId>
</dependency>
<dependency>
Propchange: camel/trunk/components/camel-bindy/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jan 29 07:29:06 2009
@@ -0,0 +1,8 @@
+.project
+.checkstyle
+.pmd
+.classpath
+target
+.settings
+eclipse-classes
+*.i??
Added: camel/trunk/components/camel-bindy/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/pom.xml?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/pom.xml (added)
+++ camel/trunk/components/camel-bindy/pom.xml Thu Jan 29 07:29:06 2009
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-bindy</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: Bindy</name>
+ <description>Camel Bindy support</description>
+
+ <properties>
+ <camel.osgi.export.pkg>
+ org.apache.camel.dataformat.bindy.*;
+ </camel.osgi.export.pkg>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-javaconfig</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <childDelegation>false</childDelegation>
+ <useFile>true</useFile>
+ <forkMode>pertest</forkMode>
+ <excludes>
+ <!-- <exclude>**/XXXTest.*</exclude> -->
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
Propchange: camel/trunk/components/camel-bindy/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/pom.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/components/camel-bindy/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: 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=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,312 @@
+/**
+ * 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;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+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.util.ClassHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The ModelFactory is the core class of the bindy component and allows to a)
+ * Generate a model associated to a record (CSV, ...) b) Bind data from a record
+ * to the POJOs c) Export data of POJOs to a record (CSV, ...) d) Format data
+ * into String, Date, Double, ... according to the format/pattern defined
+ */
+public class BindyCsvFactory implements BindyFactory {
+
+ private static final transient Log LOG = LogFactory.getLog(BindyCsvFactory.class);
+
+ private List<Class<?>> models;
+
+ private Map<Integer, DataField> mapDataField = new LinkedHashMap<Integer, DataField>();
+
+ private Map<Integer, Field> mapAnnotedField = new LinkedHashMap<Integer, Field>();
+
+ private Map<String, Field> mapAnnotedLinkField = new LinkedHashMap<String, Field>();
+
+ private String separator;
+
+ private boolean skipFirstLine;
+
+ private String packageName;
+
+ public BindyCsvFactory(String packageName) throws Exception {
+ this.packageName = packageName;
+ this.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 and retrieve the
+ * separator of the CSV record
+ *
+ * @throws Exception
+ */
+ public void initModel() throws Exception {
+
+ // Find classes defined as Model
+ initModelClasses(this.packageName);
+
+ // Find annotated fields declared in the Model classes
+ initAnnotedFields();
+
+ // Get parameters : separator and skipfirstline from
+ // @CSVrecord annotation
+ initCsvRecordParameters();
+
+ }
+
+ /**
+ * Find all the classes defined as model
+ *
+ * @param packageName
+ * @throws Exception
+ */
+ private void initModelClasses(String packageName) throws Exception {
+ models = ClassHelper.getClasses(packageName);
+ }
+
+ /**
+ * Find fields annoted in each class of the model
+ *
+ * @throws Exception
+ */
+ private void initAnnotedFields() throws Exception {
+
+ for (Class<?> cl : models) {
+
+ for (Field field : cl.getDeclaredFields()) {
+
+ DataField dataField = field.getAnnotation(DataField.class);
+ if (dataField != null) {
+ mapDataField.put(dataField.pos(), dataField);
+ mapAnnotedField.put(dataField.pos(), field);
+ }
+
+ Link linkField = field.getAnnotation(Link.class);
+
+ if (linkField != null) {
+ mapAnnotedLinkField.put(cl.getName(), field);
+ }
+
+ }
+
+ }
+
+ }
+
+ /**
+ * Bind the data of a record to their fields of the model
+ *
+ * @param data
+ * @throws Exception
+ */
+ 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);
+ Field field = mapAnnotedField.get(pos);
+ field.setAccessible(true);
+
+ 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++;
+ }
+
+ }
+
+ /**
+ * Unbind data from model objects and copy them to csv record
+ *
+ * @return String representing a csv record created
+ * @param model
+ * @throws Exception
+ */
+ public String unbind(Map<String, Object> model) throws Exception {
+
+ StringBuilder builder = new StringBuilder();
+
+ // must use a tree map to get a sorted iterator by the poisition defined by annotations
+ Map<Integer, DataField> dataFields = new TreeMap<Integer, DataField>(mapDataField);
+ Iterator<Integer> it = dataFields.keySet().iterator();
+
+ // Check if separator exists
+ ObjectHelper.notNull(this.separator, "The separator has not been instantiated or property not defined in the @CsvRecord annotation");
+
+ while (it.hasNext()) {
+
+ DataField dataField = mapDataField.get(it.next());
+
+ // Retrieve the field
+ Field field = mapAnnotedField.get(dataField.pos());
+ // Change accessibility to allow to read protected/private fields
+ field.setAccessible(true);
+
+ // Retrieve the format associated to the type
+ Format format;
+
+ String pattern = dataField.pattern();
+ format = FormatFactory.getFormat(field.getType(), 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());
+ }
+
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Link objects together (Only 1to1 relation is allowed)
+ *
+ * @param model
+ * @throws Exception
+ */
+ public void link(Map<String, Object> model) throws Exception {
+
+ Iterator<?> it = mapAnnotedLinkField.keySet().iterator();
+
+ while (it.hasNext()) {
+
+ Field field = mapAnnotedLinkField.get(it.next());
+ 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 csv
+ * records
+ * @throws Exception
+ */
+ 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 separator used to delimit the CSV fields
+ *
+ * @return String separator to split the content of a csv record into tokens
+ * @throws Exception
+ */
+ public String getSeparator() throws Exception {
+
+ return separator;
+ }
+
+ /**
+ * Get the parameter skipFirstLine
+ *
+ * @return String indicates if the first line of the CSV file must be
+ * skipped. Values are Y (for Yes) or N (for No)
+ * @throws Exception
+ */
+ public boolean getSkipFirstLine() throws Exception {
+
+ 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();
+ 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();
+ LOG.debug("Separator defined for the CSV : " + separator);
+
+ }
+
+ }
+
+ }
+
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFactory.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFactory.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFactory.java Thu Jan 29 07:29:06 2009
@@ -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;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The bindy factory is a factory used to create the POJO models and bind or
+ * unbind the data to and from the record (CSV, ...)
+ */
+public interface BindyFactory {
+
+ /**
+ * Prior to bind or unbind the data to and from string or model classes, the
+ * factory must create a collection of objects representing the model
+ *
+ * @throws Exception can be thrown
+ */
+ void initModel() throws Exception;
+
+ /**
+ * The bind allow to read the content of a record (expressed as a
+ * List<String>) and map it to the model classes.
+ *
+ * @param data List<String> represents the csv, ... data to transform
+ * @param model Map<String, object> is a collection of objects used to bind
+ * data. String is the the key name of the class link to POJO
+ * objects
+ * @throws Exception can be thrown
+ */
+ void bind(List<String> data, Map<String, Object> model) throws Exception;
+
+ /**
+ * The unbind is used to transform the content of the classes model objects
+ * into a string. The string represents a record of a CSV file
+ *
+ * @return String represents a csv record created
+ * @param model Map<String, Object> is a collection of objects used to
+ * create csv, ... records. String is the the key name of the
+ * class link to POJO objects
+ * @throws Exception can be thrown
+ */
+ String unbind(Map<String, Object> model) throws Exception;
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFactory.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/Format.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/Format.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/Format.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/Format.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,42 @@
+/**
+ * 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 allows to format object to and from string received using format or parse method
+ */
+public interface Format<T> {
+
+ /**
+ * Formats the object into a String
+ *
+ * @param object the object
+ * @return formatted as a String
+ * @throws Exception can be thrown
+ */
+ String format(T object) throws Exception;
+
+ /**
+ * Parses a String into an object
+ *
+ * @param string the string
+ * @return T the object
+ * @throws Exception can be thrown
+ */
+ T parse(String string) throws Exception;
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/Format.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/Format.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/Format.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,86 @@
+/**
+ * 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;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+import org.apache.camel.dataformat.bindy.format.BigDecimalFormat;
+import org.apache.camel.dataformat.bindy.format.BigIntegerFormat;
+import org.apache.camel.dataformat.bindy.format.ByteFormat;
+import org.apache.camel.dataformat.bindy.format.BytePatternFormat;
+import org.apache.camel.dataformat.bindy.format.CharacterFormat;
+import org.apache.camel.dataformat.bindy.format.DatePatternFormat;
+import org.apache.camel.dataformat.bindy.format.DoubleFormat;
+import org.apache.camel.dataformat.bindy.format.DoublePatternFormat;
+import org.apache.camel.dataformat.bindy.format.FloatFormat;
+import org.apache.camel.dataformat.bindy.format.FloatPatternFormat;
+import org.apache.camel.dataformat.bindy.format.IntegerFormat;
+import org.apache.camel.dataformat.bindy.format.IntegerPatternFormat;
+import org.apache.camel.dataformat.bindy.format.LongFormat;
+import org.apache.camel.dataformat.bindy.format.LongPatternFormat;
+import org.apache.camel.dataformat.bindy.format.ShortFormat;
+import org.apache.camel.dataformat.bindy.format.ShortPatternFormat;
+import org.apache.camel.dataformat.bindy.format.StringFormat;
+
+/**
+ * Factory to return {@link Format} classes for a given type.
+ */
+public final class FormatFactory {
+
+ private FormatFactory() {
+ }
+
+ /**
+ * Retrieves the format to use for the given type
+ *
+ * @param clazz represents the type of the format (String, Integer, Byte)
+ * @param pattern is the pattern to be used during the formating of the data
+ * @param precision optional scale for BigDecimal parsing.
+ * @return Format the formatter
+ * @throws IllegalArgumentException if not suitable formatter is found
+ */
+ public static Format<?> getFormat(Class<?> clazz, String pattern, int precision) throws Exception {
+ if (clazz == byte.class || clazz == Byte.class) {
+ return pattern != null ? new BytePatternFormat(pattern) : new ByteFormat();
+ } else if (clazz == short.class || clazz == Short.class) {
+ return pattern != null ? new ShortPatternFormat(pattern) : new ShortFormat();
+ } else if (clazz == int.class || clazz == Integer.class) {
+ return pattern != null ? new IntegerPatternFormat(pattern) : new IntegerFormat();
+ } else if (clazz == long.class || clazz == Long.class) {
+ return pattern != null ? new LongPatternFormat(pattern) : new LongFormat();
+ } else if (clazz == float.class || clazz == Float.class) {
+ return pattern != null ? new FloatPatternFormat(pattern) : new FloatFormat();
+ } else if (clazz == double.class || clazz == Double.class) {
+ return pattern != null ? new DoublePatternFormat(pattern) : new DoubleFormat();
+ } else if (clazz == BigDecimal.class) {
+ return new BigDecimalFormat(precision);
+ } else if (clazz == BigInteger.class) {
+ return new BigIntegerFormat();
+ } else if (clazz == String.class) {
+ return new StringFormat();
+ } else if (clazz == Date.class) {
+ return new DatePatternFormat(pattern);
+ } else if (clazz == char.class || clazz == Character.class) {
+ return new CharacterFormat();
+ } else {
+ throw new IllegalArgumentException("Can not find a suitable formatter for the type: " + clazz.getCanonicalName());
+ }
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/PatternFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/PatternFormat.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/PatternFormat.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/PatternFormat.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,32 @@
+/**
+ * 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;
+
+/**
+ * The PatternFormat extends the format interface and allows to retrieve the
+ * pattern linked to a format (Date, Double, ...)
+ */
+public interface PatternFormat<T> extends Format<T> {
+
+ /**
+ * Method used to retrieve the pattern for the format
+ *
+ * @return String the pattern
+ */
+ String getPattern();
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/PatternFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/PatternFormat.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/PatternFormat.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/CsvRecord.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/CsvRecord.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/CsvRecord.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/CsvRecord.java Thu Jan 29 07:29:06 2009
@@ -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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * This annotation represents the root class of the model When a CSV,
+ * fixed-length record must be described in the model we will use this
+ * annotation and the separator (for csv record) to know how to split the data
+ * during the unmarshal process a) separator (mandatory) b) name (optional) c)
+ * skipfirstline (optional)
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+public @interface CsvRecord {
+
+ /**
+ * Name describing the record (optional)
+ *
+ * @return String
+ */
+ String name() default "";
+
+ /**
+ * Separator used to split a record in tokens (mandatory)
+ *
+ * @return String
+ */
+ String separator();
+
+ /**
+ * The skipFirstLine parameter will allow to skip or not the first line of a
+ * CSV file. This line often contains columns definition
+ *
+ * @return boolean
+ */
+ boolean skipFirstLine() default false;
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/CsvRecord.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/CsvRecord.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/CsvRecord.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: 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=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java Thu Jan 29 07:29:06 2009
@@ -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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * An annotation used to identify in a POJO which property is link to a field of
+ * a record (csv, ...) a) position identifies the position of the data in the
+ * record (mandatory) b) name is optional and could be used in the future to
+ * bind a property which a different name c) pattern which is optional allows to
+ * define the pattern of the data (useful for Date, ...) d) length allows to
+ * define for fixed length message the size of the data's block e) precision
+ * reflects the precision to be used with BigDecimal number
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+public @interface DataField {
+
+ /**
+ * position of the data in the record (mandatory)
+ *
+ * @return int
+ */
+ int pos();
+
+ /**
+ * name of the field (optional)
+ *
+ * @return String
+ */
+ String name() default "";
+
+ /**
+ * pattern that the formater will use to transform the data (optional)
+ *
+ * @return String
+ */
+ String pattern() default "";
+
+ /**
+ * length of the data block (useful for the fixedlength record) (optional in
+ * this version)
+ *
+ * @return int
+ */
+ int length() default 0;
+
+ /**
+ * precision of the BigDecimal number to be created
+ *
+ * @return int
+ */
+ int precision() default 0;
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Link.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Link.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Link.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Link.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,39 @@
+/**
+ * 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.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * This annotation allows to link classes together in the model. This release
+ * version 1.0 only supports oneToone relation
+ */
+
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Link {
+
+ /**
+ * Type of link identifying the relation between the classes
+ *
+ * @return LinkType
+ */
+ LinkType linkType() default LinkType.OneToOne;
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Link.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Link.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/Link.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/LinkType.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/LinkType.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/LinkType.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/LinkType.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,24 @@
+/**
+ * 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.annotation;
+
+/**
+ * Enumeration of link types
+ */
+public enum LinkType {
+ OneToOne, OneToMany, ManyToOne, ManyToMany
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/LinkType.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/LinkType.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/LinkType.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: 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=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,152 @@
+/**
+ * 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.csv;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Scanner;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.dataformat.bindy.BindyCsvFactory;
+import org.apache.camel.spi.DataFormat;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A <a href="http://activemq.apache.org/camel/data-format.html">data format</a>
+ * ({@link DataFormat}) using Bindy to marshal to and from CSV files
+ */
+public class BindyCsvDataFormat implements DataFormat {
+ private static final transient Log LOG = LogFactory.getLog(BindyCsvDataFormat.class);
+
+ private String packageName;
+ private BindyCsvFactory modelFactory;
+
+ public BindyCsvDataFormat() {
+ }
+
+ public BindyCsvDataFormat(String packageName) {
+ this.packageName = packageName;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void marshal(Exchange exchange, Object body, OutputStream outputStream) throws Exception {
+ List<Map<String, Object>> models = (ArrayList<Map<String, Object>>) body;
+
+ for (Map<String, Object> model : models) {
+ String result = getFactory().unbind(model);
+ byte[] bytes = exchange.getContext().getTypeConverter().convertTo(byte[].class, exchange, result);
+ outputStream.write(bytes);
+ }
+ }
+
+ public Object unmarshal(Exchange exchange, InputStream inputStream) throws Exception {
+
+ // List of Pojos
+ List<Map<String, Object>> models = new ArrayList<Map<String, Object>>();
+
+ // Create POJO where CSV data will be stored
+ Map<String, Object> model = getFactory().factory();
+
+ InputStreamReader in = new InputStreamReader(inputStream);
+
+ // Scanner is used to read big file
+ Scanner scanner = new Scanner(in);
+
+ // Retrieve the separator defined to split the record
+ String separator = getFactory().getSeparator();
+ ObjectHelper.notEmpty(separator, "The separator has not been defined in the annotation @Record or not instantiated during initModel.");
+
+ int count = 0;
+ try {
+
+ // If the first line of the CSV file contains columns name, then we skip this line
+ if (getFactory().getSkipFirstLine()) {
+ scanner.nextLine();
+ }
+
+ while (scanner.hasNextLine()) {
+
+ // Read the line
+ String line = scanner.nextLine().trim();
+
+ if (ObjectHelper.isEmpty(line)) {
+ // skip if line is empty
+ continue;
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Counter " + count++ + " : content : " + line);
+ }
+
+ // Split the CSV record according to the separator defined in
+ // annotated class @CSVRecord
+ List<String> result = Arrays.asList(line.split(separator));
+
+ // Bind data from CSV record with model classes
+ getFactory().bind(result, model);
+
+ // Link objects together
+ getFactory().link(model);
+
+ // Add objects graph to the list
+ models.add(model);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Graph of objects created : " + model);
+ }
+
+ }
+
+ return models;
+
+ } finally {
+ scanner.close();
+ ObjectHelper.close(in, "in", LOG);
+ }
+
+ }
+
+ /**
+ * Method used to create the singleton of the BindyCsvFactory
+ */
+ public BindyCsvFactory getFactory() throws Exception {
+ if (modelFactory == null) {
+ modelFactory = new BindyCsvFactory(this.packageName);
+ }
+ return modelFactory;
+ }
+
+ public void setModelFactory(BindyCsvFactory modelFactory) {
+ this.modelFactory = modelFactory;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java Thu Jan 29 07:29:06 2009
@@ -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;
+
+import java.math.BigDecimal;
+
+import org.apache.camel.dataformat.bindy.Format;
+
+public class BigDecimalFormat implements Format<BigDecimal> {
+
+ private int precision = -1;
+
+ public BigDecimalFormat(int precision) {
+ this.precision = precision;
+ }
+
+ public BigDecimalFormat() {
+ }
+
+ public String format(BigDecimal object) throws Exception {
+ return object.toString();
+ }
+
+ public BigDecimal parse(String string) throws Exception {
+ BigDecimal result = new BigDecimal(string);
+ // only set precision if defined
+ if (precision != -1) {
+ result = result.setScale(precision);
+ }
+ return result;
+ }
+
+ public int getPrecision() {
+ return precision;
+ }
+
+ public void setPrecision(int precision) {
+ this.precision = precision;
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigIntegerFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigIntegerFormat.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigIntegerFormat.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigIntegerFormat.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,33 @@
+/**
+ * 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.math.BigInteger;
+
+import org.apache.camel.dataformat.bindy.Format;
+
+public class BigIntegerFormat implements Format<BigInteger> {
+
+ public String format(BigInteger object) throws Exception {
+ return object.toString();
+ }
+
+ public BigInteger parse(String string) throws Exception {
+ return new BigInteger(string);
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigIntegerFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigIntegerFormat.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigIntegerFormat.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ByteFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ByteFormat.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ByteFormat.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ByteFormat.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,31 @@
+/**
+ * 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 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);
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ByteFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ByteFormat.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/ByteFormat.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BytePatternFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BytePatternFormat.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BytePatternFormat.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BytePatternFormat.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,34 @@
+/**
+ * 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;
+
+public class BytePatternFormat extends NumberPatternFormat<Byte> {
+
+ public BytePatternFormat() {
+ super();
+ }
+
+ public BytePatternFormat(String pattern) {
+ super(pattern);
+ }
+
+ @Override
+ public Byte parse(String string) throws Exception {
+ return super.getNumberFormat().parse(string).byteValue();
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BytePatternFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BytePatternFormat.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BytePatternFormat.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/CharacterFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/CharacterFormat.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/CharacterFormat.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/CharacterFormat.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,36 @@
+/**
+ * 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.text.ParseException;
+
+import org.apache.camel.dataformat.bindy.Format;
+
+public 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);
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/CharacterFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/CharacterFormat.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/CharacterFormat.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DatePatternFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DatePatternFormat.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DatePatternFormat.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DatePatternFormat.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,63 @@
+/**
+ * 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.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.camel.dataformat.bindy.PatternFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class DatePatternFormat implements PatternFormat<Date> {
+
+ private String pattern;
+
+ public DatePatternFormat() {
+ }
+
+ public DatePatternFormat(String pattern) {
+ this.pattern = pattern;
+ }
+
+ public String format(Date object) throws Exception {
+ ObjectHelper.notNull(this.pattern, "pattern");
+ return this.getDateFormat().format(object);
+ }
+
+ public Date parse(String string) throws Exception {
+ ObjectHelper.notNull(this.pattern, "pattern");
+ return this.getDateFormat().parse(string);
+ }
+
+ protected java.text.DateFormat getDateFormat() {
+ return new SimpleDateFormat(this.pattern);
+ }
+
+ public String getPattern() {
+ return pattern;
+ }
+
+ /**
+ * Sets the pattern
+ *
+ * @param pattern the pattern
+ */
+ public void setPattern(String pattern) {
+ this.pattern = pattern;
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DatePatternFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DatePatternFormat.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DatePatternFormat.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoubleFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoubleFormat.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoubleFormat.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoubleFormat.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,31 @@
+/**
+ * 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 DoubleFormat implements Format<Double> {
+
+ public String format(Double object) throws Exception {
+ return object.toString();
+ }
+
+ public Double parse(String string) throws Exception {
+ return new Double(string);
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoubleFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoubleFormat.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoubleFormat.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoublePatternFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoublePatternFormat.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoublePatternFormat.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoublePatternFormat.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,33 @@
+/**
+ * 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;
+
+public class DoublePatternFormat extends NumberPatternFormat<Double> {
+
+ public DoublePatternFormat() {
+ }
+
+ public DoublePatternFormat(String pattern) {
+ super(pattern);
+ }
+
+ @Override
+ public Double parse(String string) throws Exception {
+ return super.getNumberFormat().parse(string).doubleValue();
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoublePatternFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoublePatternFormat.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/DoublePatternFormat.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatFormat.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatFormat.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatFormat.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,31 @@
+/**
+ * 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 FloatFormat implements Format<Float> {
+
+ public String format(Float object) throws Exception {
+ return object.toString();
+ }
+
+ public Float parse(String string) throws Exception {
+ return new Float(string);
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatFormat.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatFormat.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatPatternFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatPatternFormat.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatPatternFormat.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatPatternFormat.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,33 @@
+/**
+ * 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;
+
+public class FloatPatternFormat extends NumberPatternFormat<Float> {
+
+ public FloatPatternFormat() {
+ }
+
+ public FloatPatternFormat(String pattern) {
+ super(pattern);
+ }
+
+ @Override
+ public Float parse(String string) throws Exception {
+ return super.getNumberFormat().parse(string).floatValue();
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatPatternFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatPatternFormat.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/FloatPatternFormat.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerFormat.java?rev=738783&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerFormat.java (added)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerFormat.java Thu Jan 29 07:29:06 2009
@@ -0,0 +1,31 @@
+/**
+ * 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 IntegerFormat implements Format<Integer> {
+
+ public String format(Integer object) throws Exception {
+ return object.toString();
+ }
+
+ public Integer parse(String string) throws Exception {
+ return new Integer(string);
+ }
+
+}
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerFormat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerFormat.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerFormat.java
------------------------------------------------------------------------------
svn:keywords = Rev Date