edi

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ReaderBufSize is the default buf size for EDI reader. Making it too small might increase
	// mem-alloc and gc; making it too big increases the initial memory consumption footprint
	// (unnecessarily) for each reader creation which eventually leads to gc as well. Make it
	// exported so caller can experiment and set their optimal value.
	ReaderBufSize = 128
)

Functions

func IsErrInvalidEDI

func IsErrInvalidEDI(err error) bool

IsErrInvalidEDI checks if an err is of ErrInvalidEDI type.

func NewEDIFileFormat

func NewEDIFileFormat(schemaName string) fileformat.FileFormat

NewEDIFileFormat creates a FileFormat for EDI.

func NewReader

func NewReader(inputName string, r io.Reader, decl *FileDecl, targetXPath string) (*ediReader, error)

NewReader creates an FormatReader for EDI file format.

Types

type Elem added in v0.0.4

type Elem struct {
	Name           string  `json:"name,omitempty"`
	Index          int     `json:"index,omitempty"`
	CompIndex      *int    `json:"component_index,omitempty"`
	EmptyIfMissing bool    `json:"empty_if_missing,omitempty"` // Deprecated, use Default
	Default        *string `json:"default,omitempty"`
}

Elem describes an element inside an EDI segment.

type ErrInvalidEDI

type ErrInvalidEDI string

ErrInvalidEDI indicates the EDI content is corrupted. This is a fatal, non-continuable error.

func (ErrInvalidEDI) Error

func (e ErrInvalidEDI) Error() string

type FileDecl added in v0.0.4

type FileDecl struct {
	SegDelim    string     `json:"segment_delimiter,omitempty"`
	ElemDelim   string     `json:"element_delimiter,omitempty"`
	CompDelim   *string    `json:"component_delimiter,omitempty"`
	ReleaseChar *string    `json:"release_character,omitempty"`
	IgnoreCRLF  bool       `json:"ignore_crlf,omitempty"`
	SegDecls    []*SegDecl `json:"segment_declarations,omitempty"`
}

FileDecl describes EDI specific schema settings for omniparser reader.

type NonValidatingReader added in v0.0.6

type NonValidatingReader struct {
	// contains filtered or unexported fields
}

NonValidatingReader is an EDI segment reader that only reads out raw segments (its elements and components) directly without doing any segment structural/hierarchical validation.

func NewNonValidatingReader added in v0.0.6

func NewNonValidatingReader(r io.Reader, decl *FileDecl) *NonValidatingReader

NewNonValidatingReader creates an instance of NonValidatingReader.

func (*NonValidatingReader) Read added in v0.0.6

func (r *NonValidatingReader) Read() (RawSeg, error)

Read returns a raw segment of an EDI document. Note all the []byte are not a copy, so READONLY, no modification.

func (*NonValidatingReader) RuneBegin added in v0.0.6

func (r *NonValidatingReader) RuneBegin() int

RuneBegin returns the current reader's beginning rune position.

func (*NonValidatingReader) RuneEnd added in v0.0.6

func (r *NonValidatingReader) RuneEnd() int

RuneEnd returns the current reader's ending rune position.

func (*NonValidatingReader) SegCount added in v0.0.6

func (r *NonValidatingReader) SegCount() int

SegCount returns the current reader's segment count.

type RawSeg added in v0.0.6

type RawSeg struct {
	Name  string       // name of the segment, e.g. 'ISA', 'GS', etc.
	Raw   []byte       // the raw data of the entire segment, including segment delimiter. not owned, no mod!
	Elems []RawSegElem // all the broken down pieces of elements/components of the segment.
	// contains filtered or unexported fields
}

RawSeg represents a raw segment of an EDI document.

type RawSegElem added in v0.0.6

type RawSegElem struct {
	// ElemIndex is 1-based element index of this data inside the segment.
	ElemIndex int
	// CompIndex is 1-based component index of this data inside the element.
	CompIndex int
	// Data contains the element or component data.
	// WARNING: the data is just a slice of the raw input, not a copy - so no modification!
	// WARNING: data isn't unescaped if escaping sequence (release_character) is used; to
	//          unescape, use strs.ByteUnescape.
	Data []byte
}

RawSegElem represents an element or a component of a raw segment of an EDI document.

type SegDecl added in v0.0.4

type SegDecl struct {
	Name     string     `json:"name,omitempty"`
	Type     *string    `json:"type,omitempty"`
	IsTarget bool       `json:"is_target,omitempty"`
	Min      *int       `json:"min,omitempty"`
	Max      *int       `json:"max,omitempty"`
	Elems    []Elem     `json:"elements,omitempty"`
	Children []*SegDecl `json:"child_segments,omitempty"`
	// contains filtered or unexported fields
}

SegDecl describes an EDI segment declaration/settings.

Jump to

Keyboard shortcuts

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