Top Description Fields Constructors Methods
org.apache.commons.collections4.trie.analyzer

public Class StringKeyAnalyzer

extends KeyAnalyzer<String>
Class Inheritance
Imports
org.apache.commons.collections4.trie.KeyAnalyzer

An KeyAnalyzer for Strings.
Since
4.0

Field Summary

Modifier and TypeField and Description
public static final StringKeyAnalyzer
INSTANCE

A singleton instance of StringKeyAnalyzer.

public static final int
LENGTH

The number of bits per Character.

private static final int
MSB

A bit mask where the first bit is 1 and the others are zero.

private static final long
Inherited from org.apache.commons.collections4.trie.KeyAnalyzer:
EQUAL_BIT_KEYNULL_BIT_KEYOUT_OF_BOUNDS_BIT_KEY

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
bitIndex(final String
the key to use
key
,
final int
the bit offset in the key
offsetInBits
,
final int
the maximum key length in bits to use
lengthInBits
,
final String
the other key to use
other
,
final int
the bit offset in the other key
otherOffsetInBits
,
final int
the maximum key length in bits for the other key
otherLengthInBits
)

Implements abstract org.apache.commons.collections4.trie.KeyAnalyzer.bitIndex.

Returns the n-th different bit between key and other.
public int
bitsPerElement()

Implements abstract org.apache.commons.collections4.trie.KeyAnalyzer.bitsPerElement.

Returns the number of bits per element in the key.
public boolean
isBitSet(final String
the key to check, may not be null
key
,
final int
the bit index to check
bitIndex
,
final int
the maximum key length in bits to check
lengthInBits
)

Implements abstract org.apache.commons.collections4.trie.KeyAnalyzer.isBitSet.

Returns whether or not a bit is set.
public boolean
isPrefix(final String
the prefix to check
prefix
,
final int
the bit offset in the key
offsetInBits
,
final int
the maximum key length in bits to use
lengthInBits
,
final String
the key to check
key
)

Implements abstract org.apache.commons.collections4.trie.KeyAnalyzer.isPrefix.

Determines whether or not the given prefix (from offset to length) is a prefix of the given key.
public int
lengthInBits(final String
the key
key
)

Implements abstract org.apache.commons.collections4.trie.KeyAnalyzer.lengthInBits.

Returns the length of the Key in bits.
private static int
mask(final int bit)

Returns a bit mask where the given bit is set.

Inherited from org.apache.commons.collections4.trie.KeyAnalyzer:
compare

Field Detail

INSTANCEback to summary
public static final StringKeyAnalyzer INSTANCE

A singleton instance of StringKeyAnalyzer.

LENGTHback to summary
public static final int LENGTH

The number of bits per Character.

MSBback to summary
private static final int MSB

A bit mask where the first bit is 1 and the others are zero.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.collections4.trie.KeyAnalyzer.serialVersionUID.

Constructor Detail

StringKeyAnalyzerback to summary
public StringKeyAnalyzer()

Method Detail

bitIndexback to summary
public int bitIndex(final String key, final int offsetInBits, final int lengthInBits, final String other, final int otherOffsetInBits, final int otherLengthInBits)

Implements abstract org.apache.commons.collections4.trie.KeyAnalyzer.bitIndex.

Doc from org.apache.commons.collections4.trie.KeyAnalyzer.bitIndex.

Returns the n-th different bit between key and other. This starts the comparison in key at 'offsetInBits' and goes for 'lengthInBits' bits, and compares to the other key starting at 'otherOffsetInBits' and going for 'otherLengthInBits' bits.

Parameters
key:String

the key to use

offsetInBits:int

the bit offset in the key

lengthInBits:int

the maximum key length in bits to use

other:String

the other key to use

otherOffsetInBits:int

the bit offset in the other key

otherLengthInBits:int

the maximum key length in bits for the other key

Returns:int

the bit index where the key and other first differ

Annotations
@Override
bitsPerElementback to summary
public int bitsPerElement()

Implements abstract org.apache.commons.collections4.trie.KeyAnalyzer.bitsPerElement.

Doc from org.apache.commons.collections4.trie.KeyAnalyzer.bitsPerElement.

Returns the number of bits per element in the key. This is only useful for variable-length keys, such as Strings.

Returns:int

the number of bits per element

Annotations
@Override
isBitSetback to summary
public boolean isBitSet(final String key, final int bitIndex, final int lengthInBits)

Implements abstract org.apache.commons.collections4.trie.KeyAnalyzer.isBitSet.

Doc from org.apache.commons.collections4.trie.KeyAnalyzer.isBitSet.

Returns whether or not a bit is set.

Parameters
key:String

the key to check, may not be null

bitIndex:int

the bit index to check

lengthInBits:int

the maximum key length in bits to check

Returns:boolean

true if the bit is set in the given key and bitIndex < lengthInBits, false otherwise.

Annotations
@Override
isPrefixback to summary
public boolean isPrefix(final String prefix, final int offsetInBits, final int lengthInBits, final String key)

Implements abstract org.apache.commons.collections4.trie.KeyAnalyzer.isPrefix.

Doc from org.apache.commons.collections4.trie.KeyAnalyzer.isPrefix.

Determines whether or not the given prefix (from offset to length) is a prefix of the given key.

Parameters
prefix:String

the prefix to check

offsetInBits:int

the bit offset in the key

lengthInBits:int

the maximum key length in bits to use

key:String

the key to check

Returns:boolean

true if this is a valid prefix for the given key

Annotations
@Override
lengthInBitsback to summary
public int lengthInBits(final String key)

Implements abstract org.apache.commons.collections4.trie.KeyAnalyzer.lengthInBits.

Doc from org.apache.commons.collections4.trie.KeyAnalyzer.lengthInBits.

Returns the length of the Key in bits.

Parameters
key:String

the key

Returns:int

the bit length of the key

Annotations
@Override
maskback to summary
private static int mask(final int bit)

Returns a bit mask where the given bit is set.