Class CaseMap.Title
- java.lang.Object
-
- com.ibm.icu.text.CaseMap
-
- com.ibm.icu.text.CaseMap.Title
-
- Enclosing class:
- CaseMap
public static final class CaseMap.Title extends CaseMap
Titlecasing options and methods. Immutable.- See Also:
CaseMap.toTitle()
-
-
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CaseMap.Title
adjustToCased()
Returns an instance that behaves like this one but adjusts each titlecasing BreakIterator index to the next cased character.java.lang.String
apply(java.util.Locale locale, BreakIterator iter, java.lang.CharSequence src)
Titlecases a string.<A extends java.lang.Appendable>
Aapply(java.util.Locale locale, BreakIterator iter, java.lang.CharSequence src, A dest, Edits edits)
Titlecases a string and optionally records edits (seeomitUnchangedText()
).CaseMap.Title
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.CaseMap.Title
noLowercase()
Returns an instance that behaves like this one but does not lowercase non-initial parts of words when titlecasing.CaseMap.Title
omitUnchangedText()
Returns an instance that behaves like this one but omits unchanged text when case-mapping withEdits
.CaseMap.Title
sentences()
Returns an instance that behaves like this one but titlecases sentences rather than words.CaseMap.Title
wholeString()
Returns an instance that behaves like this one but titlecases the string as a whole rather than each word.
-
-
-
Method Detail
-
wholeString
public CaseMap.Title 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:
adjustToCased()
-
sentences
public CaseMap.Title 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:
adjustToCased()
-
omitUnchangedText
public CaseMap.Title 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
public CaseMap.Title 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:
UCharacter.TITLECASE_NO_LOWERCASE
,adjustToCased()
-
noBreakAdjustment
public CaseMap.Title 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:
UCharacter.TITLECASE_NO_BREAK_ADJUSTMENT
-
adjustToCased
public CaseMap.Title 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:
noBreakAdjustment()
-
apply
public java.lang.String apply(java.util.Locale locale, BreakIterator iter, java.lang.CharSequence src)
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:
UCharacter.toUpperCase(Locale, String)
-
apply
public <A extends java.lang.Appendable> A apply(java.util.Locale locale, BreakIterator iter, java.lang.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:
UCharacter.toTitleCase(Locale, String, BreakIterator, int)
-
-