Class CaseMap.Title
- Enclosing class:
CaseMap
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.ibm.icu.text.CaseMap
CaseMap.Fold, CaseMap.Lower, CaseMap.Title, CaseMap.Upper
-
Field Summary
Fields inherited from class com.ibm.icu.text.CaseMap
internalOptions
-
Method Summary
Modifier and TypeMethodDescriptionReturns an instance that behaves like this one but adjusts each titlecasing BreakIterator index to the next cased character.apply
(Locale locale, BreakIterator iter, CharSequence src) Titlecases a string.<A extends Appendable>
Aapply
(Locale locale, BreakIterator iter, CharSequence src, A dest, Edits edits) Titlecases a string and optionally records edits (seeomitUnchangedText()
).Returns an instance that behaves like this one but does not adjust the titlecasing BreakIterator indexes; titlecases exactly the characters at breaks from the iterator.Returns an instance that behaves like this one but does not lowercase non-initial parts of words when titlecasing.Returns an instance that behaves like this one but omits unchanged text when case-mapping withEdits
.Returns an instance that behaves like this one but titlecases sentences rather than words.Returns an instance that behaves like this one but titlecases the string as a whole rather than each word.
-
Method Details
-
wholeString
Returns an instance that behaves like this one but titlecases the string as a whole rather than each word. (Titlecases only the character at index 0, possibly adjusted.)It is an error to specify multiple titlecasing iterator options together, including both an option and an explicit BreakIterator.
- Returns:
- an options object with this option.
- See Also:
-
sentences
Returns an instance that behaves like this one but titlecases sentences rather than words. (Titlecases only the first character of each sentence, possibly adjusted.)It is an error to specify multiple titlecasing iterator options together, including both an option and an explicit BreakIterator.
- Returns:
- an options object with this option.
- See Also:
-
omitUnchangedText
Returns an instance that behaves like this one but omits unchanged text when case-mapping withEdits
.- Specified by:
omitUnchangedText
in classCaseMap
- Returns:
- an options object with this option.
-
noLowercase
Returns an instance that behaves like this one but does not lowercase non-initial parts of words when titlecasing.By default, titlecasing will titlecase the character at each (possibly adjusted) BreakIterator index and lowercase all other characters up to the next iterator index. With this option, the other characters will not be modified.
- Returns:
- an options object with this option.
- See Also:
-
noBreakAdjustment
Returns an instance that behaves like this one but does not adjust the titlecasing BreakIterator indexes; titlecases exactly the characters at breaks from the iterator.By default, titlecasing will take each break iterator index, adjust it to the next relevant character (see
adjustToCased()
), and titlecase that one.Other characters are lowercased.
- Returns:
- an options object with this option.
- See Also:
-
adjustToCased
Returns an instance that behaves like this one but adjusts each titlecasing BreakIterator index to the next cased character. (See the Unicode Standard, chapter 3, Default Case Conversion, R3 toTitlecase(X).)This used to be the default index adjustment in ICU. Since ICU 60, the default index adjustment is to the next character that is a letter, number, symbol, or private use code point. (Uncased modifier letters are skipped.) The difference in behavior is small for word titlecasing, but the new adjustment is much better for whole-string and sentence titlecasing: It yields "49ers" and "«丰(abc)»" instead of "49Ers" and "«丰(Abc)»".
It is an error to specify multiple titlecasing adjustment options together.
- Returns:
- an options object with this option.
- See Also:
-
apply
Titlecases a string. Casing is locale-dependent and context-sensitive. The result may be longer or shorter than the original.Titlecasing uses a break iterator to find the first characters of words that are to be titlecased. It titlecases those characters and lowercases all others. (This can be modified with options bits.)
- Parameters:
locale
- The locale ID. Can be null forLocale.getDefault()
. (SeeULocale.toLocale()
.)iter
- A break iterator to find the first characters of words that are to be titlecased. It is set to the source string (setText()) and used one or more times for iteration (first() and next()). If null, then a word break iterator for the locale is used (or something equivalent).src
- The original string.- Returns:
- the result string.
- See Also:
-
apply
public <A extends Appendable> A apply(Locale locale, BreakIterator iter, CharSequence src, A dest, Edits edits) Titlecases a string and optionally records edits (seeomitUnchangedText()
). Casing is locale-dependent and context-sensitive. The result may be longer or shorter than the original.Titlecasing uses a break iterator to find the first characters of words that are to be titlecased. It titlecases those characters and lowercases all others. (This can be modified with options bits.)
- Parameters:
locale
- The locale ID. Can be null forLocale.getDefault()
. (SeeULocale.toLocale()
.)iter
- A break iterator to find the first characters of words that are to be titlecased. It is set to the source string (setText()) and used one or more times for iteration (first() and next()). If null, then a word break iterator for the locale is used (or something equivalent).src
- The original string.dest
- A buffer for the result string. Must not be null.edits
- Records edits for index mapping, working with styled text, and getting only changes (if any). This function calls edits.reset() first. edits can be null.- Returns:
- dest with the result string (or only changes) appended.
- See Also:
-