| Modifier and Type | Method and Description |
|---|---|
| public String | Returns: A regular expression, the first capture group of which will be used for conversion to the bean fieldIf this is anything but an empty string, it will be used as a regular expression to extract part of the input before conversion to the bean field. |
| public String | Returns: The name of the column(s) in the CSV file from which this field should be taken.A regular expression defining which column names are to be included in this bean field. |
| public Class | Returns: The converter applied to each of the data points extracted from the inputOnce the data points have been recovered from the various columns of the
input, a custom converter can optionally be specified for conversion of
each of the data points before they are joined in a
|
| public Class | Returns: The type of the map elementsDefines what type the elements of the map should have. |
| public String | Returns: A format string for writing fieldsIf this is anything but an empty string, it will be used as a format
string for |
| public String | Returns: The locale selected. The default is indicated by an empty string.Defines the locale to be used for decoding the argument. |
| public Class | Returns: A class implementingorg.Defines the class used for the multi-valued map. |
| public String[] | Returns: The names of the profiles this configuration is forA profile can be used to annotate the same field differently for different inputs or outputs. |
| public boolean | Returns: If the field is required to contain information.Whether or not the annotated field is required to be present in every data set of the input. |
| public String | |
| public boolean | Returns: Whether the read locale is used for writing as wellWhether or not the same locale is used for writing as for reading. |
| capture | back to summary |
|---|---|
| public String capture() If this is anything but an empty string, it will be used as a regular expression to extract part of the input before conversion to the bean field. An empty string behaves as if the regular expression The regular expression will be compiled and every field of input will be passed through it, naturally after the input has been normalized (quotations and escape characters removed). The first capture group will be extracted, and that string will be passed on to the appropriate conversion routine for the bean field in question. This makes it possible to easily convert input fields with forms like
The regular expression is applied to the entire string in question
(i.e. with
This is the inverse operation of
| |
| column | back to summary |
|---|---|
| public String column() A regular expression defining which column names are to be included in this bean field. If not specified, the name of the column must be identical to the name of the field(s). Since this annotation can combine multiple columns from the input, and they are allowed to have the same name, it is legitimate to let opencsv default to using the field name even with this annotation.
| |
| converter | back to summary |
|---|---|
| public Class Once the data points have been recovered from the various columns of the
input, a custom converter can optionally be specified for conversion of
each of the data points before they are joined in a
| |
| elementType | back to summary |
|---|---|
| public Class Defines what type the elements of the map should have.
It is necessary to instantiate elements of the map, and it is not
always possible to determine the type of the elements at runtime.
A perfect example of this is
| |
| format | back to summary |
|---|---|
| public String format() If this is anything but an empty string, it will be used as a format
string for An empty string behaves as if the format string The format string, if it is not empty, should contain one and only
one This is the inverse operation of
| |
| locale | back to summary |
|---|---|
| public String locale() Defines the locale to be used for decoding the argument. If not specified, the current default locale is used. The locale must be
one recognized by
The locale must be in a format accepted by
Caution must be exercised with the default locale, for the default locale for numerical types does not mean the locale of the running program, such as en-US or de-DE, but rather no locale. Numbers will be parsed more or less the way the Java compiler would parse them. That means, for instance, that thousands separators in long numbers are not permitted, even if the locale of the running program would accept them. When dealing with locale-sensitive data, it is always best to specify the locale explicitly.
| |
| mapType | back to summary |
|---|---|
| public Class Defines the class used for the multi-valued map. This must be a specific implementation of
The logic for determining which class to instantiate for the multi-valued map is as follows. In all cases, the implementation must have a nullary constructor.
| |
| profiles | back to summary |
|---|---|
| public String[] profiles() A profile can be used to annotate the same field differently for different inputs or outputs. Perhaps you have multiple input sources, and they all use different header names or positions for the same data. With profiles, you don't have to create different beans with the same fields and different annotations for each input. Simply annotate the same field multiple times and specify the profile when you parse the input. The same applies to output: if you want to be able to represent the same data in multiple CSV formats (that is, with different headers or orders), annotate the bean fields multiple times with different profiles and specify which profile you want to use on writing. Results are undefined if profile names are not unique. If the same configuration applies to multiple profiles, simply list all applicable profile names here. This parameter is an array of strings. The empty string, which is the default value, specifies the default profile and will be used if no annotation for the specific profile being used can be found, or if no profile is specified.
| |
| required | back to summary |
|---|---|
| public boolean required() Whether or not the annotated field is required to be present in every data set of the input. This means that the input cannot be empty. The output after conversion is not guaranteed to be non-empty. "Input" means the string from every matching field in the CSV file on reading and the bean member variable on writing.
| |
| writeLocale | back to summary |
|---|---|
| public String writeLocale() The locale for writing.
This field is ignored unless
| |
| writeLocaleEqualsReadLocale | back to summary |
|---|---|
| public boolean writeLocaleEqualsReadLocale() Whether or not the same locale is used for writing as for reading.
If this is true,
| |