public class FixedWidthTextRecord extends Object
Modifier and Type | Field and Description |
---|---|
protected Map<String,TextField<T>> |
textFieldsByName |
Constructor and Description |
---|
FixedWidthTextRecord()
Defines an empty fixed-width record.
|
FixedWidthTextRecord(TextConversionDefaults defaults)
Defines an empty fixed-width record with the specified
text conversion behavior.
|
FixedWidthTextRecord(TextConversionDefaults defaults,
Map<String,FixedSizeTextType> fieldTypes)
Defines a record with the specified
text conversion behavior and fields.
|
Modifier and Type | Method and Description |
---|---|
TokenFormatter |
createFieldFormatter(String fieldName)
Creates a new formatter for values of the specified field.
|
TokenParser |
createFieldParser(String fieldName)
Creates a new parser for values of the specified field.
|
void |
defineField(String name,
T type)
Defines a new field in the record with the specified
name and type.
|
void |
defineField(String name,
T type,
FieldDomain domain)
Defines a new field in the record with the specified
name and type.
|
TextConversionDefaults |
getDefaults()
Gets the default conversion behaviors for fields in the
schema which do not explicitly define any.
|
int |
getFieldCount()
Gets the number of fields defined in the record.
|
FieldDomain |
getFieldDomain(String name)
Gets the domain of the specified field in the record.
|
List<String> |
getFieldNames()
Gets the names of the fields defined in the record.
|
int |
getFieldOffset(String name)
Gets the offset the the specified field from the start of the
record.
|
int |
getFieldSize(String name)
Gets the size of the specified field.
|
T |
getFieldType(String name)
Gets the type of the specified fields in the record.
|
int |
getRecordLength()
The defined length of the record.
|
List<TextField<FixedSizeTextType>> |
getTextFields() |
RecordTokenType |
getTokenType()
Gets the type of the token representation of the
text record.
|
boolean |
isFieldDefined(String name)
Indicates whether a field with the given name is already
defined.
|
void |
setFieldType(String name,
T newType)
Modifies the value conversion scheme for an existing field.
|
protected final Map<String,TextField<T extends TextDataType>> textFieldsByName
public FixedWidthTextRecord()
An empty record definition is not meaningful; it is expected that at least one field will be defined before the schema is used. The length of the record is determined from the size of the fields.
TextConversionDefaults
public FixedWidthTextRecord(TextConversionDefaults defaults)
An empty record definition is not meaningful; it is expected that at least one field will be defined before the schema is used. The length of the record is determined from the size of the fields.
defaults
- text conversion behavior to apply by
default to the schemapublic FixedWidthTextRecord(TextConversionDefaults defaults, Map<String,FixedSizeTextType> fieldTypes)
defaults
- default text conversion behavior for the schemafieldTypes
- the defined fields in the record schema
default to the schemapublic int getRecordLength()
public List<TextField<FixedSizeTextType>> getTextFields()
public int getFieldSize(String name)
name
- the field for which to report the size.
This field must exist in the schema.public int getFieldOffset(String name)
name
- the field for which to calculate the offset.
This field must exist in the schema.public final TextConversionDefaults getDefaults()
RecordTextSchema
getDefaults
in interface RecordTextSchema<T extends TextDataType>
public final RecordTokenType getTokenType()
RecordTextSchema
getTokenType
in interface RecordTextSchema<T extends TextDataType>
public final int getFieldCount()
RecordTextSchema
getFieldCount
in interface RecordTextSchema<T extends TextDataType>
public final List<String> getFieldNames()
RecordTextSchema
getFieldNames
in interface RecordTextSchema<T extends TextDataType>
public final boolean isFieldDefined(String name)
RecordTextSchema
isFieldDefined
in interface RecordTextSchema<T extends TextDataType>
name
- the field to checktrue
if a field with the name is
defined in the schema, false
otherwise.public final void defineField(String name, T type)
name
- the name associated with the field. The
name must be unique amongst all defined fields.type
- specifies how to convert between text and
token valuespublic final void defineField(String name, T type, FieldDomain domain)
name
- the name associated with the field. The
name must be unique amongst all defined fields.type
- specifies how to convert between text and
token valuespublic final T getFieldType(String name)
RecordTextSchema
getFieldType
in interface RecordTextSchema<T extends TextDataType>
name
- the field for which to fetch the typepublic final FieldDomain getFieldDomain(String name)
RecordTextSchema
getFieldDomain
in interface RecordTextSchema<T extends TextDataType>
name
- the field for which to fetch the domainpublic final void setFieldType(String name, T newType)
name
- the field to modify. This field
must exist in the schema.newType
- specifies how to convert between text and
token valuespublic final TokenParser createFieldParser(String fieldName)
RecordTextSchema
createFieldParser
in interface RecordTextSchema<T extends TextDataType>
fieldName
- the field for which to obtain a parserpublic final TokenFormatter createFieldFormatter(String fieldName)
RecordTextSchema
createFieldFormatter
in interface RecordTextSchema<T extends TextDataType>
fieldName
- the field for which to obtain a formatterCopyright © 2021 Actian Corporation. All rights reserved.