CellParsers

com.phasmidsoftware.tableparser.core.parse.CellParsers
trait CellParsers

Trait to define the various parsers for reading case classes and their parameters from table rows.

NOTE: In each of these cellParser methods, the CellParser has a parse method which ignores the columns.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Concrete methods

def cellParser[P : CellParser, T](construct: P => T): CellParser[T]

Method to return a CellParser[T] based on a function to convert a P into a T

Method to return a CellParser[T] based on a function to convert a P into a T

Type parameters

P

the type of the intermediate type.

T

the underlying type of the result.

Value parameters

construct

a function P => T.

Attributes

Returns

a SingleCellParser which converts a String into the intermediate type P and thence into a T

inline def cellParser2Conditional[K, P, T](construct: (K, P) => T, parsers: Map[K, CellParser[P]])(using kp: CellParser[K], m: ProductOf[T], helper: ColumnHelper[T]): CellParser[T]

Method to return a CellParser[T] where T is a 2-ary Product and which is based on a function to convert a (K,P) into a T. This method differs from cellParser2 in that the parser of P (a CellParser[P]) is not found implicitly, but rather is looked up dynamically depending on the value of the first parameter (of type K).

Method to return a CellParser[T] where T is a 2-ary Product and which is based on a function to convert a (K,P) into a T. This method differs from cellParser2 in that the parser of P (a CellParser[P]) is not found implicitly, but rather is looked up dynamically depending on the value of the first parameter (of type K).

Type parameters

K

the type of the conditional lookup key, which is also the type of the first field of T. Typically, this will be a String, but it could also be an Int or something more exotic.

P

the type of the second field of the Product type T.

T

the underlying type of the result, a case class with two fields.

Value parameters

construct

a function (K,P) => T, usually the apply method of a case class.

helper

the ColumnHelper[T].

m

the Mirror of T, from which the field names come.

parsers

a Map[K, CellParser[P]] which determines which particular parser of P will be used. The key value looked up is the value of the first (K) field.

Attributes

Returns

a MultiCellParser which converts Strings from a Row into the field types K and P and thence into a T.

def cellParserOption[P : CellParser]: CellParser[Option[P]]

Method to return a CellParser[Option[P]].

Method to return a CellParser[Option[P]].

This class is used for optional types which are non-scalar, i.e., there are no implicitly defined parsers for the Option[P].

Type parameters

P

the underlying type of the result

Attributes

Returns

a SingleCellParser[Option[P]]

def cellParserRepetition[P : CellParser](start: Int = ...): CellParser[Seq[P]]

Method to return a CellParser[Seq[P]] from a potentially unlimited set of P objects. The counting of the elements starts at start (defaults to 1).

Method to return a CellParser[Seq[P]] from a potentially unlimited set of P objects. The counting of the elements starts at start (defaults to 1).

Type parameters

P

the underlying type of the result

Attributes

Returns

a MultiCellParser[Seq[P]

def cellParserSeq[P : CellParser]: CellParser[Seq[P]]

Method to return a CellParser[Seq[P]. This is used only by unit tests. CONSIDER eliminating this; only used in unit tests

Method to return a CellParser[Seq[P]. This is used only by unit tests. CONSIDER eliminating this; only used in unit tests

Type parameters

P

the underlying type of the result

Attributes

Returns

a MultiCellParser[Seq[P]

def columnHelper[T](maybePrefix: Option[String], aliases: (String, String)*): ColumnHelper[T]

Method to yield a ColumnHelper[T] based on an optional prefix, and some number of explicit aliases,

Method to yield a ColumnHelper[T] based on an optional prefix, and some number of explicit aliases,

Type parameters

T

the underlying type of the resulting ColumnHelper

Value parameters

aliases

a variable number of explicit aliases to translate specific case class parameter names into their column name equivalents.

maybePrefix

an optional prefix for the column name.

Attributes

Returns

a new instance of ColumnHelper[T]

def columnHelper[T](columnNameMapper: String => String, aliases: (String, String)*): ColumnHelper[T]

Method to yield a ColumnHelper[T] based on a column name mapper, and some number of explicit aliases,

Method to yield a ColumnHelper[T] based on a column name mapper, and some number of explicit aliases,

Type parameters

T

the underlying type of the resulting ColumnHelper

Value parameters

aliases

a variable number of explicit aliases to translate specific case class parameter names into their column name equivalents.

columnNameMapper

a mapper of String=>String which will translate case class parameter names into column names.

Attributes

Returns

a new instance of ColumnHelper[T]

def columnHelper[T](columnNameMapper: String => String, maybePrefix: Option[String], aliases: (String, String)*): ColumnHelper[T]

Method to yield a ColumnHelper[T] based on a column name mapper, an optional prefix, and some number of explicit aliases,

Method to yield a ColumnHelper[T] based on a column name mapper, an optional prefix, and some number of explicit aliases,

Type parameters

T

the underlying type of the resulting ColumnHelper

Value parameters

aliases

a variable number of explicit aliases to translate specific case class parameter names into their column name equivalents.

columnNameMapper

a mapper of String=>String which will translate case class parameter names into column names.

maybePrefix

an optional prefix for the column name.

Attributes

Returns

a new instance of ColumnHelper[T]

def columnHelper[T](aliases: (String, String)*): ColumnHelper[T]

Method to yield a ColumnHelper[T] based on some number of explicit aliases,

Method to yield a ColumnHelper[T] based on some number of explicit aliases,

Type parameters

T

the underlying type of the resulting ColumnHelper

Value parameters

aliases

a variable number of explicit aliases to translate specific case class parameter names into their column name equivalents.

Attributes

Returns

a new instance of ColumnHelper[T]

Method to return a CellParser[RawRow] from a Row.

Method to return a CellParser[RawRow] from a Row.

Attributes

Returns

a CellParser[RawRow]

Concrete fields

lazy val cellParserOptionNonEmptyString: CellParser[Option[String]]

Method to return a CellParser[Option[String].

Method to return a CellParser[Option[String].

TODO: why do we need this in addition to cellParserOption?

CONSIDER: using BlankException as above...

Attributes

Returns

a SingleCellParser[Option[String]