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, must start from 1 (mandatory).
042         */
043        int pos();
044    
045        /**
046         * Name of the field (optional)
047         */
048        String name() default "";
049    
050        /**
051         * Name of the header column (optional)
052         */
053        String columnName() default "";
054    
055        /**
056         * Pattern that the formatter will use to transform the data (optional)
057         */
058        String pattern() default "";
059    
060        /**
061         * Length of the data block if the record is set to a fixed length
062         */
063        int length() default 0;
064        
065        /**
066         * Align the text to the right or left. Use values <tt>R</tt> or <tt>L</tt>.
067         */
068        String align() default "R";
069        
070        /**
071         * The char to pad with if the record is set to a fixed length
072         */
073        char paddingChar() default ' ';
074    
075        /**
076         * precision of the {@link java.math.BigDecimal} number to be created
077         */
078        int precision() default 0;
079    
080        /**
081         * Position of the field in the message generated (should start from 1)
082         */
083        int position() default 0;
084    
085        /**
086         * Indicates if the field is mandatory
087         */
088        boolean required() default false;
089    
090        /**
091         * Indicates if the value should be trimmed
092         */
093        boolean trim() default false;
094    
095        /**
096         * Indicates to clip data in the field if it exceeds the allowed length when using fixed length.
097         */
098        boolean clip() default false;
099    }