public class StringDecoderCache extends AbstractStringCache
This class is thread safe. Thread safety is achieved by maintaining two data
structures. The first is a map of seen strings to the number of times the
string has been seen. The map is maintained by the base class:
AbstractStringCache
. The second structure is a trie of the cached
byte[]
to the decoded string.
Modifier and Type | Class and Description |
---|---|
protected static class |
StringDecoderCache.TrieCache
A fast cache for bytes to decoded strings.
|
AbstractStringCache.ReverseIntegerComparator
DEFAULT_MAX_CACHE_ENTRIES, DEFAULT_MAX_CACHE_LENGTH, MAX_MULTIPLIER, myMaxCacheLength, myMaxCachEntries, myMaxCachEntriesMultiplier, mySeen, myUseCount
Constructor and Description |
---|
StringDecoderCache()
Creates a new TrieStringCache.
|
Modifier and Type | Method and Description |
---|---|
protected void |
clear()
Clears the cache.
|
String |
find(byte[] source,
int offset,
int length)
Decode a string of a known length.
|
protected void |
rebuildCache()
Rebuilds the cache from the current collection of seen entries.
|
buildCacheGroups, getMaxCacheEntries, getMaxCacheLength, setMaxCacheEntries, setMaxCacheLength, used
public String find(byte[] source, int offset, int length) throws StreamCorruptedException, EOFException
source
- The source of the bytes in the string.offset
- The offset of the first byte to decode.length
- The length of the string to decode with a terminal zero byte.StreamCorruptedException
- On the decoding of the string failing.EOFException
- On the array not containing enough bytes to decoded.protected void clear()
clear
in class AbstractStringCache
protected void rebuildCache()
rebuildCache
in class AbstractStringCache
Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.