IndexedInputToRowsTransformer

com.phasmidsoftware.tableparser.core.parse.IndexedInputToRowsTransformer
class IndexedInputToRowsTransformer[Input, Row](f: ((Input, Int)) => Try[Row], multiline: Boolean)(using evidence$1: Joinable[Input]) extends InputTransformer[Input, Row]

A transformer class designed to map and process inputs to rows while handling indexed inputs.

This class extends InputTransformer and provides functionality to apply a transformation defined by a function f to indexed inputs ((Input, Int)), processing the resulting Try[Row] instances to either extract valid Row results or handle errors using logging.

Type parameters

Input

The type of input elements to be processed. Must have an implicit Joinable[Input] defined.

Row

The type of rows produced after transformation.

Value parameters

f

A function that takes an (Input, Int) tuple and maps it to a Try[Row], representing the transformation logic from input to row with error handling.

multiline

A boolean flag indicating whether the transformation operates in a multiline mode.

Attributes

Graph
Supertypes
class InputTransformer[Input, Row]
trait InputPreprocessor[Input, Row]
class Object
trait Matchable
class Any

Members list

Type members

Classlikes

object JoinableTInt extends JoinableTInt[Input]

Implicit object representing a JoinableTInt instance for the type Input.

Implicit object representing a JoinableTInt instance for the type Input.

This implicit ensures that the JoinableTInt operations (such as join, zero, and valid) are defined for (Input, Int) based on the behavior of an implicitly available Joinable[Input] instance.

Definitions:

  • Joinable: A type class that defines how to join elements of a type, provide a zero value, and validate elements.
  • JoinableTInt: A specialized Joinable for tuples of type (T, Int), where the joining logic relies on the Joinable[T] instance for the first element of the tuple.

Usage:

  • This implicit object provides JoinableTInt behavior for (Input, Int) automatically, provided there is an implicit Joinable[Input] in scope.

Details:

  • The tj member refers to the Joinable[Input] instance, obtained implicitly.

Attributes

Supertypes
trait Joinable[(IndexedInputToRowsTransformer.this.Input, Int)]
class Object
trait Matchable
class Any
Self type

Value members

Concrete methods

def processInput(xs: Iterator[Input]): Iterator[Row]

Processes an iterator of input elements, transforming them into an iterator of output rows. This method applies a two-step transformation: first, it maps the input elements into Try[Row] instances using the mapTsToRows method, then it processes these Try[Row] instances with processTriedRows to produce valid rows or handle errors.

Processes an iterator of input elements, transforming them into an iterator of output rows. This method applies a two-step transformation: first, it maps the input elements into Try[Row] instances using the mapTsToRows method, then it processes these Try[Row] instances with processTriedRows to produce valid rows or handle errors.

Value parameters

xs

An Iterator of input elements of type Input, representing the data to be transformed.

Attributes

Returns

An Iterator of output rows of type Row, resulting from the transformation process.

def processTriedRows(rys: Iterator[Try[Row]]): Iterator[Row]

Processes an iterator of Try[Row] instances, filtering out any failures and retaining only successful results. For each Failure encountered, the exception is logged using the logException method. The successful Row objects are then extracted and returned as an iterator.

Processes an iterator of Try[Row] instances, filtering out any failures and retaining only successful results. For each Failure encountered, the exception is logged using the logException method. The successful Row objects are then extracted and returned as an iterator.

Value parameters

rys

An Iterator of Try[Row] instances to be processed, where each element represents a possible row or an error.

Attributes

Returns

An Iterator of Row objects, containing only the successful results from the input.

def triedRows(xs: Iterator[Input]): Iterator[Try[Row]]

Method to parse the input lazily, into rows, each a Try (joining lines which make up one row if multiline). Nothing is read until the result is iterated.

Method to parse the input lazily, into rows, each a Try (joining lines which make up one row if multiline). Nothing is read until the result is iterated.

Value parameters

xs

the input (after any header lines).

Attributes

Returns

an Iterator of Try[Row].

Inherited methods

def mapTsToRows(xs: Iterator[Input])(multiline: Boolean)(g: ((Input, Int)) => Try[Row])(using ev: Joinable[(Input, Int)]): Iterator[Try[Row]]

Processes an input iterator of type Input and maps its elements into rows of type Row while handling potential errors using a specified transformation function. The function can operate in two modes:

Processes an input iterator of type Input and maps its elements into rows of type Row while handling potential errors using a specified transformation function. The function can operate in two modes:

  • Multiline mode: input data can span multiple lines and will be joined using the provided Joinable type class.
  • Single-line mode: each input element is processed independently.

Value parameters

ev

An implicit instance of the Joinable[(Input, Int)] type class, which handles joining and validating input tuples during multiline mode.

g

A transformation function that takes a tuple (Input, Int), representing an input element and its index, and returns a Try[Row]. The function should encapsulate the logic for mapping input to a row, including error handling.

multiline

A Boolean flag indicating whether to process input in multiline mode. - true: Enables multiline processing using the provided Joinable type class. - false: Processes each input independently.

xs

The input iterator containing elements of type Input.

Attributes

Returns

An iterator of Try[Row], where each element represents either a successfully processed row or a failure. - In multiline mode, elements may span across multiple lines, joined using the logic provided by the Joinable type class. - In single-line mode, each input element is processed individually.

Inherited from:
InputPreprocessor

Givens

Givens

Implicit object representing a JoinableTInt instance for the type Input.

Implicit object representing a JoinableTInt instance for the type Input.

This implicit ensures that the JoinableTInt operations (such as join, zero, and valid) are defined for (Input, Int) based on the behavior of an implicitly available Joinable[Input] instance.

Definitions:

  • Joinable: A type class that defines how to join elements of a type, provide a zero value, and validate elements.
  • JoinableTInt: A specialized Joinable for tuples of type (T, Int), where the joining logic relies on the Joinable[T] instance for the first element of the tuple.

Usage:

  • This implicit object provides JoinableTInt behavior for (Input, Int) automatically, provided there is an implicit Joinable[Input] in scope.

Details:

  • The tj member refers to the Joinable[Input] instance, obtained implicitly.

Attributes