Package eu.bandm.tools.lexic
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.
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 TypeMethodDescriptionint
getAsInt()
Returns the next code point if available.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.static CodePointSource
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 interfaceIntSupplier
- Returns:
- either a valid Unicode code point, or
-1
to indicate that the end of the stream has been reached - See Also:
-
read
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 fromhandler
- 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
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
-