Interface CodePointSource

All Superinterfaces:
IntSupplier
All Known Implementing Classes:
LocationCodePointSource
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 CodePointSource extends IntSupplier
A specialized supplier of unicode code points.

For objects that implement this interface, the method getAsInt() is expected to return only valid Unicode code points or -1. Exceptions must be documented explicitly.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the next code point if available.
    read(Reader reader, Consumer<? super IOException> handler)
    Returns a supplier that produces the code points corresponding to the UTF-8 characters available from a given reader.
    read(String text)
    Returns a supplier that produces the code points of a given string.
  • Method Details

    • getAsInt

      int getAsInt()
      Returns the next code point if available.
      Specified by:
      getAsInt in interface IntSupplier
      Returns:
      either a valid Unicode code point, or -1 to indicate that the end of the stream has been reached
      See Also:
    • read

      static CodePointSource read(Reader reader, Consumer<? super IOException> handler)
      Returns a supplier that produces the code points corresponding to the UTF-8 characters available from a given reader.

      A stream of code points can be obtained by repeated calls to the method getAsInt(). If the stream is not yet exhausted, then the return value is a valid Unicode code points. The end of the stream is signalled by a special return value of -1. Further calls then also return -1 indefinitely.

      I/O exceptions are caught and signaled by calling back to the given handler. Catching an I/O exception terminates the stream of code points, regardless whether and how the exception is handled.

      Parameters:
      reader - the reader to pull characters from
      handler - the handler for caught I/O exceptions
      Returns:
      a supplier that produces the code points corresponding to the UTF-8 characters available from a given reader
      See Also:
    • read

      static CodePointSource read(String text)
      Returns a supplier that produces the code points of a given string.
      Parameters:
      text - the string to convert to code points
      Returns:
      a supplier that produces the code points of a given string, and signals no exceptions