/*
*******************************************************************************
-* Copyright (C) 2011, International Business Machines
+* Copyright (C) 2011-2012, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
* created on: 2011jan06
*
* <p>This class is not intended for public subclassing.
*
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
* @author Markus W. Scherer
*/
public final class CharsTrie implements Cloneable, Iterable<CharsTrie.Entry> {
*
* @param trieChars CharSequence that contains the serialized trie.
* @param offset Root offset of the trie in the CharSequence.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public CharsTrie(CharSequence trieChars, int offset) {
chars_=trieChars;
* Clones this trie reader object and its state,
* but not the char array which will be shared.
* @return A shallow clone of this trie.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
@Override
public Object clone() throws CloneNotSupportedException {
/**
* Resets this trie to its initial state.
* @return this
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public CharsTrie reset() {
pos_=root_;
/**
* CharsTrie state object, for saving a trie's current state
* and resetting the trie back to this state later.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public static final class State {
/**
* Constructs an empty State.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public State() {}
private CharSequence chars;
* @param state The State object to hold the trie's state.
* @return this
* @see #resetToState
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public CharsTrie saveState(State state) /*const*/ {
state.chars=chars_;
* or the state of a different trie
* @see #saveState
* @see #reset
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public CharsTrie resetToState(State state) {
if(chars_==state.chars && chars_!=null && root_==state.root) {
* Determines whether the string so far matches, whether it has a value,
* and whether another input char can continue a matching string.
* @return The match/value Result.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public Result current() /*const*/ {
int pos=pos_;
* Equivalent to reset().next(inUnit).
* @param inUnit Input char value. Values below 0 and above 0xffff will never match.
* @return The match/value Result.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public Result first(int inUnit) {
remainingMatchLength_=-1;
* Equivalent to reset().nextForCodePoint(cp).
* @param cp A Unicode code point 0..0x10ffff.
* @return The match/value Result.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public Result firstForCodePoint(int cp) {
return cp<=0xffff ?
* Traverses the trie from the current state for this input char.
* @param inUnit Input char value. Values below 0 and above 0xffff will never match.
* @return The match/value Result.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public Result next(int inUnit) {
int pos=pos_;
* one or two UTF-16 code units for this input code point.
* @param cp A Unicode code point 0..0x10ffff.
* @return The match/value Result.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public Result nextForCodePoint(int cp) {
return cp<=0xffff ?
* @param sIndex The start index of the string in s.
* @param sLimit The (exclusive) end index of the string in s.
* @return The match/value Result.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public Result next(CharSequence s, int sIndex, int sLimit) {
if(sIndex>=sLimit) {
*
* Do not call getValue() after Result.NO_MATCH or Result.NO_VALUE!
* @return The value for the string so far.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public int getValue() /*const*/ {
int pos=pos_;
* @return The unique value in bits 32..1 with bit 0 set,
* if all strings reachable from the current state
* map to the same value; otherwise returns 0.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public long getUniqueValue() /*const*/ {
int pos=pos_;
* @param out Each next char is appended to this object.
* (Only uses the out.append(c) method.)
* @return The number of chars which continue the string from here.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public int getNextChars(Appendable out) /*const*/ {
int pos=pos_;
/**
* Iterates from the current state of this trie.
* @return A new CharsTrie.Iterator.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public Iterator iterator() {
return new Iterator(chars_, pos_, remainingMatchLength_, 0);
* @param maxStringLength If 0, the iterator returns full strings.
* Otherwise, the iterator returns strings with this maximum length.
* @return A new CharsTrie.Iterator.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public Iterator iterator(int maxStringLength) {
return new Iterator(chars_, pos_, remainingMatchLength_, maxStringLength);
* @param maxStringLength If 0, the iterator returns full strings.
* Otherwise, the iterator returns strings with this maximum length.
* @return A new CharsTrie.Iterator.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public static Iterator iterator(CharSequence trieChars, int offset, int maxStringLength) {
return new Iterator(trieChars, offset, -1, maxStringLength);
/**
* Return value type for the Iterator.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public static final class Entry {
/**
* The string.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public CharSequence chars;
/**
* The value associated with the string.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public int value;
/**
* Iterator for all of the (string, value) pairs in a CharsTrie.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public static final class Iterator implements java.util.Iterator<Entry> {
private Iterator(CharSequence trieChars, int offset, int remainingMatchLength, int maxStringLength) {
/**
* Resets this iterator to its initial state.
* @return this
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public Iterator reset() {
pos_=initialPos_;
/**
* @return true if there are more elements.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public boolean hasNext() /*const*/ { return pos_>=0 || !stack_.isEmpty(); }
* a real value of -1.
* @return An Entry with the string and value of the next element.
* @throws NoSuchElementException - iteration has no more elements.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public Entry next() {
int pos=pos_;
/**
* Iterator.remove() is not supported.
* @throws UnsupportedOperationException (always)
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public void remove() {
throw new UnsupportedOperationException();