001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.camel.dataformat.bindy;
018    
019    import java.util.List;
020    import java.util.Map;
021    
022    /**
023     * The bindy factory is a factory used to create the POJO models and bind or
024     * unbind the data to and from the record (CSV, ...)
025     */
026    public interface BindyFactory {
027    
028        /**
029         * Prior to bind or unbind the data to and from string or model classes, the
030         * factory must create a collection of objects representing the model
031         * 
032         * @throws Exception can be thrown
033         */
034        void initModel() throws Exception;
035    
036        /**
037         * The bind allow to read the content of a record (expressed as a
038         * List<String>) and map it to the model classes.
039         * 
040         * @param data List<String> represents the csv, ... data to transform
041         * @param model Map<String, object> is a collection of objects used to bind
042         *            data. String is the the key name of the class link to POJO
043         *            objects
044         * @throws Exception can be thrown
045         */
046        void bind(List<String> data, Map<String, Object> model) throws Exception;
047    
048        /**
049         * The unbind is used to transform the content of the classes model objects
050         * into a string. The string represents a record of a CSV file
051         * 
052         * @return String represents a csv record created
053         * @param model Map<String, Object> is a collection of objects used to
054         *            create csv, ... records. String is the the key name of the
055         *            class link to POJO objects
056         * @throws Exception can be thrown
057         */
058        String unbind(Map<String, Object> model) throws Exception;
059    
060    }