|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.univocity.parsers.fixed.FixedWidthFields
public class FixedWidthFields
This class provides the name, length, alignment and padding of each field in a fixed-width record.
| Constructor Summary | |
|---|---|
FixedWidthFields(int... fieldLengths)
Creates a new instance initialized with the lengths of all fields in a fixed-width record. |
|
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. |
|
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. |
|
| Method Summary | |
|---|---|
FixedWidthFields |
addField(int length)
Adds the length of the next field in a fixed-width record. |
FixedWidthFields |
addField(int length,
char padding)
Adds the length of the next field in a fixed-width record. |
FixedWidthFields |
addField(int length,
FieldAlignment alignment)
Adds the length of the next field in a fixed-width record. |
FixedWidthFields |
addField(int length,
FieldAlignment alignment,
char padding)
Adds the length of the next field in a fixed-width record. |
FixedWidthFields |
addField(String name,
int length)
Adds the length of the next field in a fixed-width record. |
FixedWidthFields |
addField(String name,
int length,
char padding)
Adds the length of the next field in a fixed-width record. |
FixedWidthFields |
addField(String name,
int length,
FieldAlignment alignment)
Adds the length of the next field in a fixed-width record. |
FixedWidthFields |
addField(String name,
int length,
FieldAlignment alignment,
char padding)
Adds the length of the next field in a fixed-width record. |
FieldAlignment |
getAlignment(int position)
Returns the alignment of a given field. |
FieldAlignment |
getAlignment(String fieldName)
Returns the alignment of a given field. |
FieldAlignment[] |
getFieldAlignments()
Returns a copy of the sequence of alignment settings to apply over each field in the fixed-width record. |
int[] |
getFieldLengths()
Returns a copy of the sequence of field lengths of a fixed-width record |
String[] |
getFieldNames()
Returns the name of each field in a fixed-width record, if any |
char[] |
getFieldPaddings()
Returns a copy of the sequence of padding characters to apply over each field in the fixed-width record. |
int |
getFieldsPerRecord()
Returns the number of fields in a fixed-width record |
int |
indexOf(String fieldName)
Returns the index of a field name. |
void |
setAlignment(FieldAlignment alignment,
int... positions)
Applies alignment to a given list of fields |
void |
setAlignment(FieldAlignment alignment,
String... names)
Applies alignment to a given list of fields |
void |
setFieldLength(int position,
int newLength)
Modifies the length of a given field |
void |
setFieldLength(String name,
int newLength)
Modifies the length of a given field |
void |
setPadding(char padding,
int... positions)
Applies a custom padding character to a given list of fields |
void |
setPadding(char padding,
String... names)
Applies a custom padding character to a given list of fields |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public FixedWidthFields(LinkedHashMap<String,Integer> fields)
CommonSettings.setHeaders(String...).
fields - a LinkedHashMap containing the sequence of fields to be associated with each column in the input/output, with their respective length.
public FixedWidthFields(String[] headers,
int[] lengths)
CommonSettings.setHeaders(String...).
headers - the sequence of fields to be associated with each column in the input/outputlengths - the sequence of lengths to be associated with each given header. The size of this array must match the number of given headers.public FixedWidthFields(int... fieldLengths)
fieldLengths - The number lengths of all fields in a fixed-width record. All lengths must be greater than 0.| Method Detail |
|---|
public FixedWidthFields addField(int length)
length - the length of the next field. It must be greater than 0.
public FixedWidthFields addField(int length,
FieldAlignment alignment)
length - the length of the next field. It must be greater than 0.alignment - the alignment of the field
public FixedWidthFields addField(String name,
int length)
name - the name of the next field. It is not validated.length - the length of the next field. It must be greater than 0.
public FixedWidthFields addField(String name,
int length,
FieldAlignment alignment)
name - the name of the next field. It is not validated.length - the length of the next field. It must be greater than 0.alignment - the alignment of the field
public FixedWidthFields addField(int length,
char padding)
length - the length of the next field. It must be greater than 0.padding - the representation of unused space in this field
public FixedWidthFields addField(int length,
FieldAlignment alignment,
char padding)
length - the length of the next field. It must be greater than 0.alignment - the alignment of the fieldpadding - the representation of unused space in this field
public FixedWidthFields addField(String name,
int length,
char padding)
name - the name of the next field. It is not validated.length - the length of the next field. It must be greater than 0.padding - the representation of unused space in this field
public FixedWidthFields addField(String name,
int length,
FieldAlignment alignment,
char padding)
name - the name of the next field. It is not validated.length - the length of the next field. It must be greater than 0.alignment - the alignment of the fieldpadding - the representation of unused space in this field
public int getFieldsPerRecord()
public String[] getFieldNames()
public int[] getFieldLengths()
public void setFieldLength(String name,
int newLength)
name - the name of the field whose length must be alterednewLength - the new length of the given field
public void setFieldLength(int position,
int newLength)
position - the position of the field whose length must be alterednewLength - the new length of the given field
public void setAlignment(FieldAlignment alignment,
int... positions)
alignment - the alignment to applypositions - the positions of the fields that should be aligned
public void setAlignment(FieldAlignment alignment,
String... names)
alignment - the alignment to applynames - the names of the fields that should be alignedpublic int indexOf(String fieldName)
IllegalArgumentException will be thrown if no names have been defined.
fieldName - the name of the field to be searched
public FieldAlignment getAlignment(int position)
position - the index of the field whose alignment will be returned
public FieldAlignment getAlignment(String fieldName)
IllegalArgumentException will be thrown if no names have been defined.
fieldName - the name of the field whose alignment will be returned
public FieldAlignment[] getFieldAlignments()
public char[] getFieldPaddings()
'\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.
public void setPadding(char padding,
int... positions)
padding - the padding to applypositions - the positions of the fields that should use the given padding character
public void setPadding(char padding,
String... names)
padding - the padding to applynames - the names of the fields that should use the given padding characterpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||