Class CollationSpec
The text is hyphen-separated specifiers, read case-insensitively and reported lower-cased:
COLLATE 'EN-CI' is 'en-ci' to COLLATION, DESCRIBE and GET_DDL. A LOCALE may come
first and is any word that is not an option — 'xx', 'bogus' and 'fr_CA' all
parse, an unknown one comparing by the root rules. Without one the collation is the UTF8
pseudo-locale (spelled utf8 or bin as well), which compares code units. The options:
cs / ci case-sensitive (the default) or not as / ai accent-sensitive (the default) or not ps / pi punctuation-sensitive or not fl / fu lower- or upper-case first when two differ only in case upper / lower convert the case before comparing trim / ltrim / rtrim drop leading and/or trailing spaces before comparing
The refusals, all live-verified and all worded Invalid value '<spec>' for COLLATION.
Reason: ..., come in this order: an unknown option, the first in the text (Unknown option:
zz — and a locale anywhere but first is one); upper beside lower; and a
sensitivity option without a locale (Case sensitivity option not allowed for the UTF8
collation, then accent, punctuation and upper/lower preference). Repeating or contradicting a
sensitivity option is no refusal — the last one wins — while the trims add up. Empty specifiers
at the END are dropped, so '-' is the UTF8 collation and 'en-ci-' is
'en-ci'; one anywhere else is an unknown option, or no locale when it comes first.
A locale compares through the JDK's Collator, whose letter order, case tiers and accents
agree with the account's: a < A < b under 'en', ä after z under
'sv', 'é' = 'e' only under ai. Punctuation and spaces weigh differently in
the two rule sets, and live's case-insensitive level also folds full-width forms and the
non-breaking space, which the JDK's does not.
-
Method Summary
Modifier and TypeMethodDescriptionintOrders two strings.equalityKey(String value) The key two strings share exactly when these rules call them equal — what a grouping, a DISTINCT or a set operation buckets by.getText()The specification lower-cased, the spelling COLLATION reports.booleanWhether the comparison ignores case.static booleanWhethermessageis this class's refusal, which a caller swallowing ordinary failures must let through: it is worded as neither a compilation nor an execution error.likeOperand(String value) A LIKE operand, subject or pattern, as the match must see it: trimmed and case-converted as the rules say, and folded to lower case when they ignore case.static CollationSpecThe rulesspecnames, refusing a specification live refuses.booleanWhether LIKE and ILIKE can match under these rules: not when they ignore accents or punctuation.booleanWhether LIKE ANY and LIKE ALL can: only without a locale.
-
Method Details
-
parse
The rulesspecnames, refusing a specification live refuses.- Parameters:
spec- the specification as written, in any case- Returns:
- its rules
-
isRefusal
Whethermessageis this class's refusal, which a caller swallowing ordinary failures must let through: it is worded as neither a compilation nor an execution error.- Parameters:
message- a failure's message- Returns:
- whether it refuses a collation specification
-
getText
The specification lower-cased, the spelling COLLATION reports. -
isCaseInsensitive
public boolean isCaseInsensitive()Whether the comparison ignores case. -
supportsLike
public boolean supportsLike()Whether LIKE and ILIKE can match under these rules: not when they ignore accents or punctuation. -
supportsLikeAnyAll
public boolean supportsLikeAnyAll()Whether LIKE ANY and LIKE ALL can: only without a locale. -
compare
Orders two strings.- Parameters:
left- the first stringright- the second- Returns:
- negative, zero or positive, as
leftsorts before, with or afterright
-
equalityKey
The key two strings share exactly when these rules call them equal — what a grouping, a DISTINCT or a set operation buckets by. Derived from the same conversionscompare(java.lang.String, java.lang.String)applies, so two values land in one bucket precisely when comparing them returns zero.- Parameters:
value- the string- Returns:
- an object equal to another string's key exactly when the two compare equal
-
likeOperand
A LIKE operand, subject or pattern, as the match must see it: trimmed and case-converted as the rules say, and folded to lower case when they ignore case.- Parameters:
value- the operand's text- Returns:
- the text to match
-