/**
* Returns a CharacterIterator over the text being analyzed.
- * For at least some subclasses of BreakIterator, this is a reference
- * to the <b>actual iterator being used</b> by the BreakIterator,
- * and therefore, this function's return value should be treated as
- * <tt>const</tt>. No guarantees are made about the current position
- * of this iterator when it is returned. If you need to move that
+ * <p>
+ * <b><i>Caution:</i></b>The state of the returned CharacterIterator
+ * must not be modified in any way while the BreakIterator is still in use.
+ * Doing so will lead to undefined behavior of the BreakIterator.
+ * Clone the returned CharacterIterator first and work with that.
+ * <p>
+ * The returned CharacterIterator is a reference
+ * to the <b>actual iterator being used</b> by the BreakIterator.
+ * No guarantees are made about the current position
+ * of this iterator when it is returned; it may differ from the
+ * BreakIterators current position. If you need to move that
* position to examine the text, clone this function's return value first.
+ *
* @return A CharacterIterator over the text being analyzed.
* @stable ICU 2.0
*/
* 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.)
+ * <p>
+ * The text underlying the CharSequence must not be be modified while
+ * the BreakIterator holds a references to it. (As could possibly occur
+ * with a StringBuilder, for example).
* @param newText A CharSequence containing the text to analyze with
* this BreakIterator.
* @draft ICU 60
}
/**
- * 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.
+ * Sets the iterator to analyze a new piece of text. This function resets
+ * the current iteration position to the beginning of the text.
* (The old iterator is dropped.)
+ * <p>
+ * <b><i>Caution:</i></b> The supplied CharacterIterator is used
+ * directly by the BreakIterator, and must not be altered in any
+ * way by code outside of the BreakIterator.
+ * Doing so will lead to undefined behavior of the BreakIterator.
+ *
* @param 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).
private RuleBasedBreakIterator() {
fDictionaryCharCount = 0;
synchronized(gAllBreakEngines) {
- fBreakEngines = new ArrayList<LanguageBreakEngine>(gAllBreakEngines);
+ fBreakEngines = new ArrayList<>(gAllBreakEngines);
}
}
result.fText = (CharacterIterator)(fText.clone());
}
synchronized (gAllBreakEngines) {
- result.fBreakEngines = new ArrayList<LanguageBreakEngine>(gAllBreakEngines);
+ result.fBreakEngines = new ArrayList<>(gAllBreakEngines);
}
result.fLookAheadMatches = new LookAheadResults();
result.fBreakCache = result.new BreakCache(fBreakCache);
static {
gUnhandledBreakEngine = new UnhandledBreakEngine();
- gAllBreakEngines = new ArrayList<LanguageBreakEngine>();
+ gAllBreakEngines = new ArrayList<>();
gAllBreakEngines.add(gUnhandledBreakEngine);
}
}
/**
- * Return a CharacterIterator over the text being analyzed. This version
- * of this method returns the actual CharacterIterator we're using internally.
- * Changing the state of this iterator can have undefined consequences. If
- * you need to change it, clone it first.
+ * Returns a CharacterIterator over the text being analyzed.
+ * <p>
+ * <b><i>Caution:</i></b>The state of the returned CharacterIterator
+ * must not be modified in any way while the BreakIterator is still in use.
+ * Doing so will lead to undefined behavior of the BreakIterator.
+ * Clone the returned CharacterIterator first and work with that.
+ * <p>
+ * The returned CharacterIterator is a reference
+ * to the <b>actual iterator being used</b> by the BreakIterator.
+ * No guarantees are made about the current position
+ * of this iterator when it is returned; it may differ from the
+ * BreakIterators current position. If you need to move that
+ * position to examine the text, clone this function's return value first.
* @return An iterator over the text being analyzed.
* @stable ICU 2.0
*/
/**
* Set the iterator to analyze a new piece of text. This function resets
* the current iteration position to the beginning of the text.
+ * (The old iterator is dropped.)
+ * <p>
+ * <b><i>Caution:</i></b> The supplied CharacterIterator is used
+ * directly by the BreakIterator, and must not be altered in any
+ * way by code outside of the BreakIterator.
+ * Doing so will lead to undefined behavior of the BreakIterator.
+ *
* @param newText An iterator over the text to analyze.
* @stable ICU 2.0
*/