Class BreakIterator
- java.lang.Object
-
- com.ibm.icu.text.BreakIterator
-
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
RuleBasedBreakIterator
public abstract class BreakIterator extends java.lang.Object implements java.lang.Cloneable
.A class that locates boundaries in text. This class defines a protocol for objects that break up a piece of natural-language text according to a set of criteria. Instances or subclasses of BreakIterator can be provided, for example, to break a piece of text into words, sentences, or logical characters according to the conventions of some language or group of languages. We provide five built-in types of BreakIterator:
- getTitleInstance() returns a BreakIterator that locates boundaries between title breaks.
- getSentenceInstance() returns a BreakIterator that locates boundaries between sentences. This is useful for triple-click selection, for example.
- getWordInstance() returns a BreakIterator that locates boundaries between words. This is useful for double-click selection or "find whole words" searches. This type of BreakIterator makes sure there is a boundary position at the beginning and end of each legal word. (Numbers count as words, too.) Whitespace and punctuation are kept separate from real words.
- getLineInstance() returns a BreakIterator that locates positions where it is legal for a text editor to wrap lines. This is similar to word breaking, but not the same: punctuation and whitespace are generally kept with words (you don't want a line to start with whitespace, for example), and some special characters can force a position to be considered a line-break position or prevent a position from being a line-break position.
- getCharacterInstance() returns a BreakIterator that locates boundaries between logical characters. Because of the structure of the Unicode encoding, a logical character may be stored internally as more than one Unicode code point. (A with an umlaut may be stored as an a followed by a separate combining umlaut character, for example, but the user still thinks of it as one character.) This iterator allows various processes (especially text editors) to treat as characters the units of text that a user would think of as characters, rather than the units of text that the computer sees as "characters".
BreakIterator's interface follows an "iterator" model (hence the name), meaning it has a concept of a "current position" and methods like first(), last(), next(), and previous() that update the current position. All BreakIterators uphold the following invariants:
- The beginning and end of the text are always treated as boundary positions.
- The current position of the iterator is always a boundary position (random- access methods move the iterator to the nearest boundary position before or after the specified position, not _to_ the specified position).
- DONE is used as a flag to indicate when iteration has stopped. DONE is only returned when the current position is the end of the text and the user calls next(), or when the current position is the beginning of the text and the user calls previous().
- Break positions are numbered by the positions of the characters that follow them. Thus, under normal circumstances, the position before the first character is 0, the position after the first character is 1, and the position after the last character is 1 plus the length of the string.
- The client can change the position of an iterator, or the text it analyzes, at will, but cannot change the behavior. If the user wants different behavior, he must instantiate a new iterator.
Examples:
Creating and using text boundaries
public static void main(String args[]) { if (args.length == 1) { String stringToExamine = args[0]; //print each word in order BreakIterator boundary = BreakIterator.getWordInstance(); boundary.setText(stringToExamine); printEachForward(boundary, stringToExamine); //print each sentence in reverse order boundary = BreakIterator.getSentenceInstance(Locale.US); boundary.setText(stringToExamine); printEachBackward(boundary, stringToExamine); printFirst(boundary, stringToExamine); printLast(boundary, stringToExamine); } }
public static void printEachForward(BreakIterator boundary, String source) { int start = boundary.first(); for (int end = boundary.next(); end != BreakIterator.DONE; start = end, end = boundary.next()) { System.out.println(source.substring(start,end)); } }
public static void printEachBackward(BreakIterator boundary, String source) { int end = boundary.last(); for (int start = boundary.previous(); start != BreakIterator.DONE; end = start, start = boundary.previous()) { System.out.println(source.substring(start,end)); } }
public static void printFirst(BreakIterator boundary, String source) { int start = boundary.first(); int end = boundary.next(); System.out.println(source.substring(start,end)); }
public static void printLast(BreakIterator boundary, String source) { int end = boundary.last(); int start = boundary.previous(); System.out.println(source.substring(start,end)); }
public static void printAt(BreakIterator boundary, int pos, String source) { int end = boundary.following(pos); int start = boundary.previous(); System.out.println(source.substring(start,end)); }
public static int nextWordStartAfter(int pos, String text) { BreakIterator wb = BreakIterator.getWordInstance(); wb.setText(text); int wordStart = wb.following(pos); for (;;) { int wordLimit = wb.next(); if (wordLimit == BreakIterator.DONE) { return BreakIterator.DONE; } int wordStatus = wb.getRuleStatus(); if (wordStatus != BreakIterator.WORD_NONE) { return wordStart; } wordStart = wordLimit; } }
The iterator returned bygetWordInstance()
is unique in that the break positions it returns don't represent both the start and end of the thing being iterated over. That is, a sentence-break iterator returns breaks that each represent the end of one sentence and the beginning of the next. With the word-break iterator, the characters between two boundaries might be a word, or they might be the punctuation or whitespace between two words. The above code usesgetRuleStatus()
to identify and ignore boundaries associated with punctuation or other non-word characters.- See Also:
CharacterIterator
-
-
Field Summary
Fields Modifier and Type Field Description static int
DONE
DONE is returned by previous() and next() after all valid boundaries have been returned.static int
KIND_CHARACTER
static int
KIND_LINE
static int
KIND_SENTENCE
static int
KIND_TITLE
static int
KIND_WORD
static int
WORD_IDEO
Tag value for words containing ideographic characters, lower limitstatic int
WORD_IDEO_LIMIT
Tag value for words containing ideographic characters, upper limitstatic int
WORD_KANA
Tag value for words containing kana characters, lower limitstatic int
WORD_KANA_LIMIT
Tag value for words containing kana characters, upper limitstatic int
WORD_LETTER
Tag value for words that contain letters, excluding hiragana, katakana or ideographic characters, lower limit.static int
WORD_LETTER_LIMIT
Tag value for words containing letters, upper limitstatic int
WORD_NONE
Tag value for "words" that do not fit into any of other categories.static int
WORD_NONE_LIMIT
Upper bound for tags for uncategorized words.static int
WORD_NUMBER
Tag value for words that appear to be numbers, lower limit.static int
WORD_NUMBER_LIMIT
Tag value for words that appear to be numbers, upper limit.
-
Constructor Summary
Constructors Modifier Constructor Description protected
BreakIterator()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.Object
clone()
Clone method.abstract int
current()
Return the iterator's current position.abstract int
first()
Set the iterator to the first boundary position.abstract int
following(int offset)
Sets the iterator's current iteration position to be the first boundary position following the specified position.static java.util.Locale[]
getAvailableLocales()
Returns a list of locales for which BreakIterators can be used.static ULocale[]
getAvailableULocales()
Returns a list of locales for which BreakIterators can be used.static BreakIterator
getBreakInstance(ULocale where, int kind)
Deprecated.This API is ICU internal only.static BreakIterator
getCharacterInstance()
Returns a new instance of BreakIterator that locates logical-character boundaries.static BreakIterator
getCharacterInstance(ULocale where)
Returns a new instance of BreakIterator that locates logical-character boundaries.static BreakIterator
getCharacterInstance(java.util.Locale where)
Returns a new instance of BreakIterator that locates logical-character boundaries.static BreakIterator
getLineInstance()
Returns a new instance of BreakIterator that locates legal line- wrapping positions.static BreakIterator
getLineInstance(ULocale where)
Returns a new instance of BreakIterator that locates legal line- wrapping positions.static BreakIterator
getLineInstance(java.util.Locale where)
Returns a new instance of BreakIterator that locates legal line- wrapping positions.ULocale
getLocale(ULocale.Type type)
Returns the locale that was used to create this object, or null.int
getRuleStatus()
For RuleBasedBreakIterators, return the status tag from the break rule that determined the boundary at the current iteration position.int
getRuleStatusVec(int[] fillInArray)
For RuleBasedBreakIterators, get the status (tag) values from the break rule(s) that determined the the boundary at the current iteration position.static BreakIterator
getSentenceInstance()
Returns a new instance of BreakIterator that locates sentence boundaries.static BreakIterator
getSentenceInstance(ULocale where)
Returns a new instance of BreakIterator that locates sentence boundaries.static BreakIterator
getSentenceInstance(java.util.Locale where)
Returns a new instance of BreakIterator that locates sentence boundaries.abstract java.text.CharacterIterator
getText()
Returns a CharacterIterator over the text being analyzed.static BreakIterator
getTitleInstance()
Returns a new instance of BreakIterator that locates title boundaries.static BreakIterator
getTitleInstance(ULocale where)
Returns a new instance of BreakIterator that locates title boundaries.static BreakIterator
getTitleInstance(java.util.Locale where)
Returns a new instance of BreakIterator that locates title boundaries.static BreakIterator
getWordInstance()
Returns a new instance of BreakIterator that locates word boundaries.static BreakIterator
getWordInstance(ULocale where)
Returns a new instance of BreakIterator that locates word boundaries.static BreakIterator
getWordInstance(java.util.Locale where)
Returns a new instance of BreakIterator that locates word boundaries.boolean
isBoundary(int offset)
Return true if the specified position is a boundary position.abstract int
last()
Set the iterator to the last boundary position.abstract int
next()
Advances the iterator forward one boundary.abstract int
next(int n)
Move the iterator by the specified number of steps in the text.int
preceding(int offset)
Sets the iterator's current iteration position to be the last boundary position preceding the specified position.abstract int
previous()
Move the iterator backward one boundary.static java.lang.Object
registerInstance(BreakIterator iter, ULocale locale, int kind)
Registers a new break iterator of the indicated kind, to use in the given locale.static java.lang.Object
registerInstance(BreakIterator iter, java.util.Locale locale, int kind)
Registers a new break iterator of the indicated kind, to use in the given locale.void
setText(java.lang.CharSequence newText)
Sets the iterator to analyze a new piece of text.void
setText(java.lang.String newText)
Sets the iterator to analyze a new piece of text.abstract void
setText(java.text.CharacterIterator newText)
Sets the iterator to analyze a new piece of text.static boolean
unregister(java.lang.Object key)
Unregisters a previously-registered BreakIterator using the key returned from the register call.
-
-
-
Field Detail
-
DONE
public static final int DONE
DONE is returned by previous() and next() after all valid boundaries have been returned.- See Also:
- Constant Field Values
-
WORD_NONE
public static final int WORD_NONE
Tag value for "words" that do not fit into any of other categories. Includes spaces and most punctuation.- See Also:
- Constant Field Values
-
WORD_NONE_LIMIT
public static final int WORD_NONE_LIMIT
Upper bound for tags for uncategorized words.- See Also:
- Constant Field Values
-
WORD_NUMBER
public static final int WORD_NUMBER
Tag value for words that appear to be numbers, lower limit.- See Also:
- Constant Field Values
-
WORD_NUMBER_LIMIT
public static final int WORD_NUMBER_LIMIT
Tag value for words that appear to be numbers, upper limit.- See Also:
- Constant Field Values
-
WORD_LETTER
public static final int WORD_LETTER
Tag value for words that contain letters, excluding hiragana, katakana or ideographic characters, lower limit.- See Also:
- Constant Field Values
-
WORD_LETTER_LIMIT
public static final int WORD_LETTER_LIMIT
Tag value for words containing letters, upper limit- See Also:
- Constant Field Values
-
WORD_KANA
public static final int WORD_KANA
Tag value for words containing kana characters, lower limit- See Also:
- Constant Field Values
-
WORD_KANA_LIMIT
public static final int WORD_KANA_LIMIT
Tag value for words containing kana characters, upper limit- See Also:
- Constant Field Values
-
WORD_IDEO
public static final int WORD_IDEO
Tag value for words containing ideographic characters, lower limit- See Also:
- Constant Field Values
-
WORD_IDEO_LIMIT
public static final int WORD_IDEO_LIMIT
Tag value for words containing ideographic characters, upper limit- See Also:
- Constant Field Values
-
KIND_CHARACTER
public static final int KIND_CHARACTER
- See Also:
- Constant Field Values
-
KIND_WORD
public static final int KIND_WORD
- See Also:
- Constant Field Values
-
KIND_LINE
public static final int KIND_LINE
- See Also:
- Constant Field Values
-
KIND_SENTENCE
public static final int KIND_SENTENCE
- See Also:
- Constant Field Values
-
KIND_TITLE
public static final int KIND_TITLE
- See Also:
- Constant Field Values
-
-
Method Detail
-
clone
public java.lang.Object clone()
Clone method. Creates another BreakIterator with the same behavior and current state as this one.- Overrides:
clone
in classjava.lang.Object
- Returns:
- The clone.
-
first
public abstract int first()
Set the iterator to the first boundary position. This is always the beginning index of the text this iterator iterates over. For example, if the iterator iterates over a whole string, this function will always return 0.- Returns:
- The character offset of the beginning of the stretch of text being broken.
-
last
public abstract int last()
Set the iterator to the last boundary position. This is always the "past-the-end" index of the text this iterator iterates over. For example, if the iterator iterates over a whole string (call it "text"), this function will always return text.length().- Returns:
- The character offset of the end of the stretch of text being broken.
-
next
public abstract int next(int n)
Move the iterator by the specified number of steps in the text. A positive number moves the iterator forward; a negative number moves the iterator backwards. If this causes the iterator to move off either end of the text, this function returns DONE; otherwise, this function returns the position of the appropriate boundary. Calling this function is equivalent to calling next() or previous() n times.- Parameters:
n
- The number of boundaries to advance over (if positive, moves forward; if negative, moves backwards).- Returns:
- The position of the boundary n boundaries from the current iteration position, or DONE if moving n boundaries causes the iterator to advance off either end of the text.
-
next
public abstract int next()
Advances the iterator forward one boundary. The current iteration position is updated to point to the next boundary position after the current position, and this is also the value that is returned. If the current position is equal to the value returned by last(), or to DONE, this function returns DONE and sets the current position to DONE.- Returns:
- The position of the first boundary position following the iteration position.
-
previous
public abstract int previous()
Move the iterator backward one boundary. The current iteration position is updated to point to the last boundary position before the current position, and this is also the value that is returned. If the current position is equal to the value returned by first(), or to DONE, this function returns DONE and sets the current position to DONE.- Returns:
- The position of the last boundary position preceding the iteration position.
-
following
public abstract int following(int offset)
Sets the iterator's current iteration position to be the first boundary position following the specified position. (Whether the specified position is itself a boundary position or not doesn't matter-- this function always moves the iteration position to the first boundary after the specified position.) If the specified position is the past-the-end position, returns DONE.- Parameters:
offset
- The character position to start searching from.- Returns:
- The position of the first boundary position following "offset" (whether or not "offset" itself is a boundary position), or DONE if "offset" is the past-the-end offset.
-
preceding
public int preceding(int offset)
Sets the iterator's current iteration position to be the last boundary position preceding the specified position. (Whether the specified position is itself a boundary position or not doesn't matter-- this function always moves the iteration position to the last boundary before the specified position.) If the specified position is the starting position, returns DONE.- Parameters:
offset
- The character position to start searching from.- Returns:
- The position of the last boundary position preceding "offset" (whether of not "offset" itself is a boundary position), or DONE if "offset" is the starting offset of the iterator.
-
isBoundary
public boolean isBoundary(int offset)
Return true if the specified position is a boundary position. If the function returns true, the current iteration position is set to the specified position; if the function returns false, the current iteration position is set as though following() had been called.- Parameters:
offset
- the offset to check.- Returns:
- True if "offset" is a boundary position.
-
current
public abstract int current()
Return the iterator's current position.- Returns:
- The iterator's current position.
-
getRuleStatus
public int getRuleStatus()
For RuleBasedBreakIterators, return the status tag from the break rule that determined the boundary at the current iteration position.For break iterator types that do not support a rule status, a default value of 0 is returned.
- Returns:
- The status from the break rule that determined the boundary at the current iteration position.
-
getRuleStatusVec
public int getRuleStatusVec(int[] fillInArray)
For RuleBasedBreakIterators, get the status (tag) values from the break rule(s) that determined the the boundary at the current iteration position.For break iterator types that do not support rule status, no values are returned.
If the size of the output array is insufficient to hold the data, the output will be truncated to the available length. No exception will be thrown.
- Parameters:
fillInArray
- an array to be filled in with the status values.- Returns:
- The number of rule status values from rules that determined the the boundary at the current iteration position. In the event that the array is too small, the return value is the total number of status values that were available, not the reduced number that were actually returned.
-
getText
public abstract java.text.CharacterIterator getText()
Returns a CharacterIterator over the text being analyzed. For at least some subclasses of BreakIterator, this is a reference to the actual iterator being used by the BreakIterator, and therefore, this function's return value should be treated as const. No guarantees are made about the current position of this iterator when it is returned. If you need to move that position to examine the text, clone this function's return value first.- Returns:
- A CharacterIterator over the text being analyzed.
-
setText
public void setText(java.lang.String newText)
Sets the iterator to analyze a new piece of text. The new piece of text is passed in as a String, and the current iteration position is reset to the beginning of the string. (The old text is dropped.)- Parameters:
newText
- A String containing the text to analyze with this BreakIterator.
-
setText
public void setText(java.lang.CharSequence newText)
Sets the iterator to analyze a new piece of text. The new piece of text is passed in as a CharSequence, and the current iteration position is reset to the beginning of the text. (The old text is dropped.)- Parameters:
newText
- A CharSequence containing the text to analyze with this BreakIterator.
-
setText
public abstract void setText(java.text.CharacterIterator newText)
Sets the iterator to analyze a new piece of text. The BreakIterator is passed a CharacterIterator through which it will access the text itself. The current iteration position is reset to the CharacterIterator's start index. (The old iterator is dropped.)- Parameters:
newText
- A CharacterIterator referring to the text to analyze with this BreakIterator (the iterator's current position is ignored, but its other state is significant).
-
getWordInstance
public static BreakIterator getWordInstance()
Returns a new instance of BreakIterator that locates word boundaries. This function assumes that the text being analyzed is in the default locale's language.- Returns:
- An instance of BreakIterator that locates word boundaries.
-
getWordInstance
public static BreakIterator getWordInstance(java.util.Locale where)
Returns a new instance of BreakIterator that locates word boundaries.- Parameters:
where
- A locale specifying the language of the text to be analyzed.- Returns:
- An instance of BreakIterator that locates word boundaries.
- Throws:
java.lang.NullPointerException
- ifwhere
is null.
-
getWordInstance
public static BreakIterator getWordInstance(ULocale where)
Returns a new instance of BreakIterator that locates word boundaries.- Parameters:
where
- A locale specifying the language of the text to be analyzed.- Returns:
- An instance of BreakIterator that locates word boundaries.
- Throws:
java.lang.NullPointerException
- ifwhere
is null.
-
getLineInstance
public static BreakIterator getLineInstance()
Returns a new instance of BreakIterator that locates legal line- wrapping positions. This function assumes the text being broken is in the default locale's language.- Returns:
- A new instance of BreakIterator that locates legal line-wrapping positions.
-
getLineInstance
public static BreakIterator getLineInstance(java.util.Locale where)
Returns a new instance of BreakIterator that locates legal line- wrapping positions.- Parameters:
where
- A Locale specifying the language of the text being broken.- Returns:
- A new instance of BreakIterator that locates legal line-wrapping positions.
- Throws:
java.lang.NullPointerException
- ifwhere
is null.
-
getLineInstance
public static BreakIterator getLineInstance(ULocale where)
Returns a new instance of BreakIterator that locates legal line- wrapping positions.- Parameters:
where
- A Locale specifying the language of the text being broken.- Returns:
- A new instance of BreakIterator that locates legal line-wrapping positions.
- Throws:
java.lang.NullPointerException
- ifwhere
is null.
-
getCharacterInstance
public static BreakIterator getCharacterInstance()
Returns a new instance of BreakIterator that locates logical-character boundaries. This function assumes that the text being analyzed is in the default locale's language.- Returns:
- A new instance of BreakIterator that locates logical-character boundaries.
-
getCharacterInstance
public static BreakIterator getCharacterInstance(java.util.Locale where)
Returns a new instance of BreakIterator that locates logical-character boundaries.- Parameters:
where
- A Locale specifying the language of the text being analyzed.- Returns:
- A new instance of BreakIterator that locates logical-character boundaries.
- Throws:
java.lang.NullPointerException
- ifwhere
is null.
-
getCharacterInstance
public static BreakIterator getCharacterInstance(ULocale where)
Returns a new instance of BreakIterator that locates logical-character boundaries.- Parameters:
where
- A Locale specifying the language of the text being analyzed.- Returns:
- A new instance of BreakIterator that locates logical-character boundaries.
- Throws:
java.lang.NullPointerException
- ifwhere
is null.
-
getSentenceInstance
public static BreakIterator getSentenceInstance()
Returns a new instance of BreakIterator that locates sentence boundaries. This function assumes the text being analyzed is in the default locale's language.- Returns:
- A new instance of BreakIterator that locates sentence boundaries.
-
getSentenceInstance
public static BreakIterator getSentenceInstance(java.util.Locale where)
Returns a new instance of BreakIterator that locates sentence boundaries.- Parameters:
where
- A Locale specifying the language of the text being analyzed.- Returns:
- A new instance of BreakIterator that locates sentence boundaries.
- Throws:
java.lang.NullPointerException
- ifwhere
is null.
-
getSentenceInstance
public static BreakIterator getSentenceInstance(ULocale where)
Returns a new instance of BreakIterator that locates sentence boundaries.- Parameters:
where
- A Locale specifying the language of the text being analyzed.- Returns:
- A new instance of BreakIterator that locates sentence boundaries.
- Throws:
java.lang.NullPointerException
- ifwhere
is null.
-
getTitleInstance
public static BreakIterator getTitleInstance()
Returns a new instance of BreakIterator that locates title boundaries. This function assumes the text being analyzed is in the default locale's language. The iterator returned locates title boundaries as described for Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration, please use a word boundary iterator.getWordInstance()
- Returns:
- A new instance of BreakIterator that locates title boundaries.
-
getTitleInstance
public static BreakIterator getTitleInstance(java.util.Locale where)
Returns a new instance of BreakIterator that locates title boundaries. The iterator returned locates title boundaries as described for Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration, please use Word Boundary iterator.getWordInstance()
- Parameters:
where
- A Locale specifying the language of the text being analyzed.- Returns:
- A new instance of BreakIterator that locates title boundaries.
- Throws:
java.lang.NullPointerException
- ifwhere
is null.
-
getTitleInstance
public static BreakIterator getTitleInstance(ULocale where)
Returns a new instance of BreakIterator that locates title boundaries. The iterator returned locates title boundaries as described for Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration, please use Word Boundary iterator.getWordInstance()
- Parameters:
where
- A Locale specifying the language of the text being analyzed.- Returns:
- A new instance of BreakIterator that locates title boundaries.
- Throws:
java.lang.NullPointerException
- ifwhere
is null.
-
registerInstance
public static java.lang.Object registerInstance(BreakIterator iter, java.util.Locale locale, int kind)
Registers a new break iterator of the indicated kind, to use in the given locale. Clones of the iterator will be returned if a request for a break iterator of the given kind matches or falls back to this locale.Because ICU may choose to cache BreakIterator objects internally, this must be called at application startup, prior to any calls to BreakIterator.getInstance to avoid undefined behavior.
- Parameters:
iter
- the BreakIterator instance to adopt.locale
- the Locale for which this instance is to be registeredkind
- the type of iterator for which this instance is to be registered- Returns:
- a registry key that can be used to unregister this instance
-
registerInstance
public static java.lang.Object registerInstance(BreakIterator iter, ULocale locale, int kind)
Registers a new break iterator of the indicated kind, to use in the given locale. Clones of the iterator will be returned if a request for a break iterator of the given kind matches or falls back to this locale.Because ICU may choose to cache BreakIterator objects internally, this must be called at application startup, prior to any calls to BreakIterator.getInstance to avoid undefined behavior.
- Parameters:
iter
- the BreakIterator instance to adopt.locale
- the Locale for which this instance is to be registeredkind
- the type of iterator for which this instance is to be registered- Returns:
- a registry key that can be used to unregister this instance
-
unregister
public static boolean unregister(java.lang.Object key)
Unregisters a previously-registered BreakIterator using the key returned from the register call. Key becomes invalid after this call and should not be used again.- Parameters:
key
- the registry key returned by a previous call to registerInstance- Returns:
- true if the iterator for the key was successfully unregistered
-
getBreakInstance
@Deprecated public static BreakIterator getBreakInstance(ULocale where, int kind)
Deprecated.This API is ICU internal only.Returns a particular kind of BreakIterator for a locale. Avoids writing a switch statement with getXYZInstance(where) calls.
-
getAvailableLocales
public static java.util.Locale[] getAvailableLocales()
Returns a list of locales for which BreakIterators can be used.- Returns:
- An array of Locales. All of the locales in the array can be used when creating a BreakIterator.
-
getAvailableULocales
public static ULocale[] getAvailableULocales()
Returns a list of locales for which BreakIterators can be used.- Returns:
- An array of Locales. All of the locales in the array can be used when creating a BreakIterator.
-
getLocale
public final ULocale getLocale(ULocale.Type type)
Returns the locale that was used to create this object, or null. This may may differ from the locale requested at the time of this object's creation. For example, if an object is created for locale en_US_CALIFORNIA, the actual data may be drawn from en (the actual locale), and en_US may be the most specific locale that exists (the valid locale).Note: The actual locale is returned correctly, but the valid locale is not, in most cases.
- Parameters:
type
- type of information requested, eitherULocale.VALID_LOCALE
orULocale.ACTUAL_LOCALE
.- Returns:
- the information specified by type, or null if this object was not constructed from locale data.
- See Also:
ULocale
,ULocale.VALID_LOCALE
,ULocale.ACTUAL_LOCALE
-
-