Top Description Methods
com.univocity.parsers.annotations

public @Interface Parsed

extends Annotation
Annotations
@Retention:RUNTIME
@Inherited
@Target:FIELD, METHOD, ANNOTATION_TYPE
Imports
com.univocity.parsers.annotations.helpers.*, com.univocity.parsers.common.*, com.univocity.parsers.common.processor.*, com.univocity.parsers.conversions.*, java.lang.annotation.*

Indicates the field is parsed. If the annotated field type is not a String, it will be automatically converted using one of the existing Conversion implementations in package com.univocity.parsers.conversions.

Commonly used for java beans processed using BeanProcessor and/or BeanWriterProcessor

Implementation Note

All annotations in @Parsed fields are processed by AnnotationHelper

Author
Univocity Software Pty Ltd - [email protected]
See Also
Conversion, Conversions, BeanProcessor, BeanWriterProcessor, AnnotationHelper

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

flag indicating whether the default conversion, based on the field type, is to be applied for this field.
applyDefaultConversion
()

Flag to indicate whether the parsed field should be converted automatically based on the field type.

public String

Returns:

the default String to return when the parsed value is null
defaultNullRead
()

The default value to assign to this field in the parsed value is null

The String literal "null" will be interpreted as a regular null.

public String

Returns:

default String to write when the input is null.
defaultNullWrite
()

The default value to read from this field if it is null.

public String[]

Returns:

the possible field names (optional if the index is provided)
field
()

The possible field names of a record.

public int

Returns:

the position of this field (optional if the field name is provided)
index
()

Field position in a parsed record

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

applyDefaultConversionback to summary
public boolean applyDefaultConversion()

Flag to indicate whether the parsed field should be converted automatically based on the field type. For example, if the annotated field is a BigDecimal, then BigDecimalConversion will be used to convert Strings to BigDecimal when reading and BigDecimal to String when writing. You may want to disable the default field conversion when using custom conversions through BeanWriterProcessor#convertFields(Conversion...),BeanWriterProcessor#convertIndexes(Conversion...) or BeanWriterProcessor#convertAll(Conversion...).

Returns:boolean

flag indicating whether the default conversion, based on the field type, is to be applied for this field.

defaultNullReadback to summary
public String defaultNullRead()

The default value to assign to this field in the parsed value is null

The String literal "null" will be interpreted as a regular null.

Use "'null"' if you want the default value to be the string "null"

this value will have different effects depending on the field type:

  • on fields of type java.util.Date or java.util.Calendar: if the null value is "now", the result of new Date() or Calendar.getInstance() will be used.
  • on numeric fields (primitives, wrappers and java.math.BigDecimal and java.math.BigInteger): if the null value contains a number, e.g. "50.01", it will be parsed and assigned to the field.
  • on boolean and Boolean fields: if the null value contains a String, the result of Boolean.valueOf(defaultNullRead()) will assigned to the field.
  • on char and Character fields: if the null value contains a String, the result of defaultNullRead().charAt(0) will assigned to the field. An exception will be thrown if the length of this String is different than 1
Returns:String

the default String to return when the parsed value is null

defaultNullWriteback to summary
public String defaultNullWrite()

The default value to read from this field if it is null. Used for writing to an output by BeanWriterProcessor.

The String literal "null" will be interpreted as a regular null.

Use "'null"' if you want the default value to be the string "null"

Returns:String

default String to write when the input is null.

fieldback to summary
public String[] field()

The possible field names of a record. If multiple names are provided, the parser/writer will attempt to match the given names against the headers provided (i.e. headers found in the input when parsing with CommonParserSettings#isHeaderExtractionEnabled(), or manually set using com.univocity.parsers.common.CommonSettings#setHeaders(String...) for writing or parsing)

Returns:String[]

the possible field names (optional if the index is provided)

indexback to summary
public int index()

Field position in a parsed record

Returns:int

the position of this field (optional if the field name is provided)