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