Documentation
¶
Index ¶
- type EDIFACTConfig
- type Element
- type GenericElement
- type GenericMessage
- func (m *GenericMessage) Flatten() map[string]interface{}
- func (m *GenericMessage) GetSegmentByTag(tag string) *GenericSegment
- func (m *GenericMessage) GetSegmentsByTag(tag string) []*GenericSegment
- func (m *GenericMessage) String() string
- func (m *GenericMessage) ToJSON() ([]byte, error)
- func (m *GenericMessage) ToJSONString() (string, error)
- type GenericMessageBuilder
- func (b *GenericMessageBuilder) AddSegment(tag string, elements []GenericElement, rawString string) *GenericMessageBuilder
- func (b *GenericMessageBuilder) Build() *GenericMessage
- func (b *GenericMessageBuilder) SetMessageRef(msgRef string) *GenericMessageBuilder
- func (b *GenericMessageBuilder) SetMessageType(msgType string) *GenericMessageBuilder
- func (b *GenericMessageBuilder) SetRawContent(content string) *GenericMessageBuilder
- type GenericSegment
- type Message
- type MessageHandler
- type ParseError
- type Segment
- type Token
- type TokenType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EDIFACTConfig ¶
type EDIFACTConfig struct {
SegmentTerminator string
ElementSeparator string
ComponentSeparator string
ReleaseCharacter string
}
EDIFACTConfig holds configuration for EDIFACT parsing
func DefaultConfig ¶
func DefaultConfig() EDIFACTConfig
DefaultConfig returns the default EDIFACT configuration
type GenericElement ¶
type GenericElement struct {
Position int `json:"position"`
Value string `json:"value"`
Components []string `json:"components"`
IsComposite bool `json:"is_composite"`
ComponentCount int `json:"component_count"`
}
GenericElement represents a generic EDIFACT element
type GenericMessage ¶
type GenericMessage struct {
MessageType string `json:"message_type"`
MessageRef string `json:"message_ref"`
Segments []GenericSegment `json:"segments"`
RawContent string `json:"raw_content"`
SegmentCount int `json:"segment_count"`
ElementCount int `json:"element_count"`
ComponentCount int `json:"component_count"`
}
GenericMessage represents a generic EDIFACT message that can handle any message type
func (*GenericMessage) Flatten ¶
func (m *GenericMessage) Flatten() map[string]interface{}
Flatten returns a flattened representation of all elements
func (*GenericMessage) GetSegmentByTag ¶
func (m *GenericMessage) GetSegmentByTag(tag string) *GenericSegment
GetSegmentByTag returns the first segment with the given tag
func (*GenericMessage) GetSegmentsByTag ¶
func (m *GenericMessage) GetSegmentsByTag(tag string) []*GenericSegment
GetSegmentsByTag returns all segments with the given tag
func (*GenericMessage) String ¶
func (m *GenericMessage) String() string
String returns a string representation of the generic message
func (*GenericMessage) ToJSON ¶
func (m *GenericMessage) ToJSON() ([]byte, error)
ToJSON converts the generic message to JSON
func (*GenericMessage) ToJSONString ¶
func (m *GenericMessage) ToJSONString() (string, error)
ToJSONString converts the generic message to a JSON string
type GenericMessageBuilder ¶
type GenericMessageBuilder struct {
// contains filtered or unexported fields
}
GenericMessageBuilder helps build generic messages
func NewGenericMessageBuilder ¶
func NewGenericMessageBuilder() *GenericMessageBuilder
NewGenericMessageBuilder creates a new generic message builder
func (*GenericMessageBuilder) AddSegment ¶
func (b *GenericMessageBuilder) AddSegment(tag string, elements []GenericElement, rawString string) *GenericMessageBuilder
AddSegment adds a segment to the message
func (*GenericMessageBuilder) Build ¶
func (b *GenericMessageBuilder) Build() *GenericMessage
Build returns the built generic message
func (*GenericMessageBuilder) SetMessageRef ¶
func (b *GenericMessageBuilder) SetMessageRef(msgRef string) *GenericMessageBuilder
SetMessageRef sets the message reference
func (*GenericMessageBuilder) SetMessageType ¶
func (b *GenericMessageBuilder) SetMessageType(msgType string) *GenericMessageBuilder
SetMessageType sets the message type
func (*GenericMessageBuilder) SetRawContent ¶
func (b *GenericMessageBuilder) SetRawContent(content string) *GenericMessageBuilder
SetRawContent sets the raw EDIFACT content
type GenericSegment ¶
type GenericSegment struct {
Tag string `json:"tag"`
Elements []GenericElement `json:"elements"`
ElementCount int `json:"element_count"`
Position int `json:"position"`
RawString string `json:"raw_string"`
}
GenericSegment represents a generic EDIFACT segment
func (*GenericSegment) GetComponentValue ¶
func (s *GenericSegment) GetComponentValue(elementPosition, componentPosition int) string
GetComponentValue returns the value of a specific component in an element
func (*GenericSegment) GetElement ¶
func (s *GenericSegment) GetElement(position int) *GenericElement
GetElement returns the element at the specified position (1-based)
func (*GenericSegment) GetElementComponents ¶
func (s *GenericSegment) GetElementComponents(position int) []string
GetElementComponents returns the components of an element at the specified position
func (*GenericSegment) GetElementValue ¶
func (s *GenericSegment) GetElementValue(position int) string
GetElementValue returns the value of an element at the specified position
type Message ¶
Message represents a complete EDIFACT message
func (*Message) GetSegmentByTag ¶
GetSegmentByTag returns the first segment with the given tag
func (*Message) GetSegmentsByTag ¶
GetSegmentsByTag returns all segments with the given tag
type MessageHandler ¶
type MessageHandler interface {
Handle(message *Message) (interface{}, error)
CanHandle(messageType string) bool
}
MessageHandler defines the interface for message-specific handlers
type ParseError ¶
ParseError represents a parsing error
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type Segment ¶
Segment represents an EDIFACT segment
func (*Segment) GetElement ¶
GetElement returns the element at the specified position (1-based)