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.annotation;
018    
019    import java.lang.annotation.Documented;
020    import java.lang.annotation.Retention;
021    import java.lang.annotation.RetentionPolicy;
022    
023    /**
024     * An annotation used to identify in a POJO which property is link to a field of
025     * a record (csv, ...). The pos (mandatory) identifies the position of the data
026     * in the record The name is optional and could be used in the future to bind a
027     * property which a different name The columnName (optional) represents the name
028     * of the column who will appear in the header The pattern (optional) allows to
029     * define the pattern of the data (useful for Date, ...) The length (optional)
030     * allows to define for fixed length message the size of the data's block The
031     * precision(optional) reflects the precision to be used with BigDecimal number
032     * The position (optional) identify the position of the field in the CSV
033     * generated The required (optional) property identifies a field which is
034     * mandatory.
035     */
036    @Documented
037    @Retention(RetentionPolicy.RUNTIME)
038    public @interface DataField {
039    
040        /**
041         * position of the data in the record (mandatory)
042         * 
043         * @return int
044         */
045        int pos();
046    
047        /**
048         * name of the field (optional)
049         * 
050         * @return String
051         */
052        String name() default "";
053    
054        /**
055         * name of the header column (optional)
056         * 
057         * @return String
058         */
059        String columnName() default "";
060    
061        /**
062         * pattern that the formater will use to transform the data (optional)
063         * 
064         * @return String
065         */
066        String pattern() default "";
067    
068        /**
069         * length of the data block (useful for the fixedlength record) 
070         * 
071         * @return int
072         */
073        int length() default 0;
074        
075        /**
076         * align the text to the RIGHT or to LEFT part 
077         * 
078         * @return String
079         */
080        String align() default "R";
081        
082        /**
083         * The char to pad with.
084         * @return the char to pad with if the record is set to a fixed length;
085         * 
086         * @return char
087         */
088        char paddingChar() default ' ';
089    
090        /**
091         * precision of the BigDecimal number to be created
092         * 
093         * @return int
094         */
095        int precision() default 0;
096    
097        /**
098         * Position of the field in the message generated
099         * 
100         * @return int
101         */
102        int position() default 0;
103    
104        /**
105         * Indicates if the field is mandatory
106         * 
107         * @return boolean
108         */
109        boolean required() default false;
110    
111        /**
112         * Indicates if the value should be trimed
113         * 
114         * @return boolean
115         */
116        boolean trim() default false;
117    }