Top Description Methods
com.opencsv.bean

public @Interface CsvNumber

extends Annotation
Annotations
@Documented
@Retention:RUNTIME
@Target:FIELD
@Repeatable:CsvNumbers
Imports
java.lang.annotation.*, java.math.RoundingMode

This annotation indicates that the destination field is a number that is specially formatted. Numbers that have no more formatting than that which comes with a locale (or the default locale) do not require this annotation. If a locale is specified in the attendant CSV binding annotation (CsvBindByName, CsvBindByPosition, etc.), it is used for the conversion. The following types are supported:
Author
Andrew Rucker Jones
Since
4.2

Method Summary

Modifier and TypeMethod and Description
public String[]

Returns:

The names of the profiles this configuration is for
profiles
()

A profile can be used to annotate the same field differently for different inputs or outputs.

public RoundingMode

Returns:

The rounding pattern to be used if decimals are formatted
roundingMode
()

The rounding mode for formatting decimals.

public String

Returns:

The format string for parsing input
value
()

A decimal format string.

public String

Returns:

The format string for formatting output
writeFormat
()

A number format string.

public boolean

Returns:

Whether the read format is used for writing as well
writeFormatEqualsReadFormat
()

Whether or not the same format string is used for writing as for reading.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

profilesback 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.

Returns:String[]

The names of the profiles this configuration is for

Since
5.4
roundingModeback to summary
public RoundingMode roundingMode()

The rounding mode for formatting decimals. The default rounding mode, in keeping with java.text.DecimalFormat's default, is java.math.RoundingMode.HALF_EVEN.

Returns:RoundingMode

The rounding pattern to be used if decimals are formatted

Since
5.9
valueback to summary
public String value()

A decimal format string. This must be a localized pattern understood by java.text.DecimalFormat. The locale is gleaned from one of the other CSV-related annotations if present there, or failing that, is the default locale for the JVM. If your code might run under different locales, you are strongly encouraged to always specify a locale for conversions, otherwise your code will behave unpredictably.

Returns:String

The format string for parsing input

writeFormatback to summary
public String writeFormat()

A number format string. The default value is blank and only exists to make sure the parameter is optional.

Returns:String

The format string for formatting output

Since
5.0
See Also
value(), writeFormatEqualsReadFormat()
writeFormatEqualsReadFormatback to summary
public boolean writeFormatEqualsReadFormat()

Whether or not the same format string is used for writing as for reading. If this is true, value() is used for both reading and writing and writeFormat() is ignored.

Returns:boolean

Whether the read format is used for writing as well

Since
5.0