com.ibm.icu.util
Class BytesTrieBuilder

java.lang.Object
  extended by com.ibm.icu.util.StringTrieBuilder
      extended by com.ibm.icu.util.BytesTrieBuilder

public final class BytesTrieBuilder
extends StringTrieBuilder

Builder class for BytesTrie.

This class is not intended for public subclassing.

Author:
Markus W. Scherer
Status:
Draft ICU 4.8.

Nested Class Summary
 
Nested classes/interfaces inherited from class com.ibm.icu.util.StringTrieBuilder
StringTrieBuilder.Option
 
Field Summary
 
Fields inherited from class com.ibm.icu.util.StringTrieBuilder
strings
 
Constructor Summary
BytesTrieBuilder()
          Constructs an empty builder.
 
Method Summary
 BytesTrieBuilder add(byte[] sequence, int length, int value)
          Adds a (byte sequence, value) pair.
 BytesTrie build(StringTrieBuilder.Option buildOption)
          Builds a BytesTrie for the add()ed data.
 ByteBuffer buildByteBuffer(StringTrieBuilder.Option buildOption)
          Builds a BytesTrie for the add()ed data and byte-serializes it.
 BytesTrieBuilder clear()
          Removes all (byte sequence, value) pairs.
protected  int getMaxBranchLinearSubNodeLength()
          Deprecated. This API is ICU internal only.
protected  int getMaxLinearMatchLength()
          Deprecated. This API is ICU internal only.
protected  int getMinLinearMatch()
          Deprecated. This API is ICU internal only.
protected  boolean matchNodesCanHaveValues()
          Deprecated. This API is ICU internal only.
protected  int write(int b)
          Deprecated. This API is ICU internal only.
protected  int write(int offset, int length)
          Deprecated. This API is ICU internal only.
protected  int writeDeltaTo(int jumpTarget)
          Deprecated. This API is ICU internal only.
protected  int writeValueAndFinal(int i, boolean isFinal)
          Deprecated. This API is ICU internal only.
protected  int writeValueAndType(boolean hasValue, int value, int node)
          Deprecated. This API is ICU internal only.
 
Methods inherited from class com.ibm.icu.util.StringTrieBuilder
addImpl, buildImpl, clearImpl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BytesTrieBuilder

public BytesTrieBuilder()
Constructs an empty builder.

Status:
Draft ICU 4.8.
Method Detail

add

public BytesTrieBuilder add(byte[] sequence,
                            int length,
                            int value)
Adds a (byte sequence, value) pair. The byte sequence must be unique. Bytes 0..length-1 will be copied; the builder does not keep a reference to the input array.

Parameters:
sequence - The array that contains the byte sequence, starting at index 0.
length - The length of the byte sequence.
value - The value associated with this byte sequence.
Returns:
this
Status:
Draft ICU 4.8.

build

public BytesTrie build(StringTrieBuilder.Option buildOption)
Builds a BytesTrie for the add()ed data. Once built, no further data can be add()ed until clear() is called.

Multiple calls to build() or buildByteBuffer() return tries or buffers which share the builder's byte array, without rebuilding. The byte array must not be modified via the buildByteBuffer() result object. After clear() has been called, a new array will be used.

Parameters:
buildOption - Build option, see StringTrieBuilder.Option.
Returns:
A new BytesTrie for the add()ed data.
Status:
Draft ICU 4.8.

buildByteBuffer

public ByteBuffer buildByteBuffer(StringTrieBuilder.Option buildOption)
Builds a BytesTrie for the add()ed data and byte-serializes it. Once built, no further data can be add()ed until clear() is called.

Multiple calls to build() or buildByteBuffer() return tries or buffers which share the builder's byte array, without rebuilding. Do not modify the bytes in the buffer! After clear() has been called, a new array will be used.

The serialized BytesTrie is accessible via the buffer's array()/arrayOffset()+position() or remaining()/get(byte[]) etc.

Parameters:
buildOption - Build option, see StringTrieBuilder.Option.
Returns:
A ByteBuffer with the byte-serialized BytesTrie for the add()ed data. The buffer is not read-only and array() can be called.
Status:
Draft ICU 4.8.

clear

public BytesTrieBuilder clear()
Removes all (byte sequence, value) pairs. New data can then be add()ed and a new trie can be built.

Returns:
this
Status:
Draft ICU 4.8.

matchNodesCanHaveValues

protected boolean matchNodesCanHaveValues()
Deprecated. This API is ICU internal only.

Specified by:
matchNodesCanHaveValues in class StringTrieBuilder
Status:
Internal. This API is ICU internal only.

getMaxBranchLinearSubNodeLength

protected int getMaxBranchLinearSubNodeLength()
Deprecated. This API is ICU internal only.

Specified by:
getMaxBranchLinearSubNodeLength in class StringTrieBuilder
Status:
Internal. This API is ICU internal only.

getMinLinearMatch

protected int getMinLinearMatch()
Deprecated. This API is ICU internal only.

Specified by:
getMinLinearMatch in class StringTrieBuilder
Status:
Internal. This API is ICU internal only.

getMaxLinearMatchLength

protected int getMaxLinearMatchLength()
Deprecated. This API is ICU internal only.

Specified by:
getMaxLinearMatchLength in class StringTrieBuilder
Status:
Internal. This API is ICU internal only.

write

protected int write(int b)
Deprecated. This API is ICU internal only.

Specified by:
write in class StringTrieBuilder
Status:
Internal. This API is ICU internal only.

write

protected int write(int offset,
                    int length)
Deprecated. This API is ICU internal only.

Specified by:
write in class StringTrieBuilder
Status:
Internal. This API is ICU internal only.

writeValueAndFinal

protected int writeValueAndFinal(int i,
                                 boolean isFinal)
Deprecated. This API is ICU internal only.

Specified by:
writeValueAndFinal in class StringTrieBuilder
Status:
Internal. This API is ICU internal only.

writeValueAndType

protected int writeValueAndType(boolean hasValue,
                                int value,
                                int node)
Deprecated. This API is ICU internal only.

Specified by:
writeValueAndType in class StringTrieBuilder
Status:
Internal. This API is ICU internal only.

writeDeltaTo

protected int writeDeltaTo(int jumpTarget)
Deprecated. This API is ICU internal only.

Specified by:
writeDeltaTo in class StringTrieBuilder
Status:
Internal. This API is ICU internal only.


Copyright (c) 2011 IBM Corporation and others.