Qore FixedLengthUtil Module Reference  1.0
FixedLengthUtil::FixedLengthAbstractIterator Class Referenceabstract

Structured line iterator for abstract data allowing efficient "pipelined" processing. More...

Inheritance diagram for FixedLengthUtil::FixedLengthAbstractIterator:

Public Member Functions

private *hash checkOptions (*hash opts)
 Validate and prepare global fixed-length options. More...
 
bool checkTransition (*string from, *string to)
 A verification function to be called for each line. This method can be overridden to achieve a begin-to-end validation of the whole input file. More...
 
 constructor (hash spec, *hash opts)
 Instantiates the FixedLengthAbstractIterator object. More...
 
*hash getValue ()
 Returns the current record as a hash. More...
 
string identifyType (string input_line)
 Identify a fixed-length line type using identifyTypeImpl(), that may be overridden if necessary. More...
 
*string identifyTypeImpl (string input_line)
 Identify a fixed-length line type, given the raw line string. This method performs a lookup to a precalculated table based on line lengths (see constructor()). In case different criteria are needed, eg. when two line types in a spec have the same length and no unique resolving rule are specified, this method needs to be overridden, and will throw an exception, because the precalculated mapping will be empty. More...
 
any transform (any value, hash type)
 parses the input value based on global configuration and the current field definition
 

Private Attributes

hash m_resolve_by_length
 hash of type without rule, i.e.potentially conflicting records; key = record length, value = list of no-rule type names
 

Detailed Description

Structured line iterator for abstract data allowing efficient "pipelined" processing.

Member Function Documentation

private *hash FixedLengthUtil::FixedLengthAbstractIterator::checkOptions ( *hash  opts)

Validate and prepare global fixed-length options.

Parameters
optsOptions passed during class instantiation.
bool FixedLengthUtil::FixedLengthAbstractIterator::checkTransition ( *string  from,
*string  to 
)

A verification function to be called for each line. This method can be overridden to achieve a begin-to-end validation of the whole input file.

Parameters
fromType of previous line being processed
toType of the current line being processed
FixedLengthUtil::FixedLengthAbstractIterator::constructor ( hash  spec,
*hash  opts 
)

Instantiates the FixedLengthAbstractIterator object.

Parameters
specFixed-length line specification; see Specification Hash for more information
optsGlobal options; see Global Options for more information
Exceptions
FIXED-LENGTH-UTIL-INVALID-SPECinvalid record specification; invalid type or missing field length
*hash FixedLengthUtil::FixedLengthAbstractIterator::getValue ( )

Returns the current record as a hash.

Example:
1 my hash $h = $i.getValue();
Returns
The current record as a hash with the following keys:
  • "type": a string giving the record type name
  • "record": a hash giving the parsed record data
string FixedLengthUtil::FixedLengthAbstractIterator::identifyType ( string  input_line)

Identify a fixed-length line type using identifyTypeImpl(), that may be overridden if necessary.

Parameters
input_lineInput line to be identified
Returns
the name of the record corresponding to the input line
Exceptions
FIXED-LENGTH-UTIL-NON-MATCHING-TYPEinput line cannot be matched to a known record
*string FixedLengthUtil::FixedLengthAbstractIterator::identifyTypeImpl ( string  input_line)

Identify a fixed-length line type, given the raw line string. This method performs a lookup to a precalculated table based on line lengths (see constructor()). In case different criteria are needed, eg. when two line types in a spec have the same length and no unique resolving rule are specified, this method needs to be overridden, and will throw an exception, because the precalculated mapping will be empty.

Parameters
input_lineInput line to be identified
Returns
the record name or NOTHING if the input cannot be matched
Exceptions
FIXED-LENGTH-UTIL-NON-MATCHING-TYPEinput line cannot be matched to a known record or the input line's length does not match the expected length