CopyableTableParser

com.phasmidsoftware.tableparser.core.parse.CopyableTableParser
trait CopyableTableParser[Row, Input, Table]

A trait representing a parser for tables that supports configurability and row-level parsing.

The CopyableTableParser provides methods to configure the parsing behavior of tables, such as defining headers, enabling forgiving or multiline parsing modes, setting predicates for row filtering, and defining custom row parsing logic. It operates generically over three types: Row, representing a single row in the table; Input, representing raw input data for parsing rows; and Table, representing the parsed table as a whole.

Type parameters

Input

the type of the raw input data used to parse rows.

Row

the type of a single row in the table.

Table

the type of the parsed table.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def setForgiving(forgiving: Boolean): TableParser[Table]

Configures the parser to operate in a "forgiving" mode, where errors encountered during the parsing of individual rows are logged but do not cause the parsing process to fail. When set to true, the parser will attempt to continue parsing despite encountering errors in the input. When set to false, errors will cause the parsing process to terminate.

Configures the parser to operate in a "forgiving" mode, where errors encountered during the parsing of individual rows are logged but do not cause the parsing process to fail. When set to true, the parser will attempt to continue parsing despite encountering errors in the input. When set to false, errors will cause the parsing process to terminate.

Value parameters

forgiving

a boolean value indicating whether forgiving mode should be enabled. true enables forgiving mode, allowing parsing to continue on errors. false disables forgiving mode, causing failures on errors.

Attributes

Returns

an instance of TableParser[Table] configured with the specified forgiving behavior.

def setHeader(header: Header): TableParser[Table]

Sets a fixed header for the table parser. This method allows the configuration of the parser to use the specified header, instead of deriving it from the data during parsing.

Sets a fixed header for the table parser. This method allows the configuration of the parser to use the specified header, instead of deriving it from the data during parsing.

Value parameters

header

the Header instance representing the fixed header for the table parser, containing column names and optional additional header lines.

Attributes

Returns

a new TableParser[Table] instance configured with the specified header.

def setMultiline(multiline: Boolean): TableParser[Table]

Configures the parser to allow or disallow quoted strings to span across multiple lines.

Configures the parser to allow or disallow quoted strings to span across multiple lines.

When multiline is set to true, the parser permits quoted strings in the input to extend beyond a single line. If set to false, quoted strings are constrained to stay within one line.

Value parameters

multiline

a boolean flag indicating whether multiline parsing of quoted strings is enabled (true) or disabled (false).

Attributes

Returns

a new TableParser[Table] instance configured with the updated multiline setting.

def setPredicate(predicate: Try[Row] => Boolean): TableParser[Table]

Sets a predicate function that determines whether a parsed Row should be included in the final Table. The predicate is applied to each parsed Row wrapped in a Try to allow filtering based on success or failure.

Sets a predicate function that determines whether a parsed Row should be included in the final Table. The predicate is applied to each parsed Row wrapped in a Try to allow filtering based on success or failure.

Value parameters

predicate

a function of type Try[Row] => Boolean that accepts a Try of a Row and returns true if the row should be included in the table, or false otherwise.

Attributes

Returns

a new instance of TableParser[Table] with the specified predicate applied.

def setRowParser(rowParser: RowParser[Row, Input]): TableParser[Table]

Sets the row parser to be used for parsing rows in the table.

Sets the row parser to be used for parsing rows in the table.

The row parser provides the logic for converting raw input data of type Input into rows of type Row. This method allows you to configure the table parser with a custom row parser, enabling flexibility in interpreting the rows according to specific requirements.

Value parameters

rowParser

the RowParser instance to use for parsing rows. The RowParser defines how each input (of type Input) is transformed into a row (of type Row), potentially using a Header for additional context.

Attributes

Returns

a new TableParser instance configured with the specified row parser.