Interface TypeParser<T>

Type Parameters:
T - the object value type produced by parse(CharSequence, int, int)
All Superinterfaces:
Function<CharSequence,T>, SliceParser<T>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface TypeParser<T> extends SliceParser<T>
Parses textual values into a target typed value.

The primary operation is slice parsing. Whole-sequence parsing delegates to the slice method, so type parsers can be used anywhere a SliceParser is expected without creating intermediate strings.

  • Method Summary

    Modifier and Type
    Method
    Description
    default T
    Parses a whole character sequence into an object value.
    parse(CharSequence s, int offset, int length)
    Parses a slice of a character sequence into an object value.
    default boolean
    Parses a whole character sequence into a boolean value.
    default boolean
    parseBoolean(CharSequence s, int offset, int length)
    Parses a slice of a character sequence into a boolean value.
    default byte
    Parses a whole character sequence into a byte value.
    default byte
    parseByte(CharSequence s, int offset, int length)
    Parses a slice of a character sequence into a byte value.
    default double
    Parses a whole character sequence into a double value.
    default double
    parseDouble(CharSequence s, int offset, int length)
    Parses a slice of a character sequence into a double value.
    default int
    Parses a whole character sequence into an int value.
    default int
    parseInt(CharSequence s, int offset, int length)
    Parses a slice of a character sequence into an int value.
    default long
    Parses a whole character sequence into a long value.
    default long
    parseLong(CharSequence s, int offset, int length)
    Parses a slice of a character sequence into a long value.

    Methods inherited from interface java.util.function.Function

    andThen, compose

    Methods inherited from interface app.babylon.text.SliceParser

    apply
  • Method Details

    • parse

      T parse(CharSequence s, int offset, int length)
      Parses a slice of a character sequence into an object value.
      Specified by:
      parse in interface SliceParser<T>
      Parameters:
      s - the source text
      offset - the start index
      length - the slice length
      Returns:
      the parsed value, or null when parsing fails
    • parse

      default T parse(CharSequence s)
      Parses a whole character sequence into an object value.
      Specified by:
      parse in interface SliceParser<T>
      Parameters:
      s - the source text
      Returns:
      the parsed value, or null when parsing fails
    • parseByte

      default byte parseByte(CharSequence s)
      Parses a whole character sequence into a byte value.
      Parameters:
      s - the source text
      Returns:
      the parsed byte
    • parseByte

      default byte parseByte(CharSequence s, int offset, int length)
      Parses a slice of a character sequence into a byte value.
      Parameters:
      s - the source characters
      offset - the start index
      length - the slice length
      Returns:
      the parsed byte
    • parseBoolean

      default boolean parseBoolean(CharSequence s)
      Parses a whole character sequence into a boolean value.
      Parameters:
      s - the source text
      Returns:
      the parsed boolean
    • parseBoolean

      default boolean parseBoolean(CharSequence s, int offset, int length)
      Parses a slice of a character sequence into a boolean value.
      Parameters:
      s - the source text
      offset - the start index
      length - the slice length
      Returns:
      the parsed boolean
    • parseInt

      default int parseInt(CharSequence s)
      Parses a whole character sequence into an int value.
      Parameters:
      s - the source text
      Returns:
      the parsed int
    • parseInt

      default int parseInt(CharSequence s, int offset, int length)
      Parses a slice of a character sequence into an int value.
      Parameters:
      s - the source text
      offset - the start index
      length - the slice length
      Returns:
      the parsed int
    • parseLong

      default long parseLong(CharSequence s)
      Parses a whole character sequence into a long value.
      Parameters:
      s - the source text
      Returns:
      the parsed long
    • parseLong

      default long parseLong(CharSequence s, int offset, int length)
      Parses a slice of a character sequence into a long value.
      Parameters:
      s - the source text
      offset - the start index
      length - the slice length
      Returns:
      the parsed long
    • parseDouble

      default double parseDouble(CharSequence s)
      Parses a whole character sequence into a double value.
      Parameters:
      s - the source text
      Returns:
      the parsed double
    • parseDouble

      default double parseDouble(CharSequence s, int offset, int length)
      Parses a slice of a character sequence into a double value.
      Parameters:
      s - the source text
      offset - the start index
      length - the slice length
      Returns:
      the parsed double