Top Description Inners Fields Constructors Methods
com.ibm.icu.util

public final Class BytesTrieBuilder

extends StringTrieBuilder
Class Inheritance
Imports
java.nio.ByteBuffer

Builder class for BytesTrie.

This class is not intended for public subclassing.

Author
Markus W. Scherer
ICU Status
Stable since ICU 4.8.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private byte[]
private int
private final byte[]
Inherited from com.ibm.icu.util.StringTrieBuilder:
strings

Constructor Summary

AccessConstructor and Description
public
BytesTrieBuilder()

Constructs an empty builder.

Method Summary

Modifier and TypeMethod and Description
public BytesTrieBuilder

Returns:

this
add
(byte[]
The array that contains the byte sequence, starting at index 0.
sequence
,
int
The length of the byte sequence.
length
,
int
The value associated with this byte sequence.
value
)

Adds a (byte sequence, value) pair.

public BytesTrie

Returns:

A new BytesTrie for the add()ed data.
build
(StringTrieBuilder.Option
Build option, see StringTrieBuilder.Option.
buildOption
)

Builds a BytesTrie for the add()ed data.

public ByteBuffer

Returns:

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

Builds a BytesTrie for the add()ed data and byte-serializes it.

private void
public BytesTrieBuilder

Returns:

this
clear
()

Removes all (byte sequence, value) pairs.

private void
ensureCapacity(int length)

protected int
getMaxBranchLinearSubNodeLength()

Implements abstract com.ibm.icu.util.StringTrieBuilder.getMaxBranchLinearSubNodeLength.

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

Implements abstract com.ibm.icu.util.StringTrieBuilder.getMaxLinearMatchLength.

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

Implements abstract com.ibm.icu.util.StringTrieBuilder.getMinLinearMatch.

Deprecated This API is ICU internal only.
public static final int
internalEncodeDelta(int i, byte[] intBytes)

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

Implements abstract com.ibm.icu.util.StringTrieBuilder.matchNodesCanHaveValues.

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

Implements abstract com.ibm.icu.util.StringTrieBuilder.write.

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

Implements abstract com.ibm.icu.util.StringTrieBuilder.write.

Deprecated This API is ICU internal only.
private int
write(byte[] b, int length)

protected int
writeDeltaTo(int jumpTarget)

Implements abstract com.ibm.icu.util.StringTrieBuilder.writeDeltaTo.

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

Implements abstract com.ibm.icu.util.StringTrieBuilder.writeValueAndFinal.

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

Implements abstract com.ibm.icu.util.StringTrieBuilder.writeValueAndType.

Deprecated This API is ICU internal only.
Inherited from com.ibm.icu.util.StringTrieBuilder:
addImplbuildImplclearImpl

Field Detail

bytesback to summary
private byte[] bytes
bytesLengthback to summary
private int bytesLength
intBytesback to summary
private final byte[] intBytes

Constructor Detail

BytesTrieBuilderback to summary
public BytesTrieBuilder()

Constructs an empty builder.

ICU Status
Stable since ICU 4.8.

Method Detail

addback to summary
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:byte[]

The array that contains the byte sequence, starting at index 0.

length:int

The length of the byte sequence.

value:int

The value associated with this byte sequence.

Returns:BytesTrieBuilder

this

ICU Status
Stable since ICU 4.8.
buildback to summary
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.

A BytesTrie cannot be empty. At least one (byte sequence, value) pair must have been add()ed.

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:StringTrieBuilder.Option

Build option, see StringTrieBuilder.Option.

Returns:BytesTrie

A new BytesTrie for the add()ed data.

ICU Status
Stable since ICU 4.8.
buildByteBufferback to summary
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.

A BytesTrie cannot be empty. At least one (byte sequence, value) pair must have been add()ed.

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:StringTrieBuilder.Option

Build option, see StringTrieBuilder.Option.

Returns:ByteBuffer

A ByteBuffer with the byte-serialized BytesTrie for the add()ed data. The buffer is not read-only and array() can be called.

ICU Status
Stable since ICU 4.8.
buildBytesback to summary
private void buildBytes(StringTrieBuilder.Option buildOption)
clearback to summary
public BytesTrieBuilder clear()

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

Returns:BytesTrieBuilder

this

ICU Status
Stable since ICU 4.8.
ensureCapacityback to summary
private void ensureCapacity(int length)
getMaxBranchLinearSubNodeLengthback to summary
protected int getMaxBranchLinearSubNodeLength()

Implements abstract com.ibm.icu.util.StringTrieBuilder.getMaxBranchLinearSubNodeLength.

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
@Override
ICU Status
Internal ICU component.
getMaxLinearMatchLengthback to summary
protected int getMaxLinearMatchLength()

Implements abstract com.ibm.icu.util.StringTrieBuilder.getMaxLinearMatchLength.

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
@Override
ICU Status
Internal ICU component.
getMinLinearMatchback to summary
protected int getMinLinearMatch()

Implements abstract com.ibm.icu.util.StringTrieBuilder.getMinLinearMatch.

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
@Override
ICU Status
Internal ICU component.
internalEncodeDeltaback to summary
public static final int internalEncodeDelta(int i, byte[] intBytes)

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
ICU Status
Internal ICU component.
matchNodesCanHaveValuesback to summary
protected boolean matchNodesCanHaveValues()

Implements abstract com.ibm.icu.util.StringTrieBuilder.matchNodesCanHaveValues.

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
@Override
ICU Status
Internal ICU component.
writeback to summary
protected int write(int b)

Implements abstract com.ibm.icu.util.StringTrieBuilder.write.

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
@Override
ICU Status
Internal ICU component.
writeback to summary
protected int write(int offset, int length)

Implements abstract com.ibm.icu.util.StringTrieBuilder.write.

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
@Override
ICU Status
Internal ICU component.
writeback to summary
private int write(byte[] b, int length)
writeDeltaToback to summary
protected int writeDeltaTo(int jumpTarget)

Implements abstract com.ibm.icu.util.StringTrieBuilder.writeDeltaTo.

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
@Override
ICU Status
Internal ICU component.
writeValueAndFinalback to summary
protected int writeValueAndFinal(int i, boolean isFinal)

Implements abstract com.ibm.icu.util.StringTrieBuilder.writeValueAndFinal.

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
@Override
ICU Status
Internal ICU component.
writeValueAndTypeback to summary
protected int writeValueAndType(boolean hasValue, int value, int node)

Implements abstract com.ibm.icu.util.StringTrieBuilder.writeValueAndType.

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
@Override
ICU Status
Internal ICU component.
com.ibm.icu.util back to summary

private final Class BytesTrieBuilder.BytesAsCharSequence

extends Object
implements CharSequence
Class Inheritance
All Implemented Interfaces
java.lang.CharSequence

Field Summary

Modifier and TypeField and Description
private int
private byte[]
s

Constructor Summary

AccessConstructor and Description
public
BytesAsCharSequence(byte[] sequence, int length)

Method Summary

Modifier and TypeMethod and Description
public char
charAt(int
the index of the char value to be returned
i
)

Implements java.lang.CharSequence.charAt.

Returns the char value at the specified index.
public int
length()

Implements java.lang.CharSequence.length.

Returns the length of this character sequence.
public CharSequence
subSequence(int
the start index, inclusive
start
,
int
the end index, exclusive
end
)

Implements java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lenback to summary
private int len
sback to summary
private byte[] s

Constructor Detail

BytesAsCharSequenceback to summary
public BytesAsCharSequence(byte[] sequence, int length)

Method Detail

charAtback to summary
public char charAt(int i)

Implements java.lang.CharSequence.charAt.

Doc from java.lang.CharSequence.charAt.

Returns the char value at the specified index. An index ranges from zero to length() - 1. The first char value of the sequence is at index zero, the next at index one, and so on, as for array indexing.

If the char value specified by the index is a surrogate, the surrogate value is returned.

Parameters
i:int

the index of the char value to be returned

Returns:char

the specified char value

Annotations
@Override
lengthback to summary
public int length()

Implements java.lang.CharSequence.length.

Doc from java.lang.CharSequence.length.

Returns the length of this character sequence. The length is the number of 16-bit chars in the sequence.

Returns:int

the number of chars in this sequence

Annotations
@Override
subSequenceback to summary
public CharSequence subSequence(int start, int end)

Implements java.lang.CharSequence.subSequence.

Doc from java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence. The subsequence starts with the char value at the specified index and ends with the char value at index end - 1. The length (in chars) of the returned sequence is end - start, so if start == end then an empty sequence is returned.

Parameters
start:int

the start index, inclusive

end:int

the end index, exclusive

Returns:CharSequence

the specified subsequence

Annotations
@Override