Class CharPolicy
java.lang.Object
io.github.sergeloie.languagecheck.check.CharPolicy
Decides whether a Unicode code point is allowed in a checked file.
Three rule levels, evaluated for every code point:
- ASCII (U+0000..U+007F) is always allowed - code, whitespace and punctuation shared by every language.
- Formatting code points from the catalog (typography, box drawing,
agent emoji, LLM math symbols) are allowed for mapped files whose
extension is listed in
formattingExtensions, but never forASCII-onlyones. - Any code point inside one of the mapped languages' ranges is allowed.
Instances are immutable and cheap to share across every file that uses the same extension mapping.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanallows(int codePoint) True if the code point passes this policy.static CharPolicyStrict ASCII-only policy: no formatting characters, no language ranges.static CharPolicyforLanguages(List<Language> languages, LanguageCatalog catalog) Policy for a set of mapped languages: the union of their character ranges plus the catalog's shared formatting characters.static CharPolicyforLanguages(List<Language> languages, LanguageCatalog catalog, boolean formattingAllowed) Policy for a set of mapped languages with explicit control over the global formatting list.
-
Method Details
-
asciiOnly
Strict ASCII-only policy: no formatting characters, no language ranges. Used forasciiOnlyExtensionssuch as.java. -
forLanguages
Policy for a set of mapped languages: the union of their character ranges plus the catalog's shared formatting characters.An empty language list yields plain "ASCII + formatting" - the natural policy for an English-only mapped document.
-
forLanguages
public static CharPolicy forLanguages(List<Language> languages, LanguageCatalog catalog, boolean formattingAllowed) Policy for a set of mapped languages with explicit control over the global formatting list. WhenformattingAllowedisfalse(or the catalog isnull), only the languages' alphabets and ASCII pass - no typography, no agent emoji, no LLM math symbols. -
allows
public boolean allows(int codePoint) True if the code point passes this policy. Ranges are pre-merged and sorted, so lookup is binary-search (O(log n)).
-