View Javadoc
1   package org.csveed.annotations;
2   
3   import java.lang.annotation.ElementType;
4   import java.lang.annotation.Retention;
5   import java.lang.annotation.RetentionPolicy;
6   import java.lang.annotation.Target;
7   
8   import org.csveed.bean.AbstractMapper;
9   import org.csveed.bean.ColumnIndexMapper;
10  
11  /**
12  * Various settings applying to the entire CSV file and BeanInstructions.
13  * @author Robert Bor
14  */
15  @Target(ElementType.TYPE)
16  @Retention(RetentionPolicy.RUNTIME)
17  public @interface CsvFile {
18  
19      /**
20      * The symbol which escapes a quote character while inside a quoted string. By default a double quote (")
21      * @return escape character
22      */
23      char escape() default '"';
24  
25      /**
26      * The quote symbol is the sign on both sides of the field value. By default this will be a double quote
27      * @return quote symbol for a field
28      */
29      char quote() default '"';
30  
31      /**
32       * Sets whether or not quotes are written around the field values.
33       * If enabled, the character set as the escape symbol will be disabled.
34       * If disabled, no quotes are written around the field values and the escape symbol is not escaped.
35       * This setting has <strong>no</strong> effect when reading CSV files, only when writing them.
36       * @return whether or not to write quotes around field values
37       */
38      boolean quotingEnabled() default true;
39  
40      /**
41      * The separator is the symbol between two fields. By default this will be a semi-colon
42      * @return separator between two fields
43      */
44      char separator() default ';';
45  
46      /**
47      * The symbols all eligible as end-of-line markers. By default \r and \n are both eol symbols
48      * @return all the eligible eol symbols
49      */
50      char[] endOfLine() default { '\r', '\n' };
51  
52      /**
53      * All lines starting with this symbol (must be at the first encountered position) will be considered
54      * comments, which are ignored by the parser
55      * @return comment symbol
56      */
57      char comment() default '#';
58  
59      /**
60      * States whether the first line will be used as a structure line. If this is not the case, the mapping
61      * will be done based on column indexes.
62      * @return whether to use the first line as a structure or not
63      */
64      boolean useHeader() default true;
65  
66      /**
67      * The point from where the lines must be read, including the structure (if applicable). By default,
68      * this value is 1 and includes the header. Note that row counting starts at 1, not at 0, ie CSVeed is
69      * 1-based to be more aligned with the Excel user who receives the error report, not the developer.
70      * @return the point from where lines must be converted, 1-based
71      */
72      int startRow() default 1;
73  
74      /**
75      * Ascertains that empty lines are skipped. If this value is false, empty lines will be parsed as single
76      * column rows. Default values is true.
77      * @return whether empty files must be skipped
78      */
79      boolean skipEmptyLines() default true;
80  
81      /**
82      * Ascertains that comment lines are skipped. If this value is false, the comment marker is ignored.
83      * Normally, this method should not be needed. Use only if you want to have 100% certainty that lines
84      * identified as comment lines are never skipped. Default value is true.
85      * @return whether comment lines (marked with a comment marker on the first position) must be skipped
86      */
87      boolean skipCommentLines() default true;
88  
89      /**
90      * The column where the dynamic headers start. All columns following this column are automatically assumed
91      * to be dynamic also.
92      * @return index where dynamic columns start
93      */
94      int startIndexDynamicColumns() default 0;
95  
96      /**
97      * Determines the strategy to employ for mapping between CSV and Bean. The default will be to map on the
98      * basis of the column index
99      * @return the mapping strategy
100     */
101     Class<? extends AbstractMapper> mappingStrategy() default ColumnIndexMapper.class;
102 
103 }