Top Description Fields Constructors Methods
com.univocity.parsers.fixed

public Class FixedWidthFields

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
com.univocity.parsers.fixed.FixedWidthFieldLengths
Imports
com.univocity.parsers.annotations.*, com.univocity.parsers.annotations.helpers.*, com.univocity.parsers.common.*, java.util.*, java.util.Map.*

This class provides the name, length, alignment and padding of each field in a fixed-width record.
Author
Univocity Software Pty Ltd - [email protected]

Field Summary

Modifier and TypeField and Description
private List<FieldAlignment>
private List<Integer>
private List<NormalizedString>
private List<Character>
private List<Boolean>
private boolean
private List<Boolean>
private int

Constructor Summary

AccessConstructor and Description
public
FixedWidthFields(LinkedHashMap<String, Integer>
a LinkedHashMap containing the sequence of fields to be associated with each column in the input/output, with their respective length.
fields
)

Defines a sequence of field names used to refer to columns in the input/output text of an entity, along with their lengths.

public
FixedWidthFields(String[]
the sequence of fields to be associated with each column in the input/output
headers
,
int[]
the sequence of lengths to be associated with each given header. The size of this array must match the number of given headers.
lengths
)

Defines a sequence of field names used to refer to columns in the input/output text of an entity, along with their lengths.

public
FixedWidthFields(int...
The number lengths of all fields in a fixed-width record. All lengths must be greater than 0.
fieldLengths
)

Creates a new instance initialized with the lengths of all fields in a fixed-width record.

public
FixedWidthFields(Class<T>
the class whose FixedWidth annotations will be processed to configure this field list.
beanClass
)

Deprecated use forParsing(Class) and forWriting(Class) to initialize the fields from the given class and filter out getters and setters that target the same field.
Creates a new instance initialized from FixedWidth annotations in the fields and methods of a given class.
private
FixedWidthFields(Class<T>
the class whose FixedWidth annotations will be processed to configure this field list.
beanClass
,
MethodFilter
filter to apply over annotated methods when the fixed-width writer is reading data from beans (to write values to an output) or writing values into beans (when parsing). It is used to choose either a "get" or a "set" method annotated with Parsed, when both methods target the same field.
methodFilter
)

Creates a new instance initialized from FixedWidth annotations in the fields of a given class.

Method Summary

Modifier and TypeMethod and Description
public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(int
starting position of the field.
startPosition
,
int
ending position of the field
endPosition
)

Adds the range of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(String
the name of the next field. It is not validated.
name
,
int
starting position of the field.
startPosition
,
int
ending position of the field
endPosition
)

Adds the range of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(String
the name of the next field. It is not validated.
name
,
int
starting position of the field.
startPosition
,
int
ending position of the field
endPosition
,
char
the representation of unused space in this field
padding
)

Adds the range of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(String
the name of the next field. It is not validated.
name
,
int
starting position of the field.
startPosition
,
int
ending position of the field
endPosition
,
FieldAlignment
the alignment of the field
alignment
)

Adds the range of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(int
starting position of the field.
startPosition
,
int
ending position of the field
endPosition
,
FieldAlignment
the alignment of the field
alignment
)

Adds the range of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(int
starting position of the field.
startPosition
,
int
ending position of the field
endPosition
,
FieldAlignment
the alignment of the field
alignment
,
char
the representation of unused space in this field
padding
)

Adds the range of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(int
starting position of the field.
startPosition
,
int
ending position of the field
endPosition
,
char
the representation of unused space in this field
padding
)

Adds the range of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(String
the name of the next field. It is not validated.
name
,
int
starting position of the field.
startPosition
,
int
ending position of the field
endPosition
,
FieldAlignment
the alignment of the field
alignment
,
char
the representation of unused space in this field
padding
)

Adds the range of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(int
the length of the next field. It must be greater than 0.
length
)

Adds the length of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(int
the length of the next field. It must be greater than 0.
length
,
FieldAlignment
the alignment of the field
alignment
)

Adds the length of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(String
the name of the next field. It is not validated.
name
,
int
the length of the next field. It must be greater than 0.
length
)

Adds the length of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(String
the name of the next field. It is not validated.
name
,
int
the length of the next field. It must be greater than 0.
length
,
FieldAlignment
the alignment of the field
alignment
)

Adds the length of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(int
the length of the next field. It must be greater than 0.
length
,
char
the representation of unused space in this field
padding
)

Adds the length of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(int
the length of the next field. It must be greater than 0.
length
,
FieldAlignment
the alignment of the field
alignment
,
char
the representation of unused space in this field
padding
)

Adds the length of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(String
the name of the next field. It is not validated.
name
,
int
the length of the next field. It must be greater than 0.
length
,
char
the representation of unused space in this field
padding
)

Adds the length of the next field in a fixed-width record.

public FixedWidthFields

Returns:

the FixedWidthFields instance itself for chaining.
addField
(String
the name of the next field. It is not validated.
name
,
int
the length of the next field. It must be greater than 0.
length
,
FieldAlignment
the alignment of the field
alignment
,
char
the representation of unused space in this field
padding
)

Adds the length of the next field in a fixed-width record.

protected FixedWidthFields
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public static FixedWidthFields

Returns:

a new FixedWidthFields instance built with the FixedWidth annotations found in the given class' attributes and methods (excluding getters)
forParsing
(Class<T>
the class whose FixedWidth annotations will be processed to configure this field list.
beanClass
)

Creates a new instance initialized from FixedWidth annotations in the fields and methods of a given class.

public static FixedWidthFields

Returns:

a new FixedWidthFields instance built with the FixedWidth annotations found in the given class' attributes and methods (excluding setters)
forWriting
(Class<T>
the class whose FixedWidth annotations will be processed to configure this field list.
beanClass
)

Creates a new instance initialized from FixedWidth annotations in the fields and methods of a given class.

public FieldAlignment

Returns:

the alignment of the field
getAlignment
(int
the index of the field whose alignment will be returned
position
)

Returns the alignment of a given field.

public FieldAlignment

Returns:

the alignment of the given field
getAlignment
(String
the name of the field whose alignment will be returned
fieldName
)

Returns the alignment of a given field.

pack-priv int[]
public FieldAlignment[]

Returns:

the sequence of alignment settings to apply over each field in the fixed-width record.
getFieldAlignments
()

Returns a copy of the sequence of alignment settings to apply over each field in the fixed-width record.

public int[]

Returns:

a copy of the sequence of field lengths of a fixed-width record
getFieldLengths
()

Returns a copy of the sequence of field lengths of a fixed-width record

public NormalizedString[]

Returns:

the name of each field in a fixed-width record, or null if no name has been defined.
getFieldNames
()

Returns the name of each field in a fixed-width record, if any

public char[]

Returns:

the sequence of padding characters to apply over each field in the fixed-width record.
getFieldPaddings
()

Returns a copy of the sequence of padding characters to apply over each field in the fixed-width record.

pack-priv char[]
public int

Returns:

the number of fields in a fixed-width record
getFieldsPerRecord
()

Returns the number of fields in a fixed-width record

pack-priv boolean[]

Returns:

the sequence of fields to ignore.
getFieldsToIgnore
()

Returns the sequence of fields to ignore.

pack-priv Boolean[]

Returns:

the sequence that have an explicit 'keepPadding' flag.
getKeepPaddingFlags
()

Returns the sequence of fields whose padding character must/must not be retained in the parsed value

private <T> List<T>
public int

Returns:

the index of the field, or -1 if it does not exist.
indexOf
(String
the name of the field to be searched
fieldName
)

Returns the index of a field name.

public void
keepPaddingOn(int
the positions of the fields that should keep the padding character
position
,
int...
additional positions
positions
)

Configures a given list of fields to retain the padding character in any parsed values, overriding the any default set for the whole input in FixedWidthParserSettings#getKeepPadding()

public void
keepPaddingOn(String
the name of the first field that should keep the padding character
name
,
String...
the names of more fields that should keep the padding character
names
)

Configures a given list of fields to retain the padding character in any parsed values, overriding the any default set for the whole input in FixedWidthParserSettings#getKeepPadding()

public void
setAlignment(FieldAlignment
the alignment to apply
alignment
,
int...
the positions of the fields that should be aligned
positions
)

Applies alignment to a given list of fields

public void
setAlignment(FieldAlignment
the alignment to apply
alignment
,
String...
the names of the fields that should be aligned
names
)

Applies alignment to a given list of fields

private void
setAlignment(int position, FieldAlignment alignment)

public void
setFieldLength(String
the name of the field whose length must be altered
name
,
int
the new length of the given field
newLength
)

Modifies the length of a given field

public void
setFieldLength(int
the position of the field whose length must be altered
position
,
int
the new length of the given field
newLength
)

Modifies the length of a given field

pack-priv static void
setHeadersIfPossible(FixedWidthFields fieldLengths, CommonSettings<F extends Format> settings)

private void
setKeepPaddingFlag(boolean keep, int position, int... positions)

private void
setKeepPaddingFlag(boolean keep, String name, String... names)

public void
setPadding(char
the padding to apply
padding
,
int...
the positions of the fields that should use the given padding character
positions
)

Applies a custom padding character to a given list of fields

public void
setPadding(char
the padding to apply
padding
,
String...
the names of the fields that should use the given padding character
names
)

Applies a custom padding character to a given list of fields

private void
setPadding(int position, char padding)

private void
setPaddingToKeep(int position, boolean keepPaddingFlag)

public void
stripPaddingFrom(int
the positions of the fields that should keep the padding character
position
,
int...
additional positions
positions
)

Configures a given list of fields to remove the padding character in any parsed values, overriding the any default set for the whole input in FixedWidthParserSettings#getKeepPadding()

public void
stripPaddingFrom(String
the name of the first field that have any padding characters removed
name
,
String...
the names of the fields that should have any padding characters removed
names
)

Configures a given list of fields to remove the padding character in any parsed values, overriding the any default set for the whole input in FixedWidthParserSettings#getKeepPadding()

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private void
validateIndex(int position)

private void
validateLength(String name, int length)

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

fieldAlignmentback to summary
private List<FieldAlignment> fieldAlignment
fieldLengthsback to summary
private List<Integer> fieldLengths
fieldNamesback to summary
private List<NormalizedString> fieldNames
fieldPaddingback to summary
private List<Character> fieldPadding
fieldsToIgnoreback to summary
private List<Boolean> fieldsToIgnore
noNamesback to summary
private boolean noNames
paddingsToKeepback to summary
private List<Boolean> paddingsToKeep
totalLengthback to summary
private int totalLength

Constructor Detail

FixedWidthFieldsback to summary
public FixedWidthFields(LinkedHashMap<String, Integer> fields)

Defines a sequence of field names used to refer to columns in the input/output text of an entity, along with their lengths. The field names defined will be used as headers, having the same effect of a call to FixedWidthParserSettings#setHeaders(String...).

Parameters
fields:LinkedHashMap<String, Integer>

a LinkedHashMap containing the sequence of fields to be associated with each column in the input/output, with their respective length.

FixedWidthFieldsback to summary
public FixedWidthFields(String[] headers, int[] lengths)

Defines a sequence of field names used to refer to columns in the input/output text of an entity, along with their lengths. The field names defined will be used as headers, having the same effect of a call to FixedWidthParserSettings#setHeaders(String...).

Parameters
headers:String[]

the sequence of fields to be associated with each column in the input/output

lengths:int[]

the sequence of lengths to be associated with each given header. The size of this array must match the number of given headers.

FixedWidthFieldsback to summary
public FixedWidthFields(int... fieldLengths)

Creates a new instance initialized with the lengths of all fields in a fixed-width record.

Parameters
fieldLengths:int[]

The number lengths of all fields in a fixed-width record. All lengths must be greater than 0.

FixedWidthFieldsback to summary
public FixedWidthFields(Class<T> beanClass)

Deprecated

use forParsing(Class) and forWriting(Class) to initialize the fields from the given class and filter out getters and setters that target the same field. If the given class has any annotated methods only the setters will be used, making it usable only for parsing.

Creates a new instance initialized from FixedWidth annotations in the fields and methods of a given class. Note that all fields should additionally have the Parsed annotation to configure header names and/or their positions.

Parameters
beanClass:Class<T>

the class whose FixedWidth annotations will be processed to configure this field list.

Annotations
@Deprecated
FixedWidthFieldsback to summary
private FixedWidthFields(Class<T> beanClass, MethodFilter methodFilter)

Creates a new instance initialized from FixedWidth annotations in the fields of a given class. Note that all fields should additionally have the Parsed annotation to configure header names and/or their positions.

Parameters
beanClass:Class<T>

the class whose FixedWidth annotations will be processed to configure this field list.

methodFilter:MethodFilter

filter to apply over annotated methods when the fixed-width writer is reading data from beans (to write values to an output) or writing values into beans (when parsing). It is used to choose either a "get" or a "set" method annotated with Parsed, when both methods target the same field.

Method Detail

addFieldback to summary
public FixedWidthFields addField(int startPosition, int endPosition)

Adds the range of the next field in a fixed-width record. The given range cannot overlap with previously defined fields. Blanks will be used to fill any "gap" between record ranges when writing.

Parameters
startPosition:int

starting position of the field.

endPosition:int

ending position of the field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(String name, int startPosition, int endPosition)

Adds the range of the next field in a fixed-width record. The given range cannot overlap with previously defined fields. Blanks will be used to fill any "gap" between record ranges when writing.

Parameters
name:String

the name of the next field. It is not validated.

startPosition:int

starting position of the field.

endPosition:int

ending position of the field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(String name, int startPosition, int endPosition, char padding)

Adds the range of the next field in a fixed-width record. The given range cannot overlap with previously defined fields. Blanks will be used to fill any "gap" between record ranges when writing.

Parameters
name:String

the name of the next field. It is not validated.

startPosition:int

starting position of the field.

endPosition:int

ending position of the field

padding:char

the representation of unused space in this field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(String name, int startPosition, int endPosition, FieldAlignment alignment)

Adds the range of the next field in a fixed-width record. The given range cannot overlap with previously defined fields. Blanks will be used to fill any "gap" between record ranges when writing.

Parameters
name:String

the name of the next field. It is not validated.

startPosition:int

starting position of the field.

endPosition:int

ending position of the field

alignment:FieldAlignment

the alignment of the field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(int startPosition, int endPosition, FieldAlignment alignment)

Adds the range of the next field in a fixed-width record. The given range cannot overlap with previously defined fields. Blanks will be used to fill any "gap" between record ranges when writing.

Parameters
startPosition:int

starting position of the field.

endPosition:int

ending position of the field

alignment:FieldAlignment

the alignment of the field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(int startPosition, int endPosition, FieldAlignment alignment, char padding)

Adds the range of the next field in a fixed-width record. The given range cannot overlap with previously defined fields. Blanks will be used to fill any "gap" between record ranges when writing.

Parameters
startPosition:int

starting position of the field.

endPosition:int

ending position of the field

alignment:FieldAlignment

the alignment of the field

padding:char

the representation of unused space in this field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(int startPosition, int endPosition, char padding)

Adds the range of the next field in a fixed-width record. The given range cannot overlap with previously defined fields. Blanks will be used to fill any "gap" between record ranges when writing.

Parameters
startPosition:int

starting position of the field.

endPosition:int

ending position of the field

padding:char

the representation of unused space in this field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(String name, int startPosition, int endPosition, FieldAlignment alignment, char padding)

Adds the range of the next field in a fixed-width record. The given range cannot overlap with previously defined fields. Blanks will be used to fill any "gap" between record ranges when writing.

Parameters
name:String

the name of the next field. It is not validated.

startPosition:int

starting position of the field.

endPosition:int

ending position of the field

alignment:FieldAlignment

the alignment of the field

padding:char

the representation of unused space in this field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(int length)

Adds the length of the next field in a fixed-width record. This method can be chained like this: addField(5).addField(6)...

Parameters
length:int

the length of the next field. It must be greater than 0.

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(int length, FieldAlignment alignment)

Adds the length of the next field in a fixed-width record. This method can be chained like this: addField(5).addField(6)...

Parameters
length:int

the length of the next field. It must be greater than 0.

alignment:FieldAlignment

the alignment of the field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(String name, int length)

Adds the length of the next field in a fixed-width record. This method can be chained like this: addField("field_1", 5).addField("field_2", 6)...

Parameters
name:String

the name of the next field. It is not validated.

length:int

the length of the next field. It must be greater than 0.

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(String name, int length, FieldAlignment alignment)

Adds the length of the next field in a fixed-width record. This method can be chained like this: addField("field_1", 5).addField("field_2", 6)...

Parameters
name:String

the name of the next field. It is not validated.

length:int

the length of the next field. It must be greater than 0.

alignment:FieldAlignment

the alignment of the field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(int length, char padding)

Adds the length of the next field in a fixed-width record. This method can be chained like this: addField(5).addField(6)...

Parameters
length:int

the length of the next field. It must be greater than 0.

padding:char

the representation of unused space in this field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(int length, FieldAlignment alignment, char padding)

Adds the length of the next field in a fixed-width record. This method can be chained like this: addField(5).addField(6)...

Parameters
length:int

the length of the next field. It must be greater than 0.

alignment:FieldAlignment

the alignment of the field

padding:char

the representation of unused space in this field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(String name, int length, char padding)

Adds the length of the next field in a fixed-width record. This method can be chained like this: addField("field_1", 5).addField("field_2", 6)...

Parameters
name:String

the name of the next field. It is not validated.

length:int

the length of the next field. It must be greater than 0.

padding:char

the representation of unused space in this field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

addFieldback to summary
public FixedWidthFields addField(String name, int length, FieldAlignment alignment, char padding)

Adds the length of the next field in a fixed-width record. This method can be chained like this: addField("field_1", 5).addField("field_2", 6)...

Parameters
name:String

the name of the next field. It is not validated.

length:int

the length of the next field. It must be greater than 0.

alignment:FieldAlignment

the alignment of the field

padding:char

the representation of unused space in this field

Returns:FixedWidthFields

the FixedWidthFields instance itself for chaining.

cloneback to summary
protected FixedWidthFields clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:FixedWidthFields

a clone of this instance.

Annotations
@Override
forParsingback to summary
public static FixedWidthFields forParsing(Class<T> beanClass)

Creates a new instance initialized from FixedWidth annotations in the fields and methods of a given class. Note that all fields should additionally have the Parsed annotation to configure header names and/or their positions. Only setter methods will be considered as fields.

Parameters
beanClass:Class<T>

the class whose FixedWidth annotations will be processed to configure this field list.

Returns:FixedWidthFields

a new FixedWidthFields instance built with the FixedWidth annotations found in the given class' attributes and methods (excluding getters)

forWritingback to summary
public static FixedWidthFields forWriting(Class<T> beanClass)

Creates a new instance initialized from FixedWidth annotations in the fields and methods of a given class. Note that all fields should additionally have the Parsed annotation to configure header names and/or their positions. Only getter methods will be considered as fields.

Parameters
beanClass:Class<T>

the class whose FixedWidth annotations will be processed to configure this field list.

Returns:FixedWidthFields

a new FixedWidthFields instance built with the FixedWidth annotations found in the given class' attributes and methods (excluding setters)

getAlignmentback to summary
public FieldAlignment getAlignment(int position)

Returns the alignment of a given field.

Parameters
position:int

the index of the field whose alignment will be returned

Returns:FieldAlignment

the alignment of the field

getAlignmentback to summary
public FieldAlignment getAlignment(String fieldName)

Returns the alignment of a given field. An IllegalArgumentException will be thrown if no names have been defined.

Parameters
fieldName:String

the name of the field whose alignment will be returned

Returns:FieldAlignment

the alignment of the given field

getAllLengthsback to summary
pack-priv int[] getAllLengths()
getFieldAlignmentsback to summary
public FieldAlignment[] getFieldAlignments()

Returns a copy of the sequence of alignment settings to apply over each field in the fixed-width record.

Returns:FieldAlignment[]

the sequence of alignment settings to apply over each field in the fixed-width record.

getFieldLengthsback to summary
public int[] getFieldLengths()

Returns a copy of the sequence of field lengths of a fixed-width record

Returns:int[]

a copy of the sequence of field lengths of a fixed-width record

getFieldNamesback to summary
public NormalizedString[] getFieldNames()

Returns the name of each field in a fixed-width record, if any

Returns:NormalizedString[]

the name of each field in a fixed-width record, or null if no name has been defined.

getFieldPaddingsback to summary
public char[] getFieldPaddings()

Returns a copy of the sequence of padding characters to apply over each field in the fixed-width record. The null character ('\0') is used to inform no padding has been explicitly set for a field, and that the default padding character defined in FixedWidthFormat#getPadding() should be used.

Returns:char[]

the sequence of padding characters to apply over each field in the fixed-width record.

getFieldPaddingsback to summary
pack-priv char[] getFieldPaddings(FixedWidthFormat format)
getFieldsPerRecordback to summary
public int getFieldsPerRecord()

Returns the number of fields in a fixed-width record

Returns:int

the number of fields in a fixed-width record

getFieldsToIgnoreback to summary
pack-priv boolean[] getFieldsToIgnore()

Returns the sequence of fields to ignore.

Returns:boolean[]

the sequence of fields to ignore.

getKeepPaddingFlagsback to summary
pack-priv Boolean[] getKeepPaddingFlags()

Returns the sequence of fields whose padding character must/must not be retained in the parsed value

Returns:Boolean[]

the sequence that have an explicit 'keepPadding' flag.

getSelectedElementsback to summary
private <T> List<T> getSelectedElements(List<T> elements)
indexOfback to summary
public int indexOf(String fieldName)

Returns the index of a field name. An IllegalArgumentException will be thrown if no names have been defined.

Parameters
fieldName:String

the name of the field to be searched

Returns:int

the index of the field, or -1 if it does not exist.

keepPaddingOnback to summary
public void keepPaddingOn(int position, int... positions)

Configures a given list of fields to retain the padding character in any parsed values, overriding the any default set for the whole input in FixedWidthParserSettings#getKeepPadding()

Parameters
position:int

the positions of the fields that should keep the padding character

positions:int[]

additional positions

keepPaddingOnback to summary
public void keepPaddingOn(String name, String... names)

Configures a given list of fields to retain the padding character in any parsed values, overriding the any default set for the whole input in FixedWidthParserSettings#getKeepPadding()

Parameters
name:String

the name of the first field that should keep the padding character

names:String[]

the names of more fields that should keep the padding character

setAlignmentback to summary
public void setAlignment(FieldAlignment alignment, int... positions)

Applies alignment to a given list of fields

Parameters
alignment:FieldAlignment

the alignment to apply

positions:int[]

the positions of the fields that should be aligned

setAlignmentback to summary
public void setAlignment(FieldAlignment alignment, String... names)

Applies alignment to a given list of fields

Parameters
alignment:FieldAlignment

the alignment to apply

names:String[]

the names of the fields that should be aligned

setAlignmentback to summary
private void setAlignment(int position, FieldAlignment alignment)
setFieldLengthback to summary
public void setFieldLength(String name, int newLength)

Modifies the length of a given field

Parameters
name:String

the name of the field whose length must be altered

newLength:int

the new length of the given field

setFieldLengthback to summary
public void setFieldLength(int position, int newLength)

Modifies the length of a given field

Parameters
position:int

the position of the field whose length must be altered

newLength:int

the new length of the given field

setHeadersIfPossibleback to summary
pack-priv static void setHeadersIfPossible(FixedWidthFields fieldLengths, CommonSettings<F extends Format> settings)
setKeepPaddingFlagback to summary
private void setKeepPaddingFlag(boolean keep, int position, int... positions)
setKeepPaddingFlagback to summary
private void setKeepPaddingFlag(boolean keep, String name, String... names)
setPaddingback to summary
public void setPadding(char padding, int... positions)

Applies a custom padding character to a given list of fields

Parameters
padding:char

the padding to apply

positions:int[]

the positions of the fields that should use the given padding character

setPaddingback to summary
public void setPadding(char padding, String... names)

Applies a custom padding character to a given list of fields

Parameters
padding:char

the padding to apply

names:String[]

the names of the fields that should use the given padding character

setPaddingback to summary
private void setPadding(int position, char padding)
setPaddingToKeepback to summary
private void setPaddingToKeep(int position, boolean keepPaddingFlag)
stripPaddingFromback to summary
public void stripPaddingFrom(int position, int... positions)

Configures a given list of fields to remove the padding character in any parsed values, overriding the any default set for the whole input in FixedWidthParserSettings#getKeepPadding()

Parameters
position:int

the positions of the fields that should keep the padding character

positions:int[]

additional positions

stripPaddingFromback to summary
public void stripPaddingFrom(String name, String... names)

Configures a given list of fields to remove the padding character in any parsed values, overriding the any default set for the whole input in FixedWidthParserSettings#getKeepPadding()

Parameters
name:String

the name of the first field that have any padding characters removed

names:String[]

the names of the fields that should have any padding characters removed

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
validateIndexback to summary
private void validateIndex(int position)
validateLengthback to summary
private void validateLength(String name, int length)