Packages

object StringParser

Parsing methods from String to various simple types.

Contains parsers for common types, like numbers, dates and times.

Additional parsers may be provided by implementing StringParser or FormattedStringParser traits and putting implicit values in scope. StringParser may be implemented if there are no different formatting options for given type, e.g. for integers (although one may argue if this is a good example). For all cases when different formatting options exist, FormattedStringParser should be implemented.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. StringParser
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. class Pattern[A] extends AnyRef

    Intermediary to delegate parsing to in order to infer type of formatter used by parser.

    Intermediary to delegate parsing to in order to infer type of formatter used by parser.

    When adding parsing function to an entity, instead of providing

    def parse[A, B](input: A, format: B)(implicit parser: FormattedStringParser[A, B]): ParseResult[A]

    which requires then to use it as

    entity.parse[Double, NumberFormat]("123,45", numberFormat)

    one can provide function to get this Pattern

    def parse[A]: Pattern[A]

    and use it with nicer syntax

    entity.parse[Double]("123,45", numberFormat)
    A

    target type for parsing

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. implicit val bigDecimalParser: FormattedStringParser[BigDecimal, DecimalFormat]

    Parser for decimal values with support for formats.

  6. implicit val booleanParser: FormattedStringParser[Boolean, BooleanFormatter]

    Parser for boolean values with support for formats.

  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  8. implicit val doubleParser: FormattedStringParser[Double, DecimalFormat]

    Parser for double values with support for formats.

  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  11. implicit def fmtOptionParser[A, B](implicit parser: FormattedStringParser[A, B]): FormattedStringParser[Option[A], B]

    Parser for optional values with support for different formats.

    Parser for optional values with support for different formats. Allows conversion of any simple parser to return Option[A] instead of A, avoiding error for empty string.

    A

    the simple type wrapped by scala.Option

    B

    type of formatter

    parser

    the parser for underlying simple type

    returns

    parser which support formatted input and accepts empty one

  12. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. implicit val intParser: StringParser[Int]

    Parser for integer values.

  15. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  16. implicit val localDateParser: FormattedStringParser[LocalDate, DateTimeFormatter]

    Parser for date values with support for formats.

  17. implicit val localDateTimeParser: FormattedStringParser[LocalDateTime, DateTimeFormatter]

    Parser for date with time values with support for formats.

  18. implicit val localTimeParser: FormattedStringParser[LocalTime, DateTimeFormatter]

    Parser for time values with support for formats.

  19. implicit val longParser: FormattedStringParser[Long, NumberFormat]

    Parser for long values with support for formats.

  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  23. implicit def optionParser[A](implicit parser: StringParser[A]): StringParser[Option[A]]

    Parser for optional values.

    Parser for optional values. Allows conversion of any simple parser to return Option[A] instead of A, avoiding error for empty string.

    A

    the simple type wrapped by scala.Option

    parser

    the parser for underlying simple type

    returns

    parser which accepts empty input

  24. def parse[A]: Pattern[A]

    Parses string to desired type based on provided format.

    Parses string to desired type based on provided format.

    Delegates actual parsing to Pattern#apply method.

    A

    target type for parsing

    returns

    intermediary to retrieve value according to custom format

    See also

    parse for sample usage.

  25. def parse[A](str: String)(implicit parser: StringParser[A]): ParseResult[A]

    Safely parses string to desired type.

    Safely parses string to desired type.

    A

    target type for parsing

    str

    the input string

    parser

    the parser for specific target type

    returns

    either parsed value or an ParseError

    Example:
    1. import info.fingo.spata.text.StringParser._
      val x = parse[Double]("123.45").getOrElse(Double.NaN)
      val y = parse[Option[Double]]("123.45").map(_.getOrElse(0.0)).getOrElse(Double.NaN)
  26. implicit val stringParser: StringParser[String]

    No-op parser for strings.

  27. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  28. def toString(): String
    Definition Classes
    AnyRef → Any
  29. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  30. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  31. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped