public class TextRecord extends Object
Modifier and Type | Field and Description |
---|---|
static TextRecordDiscoverer |
DEFAULT_AUTODISCOVER
The default schema discoverer used for reading delimited text.
|
static TextRecordDiscoverer |
TEXT_FIELD_DISCOVER
A schema discoverer which treats all fields as raw text.
|
protected Map<String,TextField<T>> |
textFieldsByName |
Constructor and Description |
---|
TextRecord()
Defines an empty record.
|
TextRecord(TextConversionDefaults defaults)
Defines an empty record with the specified
text conversion behavior.
|
TextRecord(TextConversionDefaults defaults,
Map<String,TextDataType> fieldTypes)
Defines a record with the specified
text conversion behavior and fields.
|
Modifier and Type | Method and Description |
---|---|
static TextRecord |
convert(RecordTokenType type)
Generates a text file schema from a token type.
|
static TextRecord |
convert(RecordTokenType type,
TextConversionDefaults defaults)
Generates a text file schema from a token type, using the
specified schema-wide default behavior.
|
static TextRecord |
convert(RecordTokenType type,
TextTypes.StringConversion behavior)
Generates a text file schema from a token type, using the
specified string conversion default behavior.
|
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.
|
static TextRecordDiscoverer |
extendDefault(List<TypePattern> additions)
Creates a new discoverer which extends the default patterns.
|
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.
|
T |
getFieldType(String name)
Gets the type of the specified fields in the record.
|
List<TextField<TextDataType>> |
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.
|
public static final TextRecordDiscoverer DEFAULT_AUTODISCOVER
PatternBasedDiscovery
.public static final TextRecordDiscoverer TEXT_FIELD_DISCOVER
ReadDelimitedText
, the
resulting schema identifies the field values without
interpreting them.
The output type produced is compatible for use as input to
ParseTextFields
.
protected final Map<String,TextField<T extends TextDataType>> textFieldsByName
public TextRecord()
An empty record definition is not meaningful; at least one field must be defined before the schema is used.
TextConversionDefaults
public TextRecord(TextConversionDefaults defaults)
An empty record definition is not meaningful; at least one field must be defined before the schema is used.
defaults
- text conversion behavior to apply by
default to the schemapublic TextRecord(TextConversionDefaults defaults, Map<String,TextDataType> fieldTypes)
defaults
- default text conversion behavior for the schemafieldTypes
- the defined fields in the record schema
default to the schemapublic static final TextRecord convert(RecordTokenType type)
type
- the template type for which to create a text schemapublic static final TextRecord convert(RecordTokenType type, TextTypes.StringConversion behavior)
type
- the template type for which to create a text schemabehavior
- the schema-wide default behavior for string
conversionpublic List<TextField<TextDataType>> getTextFields()
public static final TextRecord convert(RecordTokenType type, TextConversionDefaults defaults)
type
- the template type for which to create a text schemadefaults
- the schema-wide default settings for text conversionpublic static TextRecordDiscoverer extendDefault(List<TypePattern> additions)
PatternBasedDiscovery.DEFAULT_PATTERNS
.additions
- additional patterns to use in determining field typespublic 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 © 2020 Actian Corporation. All rights reserved.