EncryptedHeadedStringTableParser

com.phasmidsoftware.tableparser.crypto.parse.EncryptedHeadedStringTableParser
case class EncryptedHeadedStringTableParser[X, A](encryptedRowPredicate: String => Boolean, keyFunction: String => String, maybeHeader: Option[Header] = ..., forgiving: Boolean = ..., headerRowsToRead: Int = ...)(using evidence$1: CellParser[X], evidence$2: HexEncryption[A]) extends HeadedStringTableParser[X]

Case class to define a StringTableParser that assumes a header to be found in the input file. This class attempts to provide as much built-in functionality as possible.

This class assumes that the names of the columns are in the first line. This class implements builder with a HeadedTable object. This class uses StandardRowParser of its rowParser.

Type parameters

A

the cipher algorithm (for which there must be evidence of HexEncryption[A]).

X

the underlying row type for which there must be evidence of a CellParser.

Value parameters

encryptedRowPredicate

a function which takes a String and returns a Boolean.

forgiving

if true, exceptions when parsing individual rows will be logged then ignored. if false, any exception will terminate the parsing. Defaults to false.

headerRowsToRead

the number of header rows expected in the input file defaults to 1.

keyFunction

a function which takes a String and returns a String (input might be ignored).

maybeHeader

None => requires that the data source has a header row. Some(h) => specifies that the header is to be taken from h. Defaults to None. NOTE: that the simplest is to specify the header directly from the type X.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait CopyableTableParser[X, String, Table[X]]
trait TableParser[Table[X]]
trait TableBuilder[Table[X]]
class Object
trait Matchable
class Any
Show all

Members list

Type members

Inherited types

type Input = String

The input type, typically String or Strings.

The input type, typically String or Strings.

Attributes

Inherited from:
StringTableParser
type Row = X

The row type.

The row type.

Attributes

Inherited from:
HeadedStringTableParser

Value members

Concrete methods

override def parse(xs: Iterator[String], n: Int = ...): Try[Table[X]]

Method to parse an encrypted table, as Table.parse (and parseFile, parseResource, etc.) do. This is parseIO, run synchronously (decryption is done in IO). Up to 2.0.1, this was the parse method of HeadedStringTableParser, which doesn't decrypt.

Method to parse an encrypted table, as Table.parse (and parseFile, parseResource, etc.) do. This is parseIO, run synchronously (decryption is done in IO). Up to 2.0.1, this was the parse method of HeadedStringTableParser, which doesn't decrypt.

Value parameters

n

the number of lines which make up the header.

xs

the lines of the input.

Attributes

Returns

a Try[Table].

Definition Classes
def parseIO(xr: Iterator[String], n: Int): IO[Table[X]]

Method to parse an encrypted table. The first n lines are the (plaintext) header. Each of the other lines is a key and the encrypted row, separated by "|" (see CsvTableEncryptedFileRenderer). Only the rows whose key satisfies encryptedRowPredicate are decrypted (with the key given by keyFunction), and they are then parsed as plaintext rows, with the header.

Method to parse an encrypted table. The first n lines are the (plaintext) header. Each of the other lines is a key and the encrypted row, separated by "|" (see CsvTableEncryptedFileRenderer). Only the rows whose key satisfies encryptedRowPredicate are decrypted (with the key given by keyFunction), and they are then parsed as plaintext rows, with the header.

Value parameters

n

the number of lines which make up the header.

xr

the lines of the input.

Attributes

Returns

an IO[Table].

def setForgiving(b: Boolean): TableParser[Table[X]]

Set the value of forgiving for the plaintext TableParser.

Set the value of forgiving for the plaintext TableParser.

Value parameters

b

true or false. See TableParser.

Attributes

Returns

a TableParser of Table[X]

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

Set the Header for the plaintext TableParser.

Set the Header for the plaintext TableParser.

CONSIDER does this make sense to allow?

Value parameters

header

the required Header.

Attributes

Returns

a TableParser of Table[X]

def setMultiline(b: Boolean): TableParser[Table[X]]

Set the value of multiline for the plaintext TableParser.

Set the value of multiline for the plaintext TableParser.

Value parameters

b

value of multiline for the plaintext TableParser. See TableParser.

Attributes

Returns

a TableParser of Table[X]

def setPlaintextPredicate(p: Try[X] => Boolean): TableParser[Table[X]]

Set the value of predicate for the plaintext TableParser.

Set the value of predicate for the plaintext TableParser.

Value parameters

p

predicate for the plaintext TableParser.

Attributes

Returns

a TableParser of Table[X]

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

Set the predicate for the plaintext TableParser.

Set the predicate for the plaintext TableParser.

Value parameters

predicate

a predicate which will be applied to each X (i.e. AFTER decryption).

Attributes

Returns

a TableParser of Table[X]

Set the value of the row parser for the plaintext TableParser.

Set the value of the row parser for the plaintext TableParser.

Value parameters

rp

the row parser for the plaintext TableParser.

Attributes

Returns

a TableParser of Table[X]

Inherited methods

def doParseRows(ts: Iterator[Input], header: Header, f: ((Input, Int)) => Try[Row])(using ev: Joinable[Input]): Try[Table[X]]

Parses rows of input data into a table representation.

Parses rows of input data into a table representation.

This method utilizes an IndexedInputToRowsAggregator to transform an iterator of inputs into rows using the provided header and transformation function. It processes the input, materializes the resulting rows into a list, and constructs a table representation from the processed rows and header.

Value parameters

ev

an implicit evidence parameter ensuring the input type adheres to the Joinable type class, which defines how input elements can be combined or validated during processing.

f

a transformation function that maps the Header to a function capable of transforming a tuple of input and its index into a Try[Row]. This function encapsulates row processing logic and error handling for each input element.

header

the Header containing column metadata to guide the transformation process.

ts

an iterator of inputs to be parsed into rows.

Attributes

Returns

a Try containing a Table if the parsing is successful, or an error in case of failure.

Inherited from:
AbstractTableParser
def parseRows(ws: Iterator[String], header: Header): Try[Table[X]]

Parses rows from an iterator of input strings (ws) using the provided header and row parsing logic.

Parses rows from an iterator of input strings (ws) using the provided header and row parsing logic.

This method utilizes the doParseRows function to process each row in the input iterator, applying the provided rowParser.parse function to convert input strings into logical rows, while using the header to guide parsing and interpretation of the input.

Value parameters

header

the Header object that describes the expected structure of the table (e.g., column names).

ws

an iterator over the input strings, where each string represents a row in the table.

Attributes

Returns

a Try of the parsed Table object. On success, it contains the resulting table; on failure, it contains the parsing error.

Inherited from:
StringTableParser
def parseSelected(xs: Iterator[String], selection: RowSelection, n: Int = ...): Try[Table[X]]

Method to parse the input into a Table of the selected rows (see rows). As in parse, if this parser isn't forgiving, a row which can't be parsed makes the result a Failure.

Method to parse the input into a Table of the selected rows (see rows). As in parse, if this parser isn't forgiving, a row which can't be parsed makes the result a Failure.

Value parameters

n

the number of header lines (defaults to headerRowsToRead).

selection

the rows to select (RFC 7111: see CsvFragment).

xs

the lines of the input.

Attributes

Returns

a Try[Table].

Inherited from:
StringTableParser
def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
def rows(xs: Iterator[String], n: Int = ..., selection: RowSelection = ...): Try[(Header, Iterator[Try[Row]])]

Method to parse the input lazily, as a stream of rows rather than a Table (see, e.g., IOTable.stream). The header is read now (from the first n lines, unless this parser has a fixed header); each row is parsed only when it is pulled from the iterator. As in parse, the predicate selects the rows; and, if this parser is forgiving, a row which can't be parsed is logged and left out. Otherwise, it is a Failure in the iterator.

Method to parse the input lazily, as a stream of rows rather than a Table (see, e.g., IOTable.stream). The header is read now (from the first n lines, unless this parser has a fixed header); each row is parsed only when it is pulled from the iterator. As in parse, the predicate selects the rows; and, if this parser is forgiving, a row which can't be parsed is logged and left out. Otherwise, it is a Failure in the iterator.

The selection (of RFC 7111 rows: see CsvFragment) applies before the predicate, since its row numbers are those of the input.

Value parameters

n

the number of header lines (defaults to headerRowsToRead).

selection

the rows to select (by default, all of them).

xs

the lines of the input.

Attributes

Returns

a Try of the header and an Iterator of the rows (each a Try).

Inherited from:
StringTableParser

Inherited fields

protected val predicate: Try[Row] => Boolean

Predicate to filter rows. Defaults to including all rows.

Predicate to filter rows. Defaults to including all rows.

Attributes

Inherited from:
TableBuilder
val rowParser: RowParser[X, String]

Method to define a row parser.

Method to define a row parser.

Attributes

Returns

a RowParser[Row, Input].

Inherited from:
HeadedStringTableParser