/*
*******************************************************************************
-* Copyright (C) 2010-2011, International Business Machines
+* Copyright (C) 2010-2012, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
* created on: 2010nov23
*
* <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 BytesTrie implements Cloneable, Iterable<BytesTrie.Entry> {
*
* @param trieBytes Bytes array that contains the serialized trie.
* @param offset Root offset of the trie in the array.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public BytesTrie(byte[] trieBytes, int offset) {
bytes_=trieBytes;
* Clones this trie reader object and its state,
* but not the byte 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 BytesTrie reset() {
pos_=root_;
/**
* BytesTrie 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 byte[] bytes;
* @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 BytesTrie saveState(State state) /*const*/ {
state.bytes=bytes_;
* 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 BytesTrie resetToState(State state) {
if(bytes_==state.bytes && bytes_!=null && root_==state.root) {
/**
* Return values for BytesTrie.next(), CharsTrie.next() and similar methods.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public enum Result {
/**
* Once current()/next() return NO_MATCH,
* all further calls to current()/next() will also return NO_MATCH,
* until the trie is reset to its original state or to a saved state.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
NO_MATCH,
/**
* The input unit(s) continued a matching string
* but there is no value for the string so far.
* (It is a prefix of a longer string.)
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
NO_VALUE,
/**
* and there is a value for the string so far.
* This value will be returned by getValue().
* No further input byte/unit can continue a matching string.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
FINAL_VALUE,
/**
* and there is a value for the string so far.
* This value will be returned by getValue().
* Another input byte/unit can continue a matching string.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
INTERMEDIATE_VALUE;
/**
* Same as (result!=NO_MATCH).
* @return true if the input bytes/units so far are part of a matching string/byte sequence.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public boolean matches() { return this!=NO_MATCH; }
* Equivalent to (result==INTERMEDIATE_VALUE || result==FINAL_VALUE).
* @return true if there is a value for the input bytes/units so far.
* @see #getValue
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public boolean hasValue() { return ordinal()>=2; }
/**
* Equivalent to (result==NO_VALUE || result==INTERMEDIATE_VALUE).
* @return true if another input byte/unit can continue a matching string.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public boolean hasNext() { return (ordinal()&1)!=0; }
}
* Determines whether the byte sequence so far matches, whether it has a value,
* and whether another input byte can continue a matching byte sequence.
* @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_;
* @param inByte Input byte value. Values -0x100..-1 are treated like 0..0xff.
* Values below -0x100 and above 0xff 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 inByte) {
remainingMatchLength_=-1;
* @param inByte Input byte value. Values -0x100..-1 are treated like 0..0xff.
* Values below -0x100 and above 0xff 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 inByte) {
int pos=pos_;
* @param sIndex The start index of the byte sequence in s.
* @param sLimit The (exclusive) end index of the byte sequence 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(byte[] 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 byte sequence 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 byte sequences 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 byte is 0-extended to a char and appended to this object.
* (Only uses the out.append(c) method.)
* @return The number of bytes which continue the byte sequence from here.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public int getNextBytes(Appendable out) /*const*/ {
int pos=pos_;
/**
* Iterates from the current state of this trie.
* @return A new BytesTrie.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(bytes_, pos_, remainingMatchLength_, 0);
* @param maxStringLength If 0, the iterator returns full strings/byte sequences.
* Otherwise, the iterator returns strings with this maximum length.
* @return A new BytesTrie.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(bytes_, pos_, remainingMatchLength_, maxStringLength);
* @param maxStringLength If 0, the iterator returns full strings/byte sequences.
* Otherwise, the iterator returns strings with this maximum length.
* @return A new BytesTrie.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(byte[] trieBytes, int offset, int maxStringLength) {
return new Iterator(trieBytes, 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 {
private Entry(int capacity) {
/**
* @return The length of the byte sequence.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public int bytesLength() { return length; }
/**
* Returns a byte of the byte sequence.
* @param index An index into the byte sequence.
* @return The index-th byte sequence byte.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public byte byteAt(int index) { return bytes[index]; }
/**
* Copies the byte sequence into a byte array.
* @param dest Destination byte array.
* @param destOffset Starting offset to where in dest the byte sequence is copied.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public void copyBytesTo(byte[] dest, int destOffset) {
System.arraycopy(bytes, 0, dest, destOffset, length);
}
/**
* @return The byte sequence as a read-only ByteBuffer.
- * @draft ICU 4.8
- * @provisional This API might change or be removed in a future release.
+ * @stable ICU 4.8
*/
public ByteBuffer bytesAsByteBuffer() {
return ByteBuffer.wrap(bytes, 0, length).asReadOnlyBuffer();
/**
* The value associated with the byte sequence.
- * @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 (byte sequence, value) pairs in a BytesTrie.
- * @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(byte[] trieBytes, 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();