fixedlength

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrInvalidFixedLength

func IsErrInvalidFixedLength(err error) bool

IsErrInvalidFixedLength checks if the `err` is of ErrInvalidFixedLength type.

func NewFixedLengthFileFormat

func NewFixedLengthFileFormat(schemaName string) fileformat.FileFormat

NewFixedLengthFileFormat creates a FileFormat for 'fixedlength2'.

func NewReader

func NewReader(
	inputName string, r io.Reader, decl *FileDecl, targetXPathExpr *xpath.Expr) *reader

NewReader creates an FormatReader for fixed-length file format.

Types

type ColumnDecl

type ColumnDecl struct {
	Name        string  `json:"name,omitempty"`
	StartPos    int     `json:"start_pos,omitempty"`  // 1-based. and rune-based.
	Length      int     `json:"length,omitempty"`     // rune-based length.
	LineIndex   *int    `json:"line_index,omitempty"` // 1-based.
	LinePattern *string `json:"line_pattern,omitempty"`
	// contains filtered or unexported fields
}

ColumnDecl describes a column of an envelope.

type EnvelopeDecl

type EnvelopeDecl struct {
	Name     string          `json:"name,omitempty"`
	Rows     *int            `json:"rows,omitempty"`
	Header   *string         `json:"header,omitempty"`
	Footer   *string         `json:"footer,omitempty"`
	Type     *string         `json:"type,omitempty"`
	IsTarget bool            `json:"is_target,omitempty"`
	Min      *int            `json:"min,omitempty"`
	Max      *int            `json:"max,omitempty"`
	Columns  []*ColumnDecl   `json:"columns,omitempty"`
	Children []*EnvelopeDecl `json:"child_envelopes,omitempty"`
	// contains filtered or unexported fields
}

EnvelopeDecl describes an envelope of a fixed-length input. If Rows/Header/Footer are all nil, then it defaults to Rows = 1. If Rows specified, then Header/Footer must be nil. (JSON schema validation will ensure this.) If Header is specified, Rows must be nil. (JSON schema validation will ensure this.) Footer is optional; If not specified, Header will be used for a single-line envelope matching.

func (*EnvelopeDecl) ChildDecls

func (e *EnvelopeDecl) ChildDecls() []flatfile.RecDecl

func (*EnvelopeDecl) DeclName

func (e *EnvelopeDecl) DeclName() string

func (*EnvelopeDecl) Group

func (e *EnvelopeDecl) Group() bool

func (*EnvelopeDecl) MaxOccurs

func (e *EnvelopeDecl) MaxOccurs() int

MaxOccurs defaults to unbounded. Fixed-length input most common scenario is min=0/max=unbounded.

func (*EnvelopeDecl) MinOccurs

func (e *EnvelopeDecl) MinOccurs() int

MinOccurs defaults to 0. Fixed-length input most common scenario is min=0/max=unbounded.

func (*EnvelopeDecl) Target

func (e *EnvelopeDecl) Target() bool

type ErrInvalidFixedLength

type ErrInvalidFixedLength string

ErrInvalidFixedLength indicates the fixed-length content is corrupted or IO failure. This is a fatal, non-continuable error.

func (ErrInvalidFixedLength) Error

func (e ErrInvalidFixedLength) Error() string

Error implements error interface.

type FileDecl

type FileDecl struct {
	Envelopes []*EnvelopeDecl `json:"envelopes,omitempty"`
}

FileDecl describes fixed-length schema `file_declaration` setting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL