StringParser

info.fingo.spata.text.StringParser
See theStringParser companion object
trait StringParser[+A]

Parser from String to desired type.

This parser defines behavior to be implemented by concrete, given parser instances for various types, used by [[StringParser.parseA* parse]] function from StringParser object.

Parsing fails on an empty input if a simple type is provided. To accept empty input Option[?] should be provided as type parameter.

Type parameters

A

target type for parsing

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait FormattedStringParser[A, B]
object bigDecimalParserFmt.type
object booleanParserFmt.type
object doubleParserFmt.type
object localDateParserFmt.type
object localTimeParserFmt.type
object longParserFmt.type
object intParser.type
object stringParser.type
Show all

Members list

Value members

Abstract methods

def apply(str: String): A

Parses string to desired type.

Parses string to desired type.

If parsing fails this function should report error by throwing exception. This is further handled by parse to allow for exception-free, functional code.

Value parameters

str

the input string

Attributes

Returns

parsed value

Throws
RuntimeException

if text cannot be parsed to requested type

Note

This function assumes "standard" string formatting, e.g. point as decimal separator or ISO date and time formats, without any locale support. Use FormattedStringParser if more control over source format is required.