org.evolvis.tartools.rfc822.ContextlessMatcher Maven / Gradle / Ivy
Show all versions of rfc822 Show documentation
package org.evolvis.tartools.rfc822;
/*-
* Copyright © 2021 mirabilos ([email protected])
* Licensor: tarent solutions GmbH, Bonn
*
* Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission
* is granted to deal in this work without restriction, including un‐
* limited rights to use, publicly perform, distribute, sell, modify,
* merge, give away, or sublicence.
*
* This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
* the utmost extent permitted by applicable law, neither express nor
* implied; without malicious intent or gross negligence. In no event
* may a licensor, author or contributor be held liable for indirect,
* direct, other damage, loss, or other issues arising in any way out
* of dealing in the work, even if advised of the possibility of such
* damage or existence of a defect, except proven that it results out
* of said person’s immediate fault when using the work as intended.
*/
import java.util.function.Function;
/**
* Context-less matcher callback for {@link Parser#skip(ContextlessMatcher)}.
*
* This is a functional interface for method references or lambdas.
* It contains one method {@link #toSkip(int)} that determines
* whether to abort or continue skipping, based on the characters in
* the input data.
*
* This interface is identical to {@code Function}
* except for the name of its functional method.
*
* @author mirabilos ([email protected])
* @see LookaheadMatcher
* @see Function
*/
@FunctionalInterface
public interface ContextlessMatcher {
/**
* Determines whether the current character is to be skipped.
*
* Skipping ahead is determined based on the codepoints in the file, that is,
* the input fully decoded to UCS (ISO 10646) codepoints, not just bytes or
* Java™-internal UTF-16 characters. If the end of input is reached, {@code -1}
* will be passed; otherwise, the 21-bit UCS codepoint of the respective wide
* (possibly multibyte, in the input) character.
*
* @param cur the codepoint of the current character
*
* @return {@code true} to continue skipping ahead, {@code false} to stop skipping
*/
boolean toSkip(final int cur);
}