Class ByteTrie<T>
- java.lang.Object
-
- org.apache.pdfbox.util.filetypedetector.ByteTrie<T>
-
- Type Parameters:
T
- the type of value to store for byte sequences
class ByteTrie<T> extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ByteTrie.ByteTrieNode<T>
A node in the trie.
-
Field Summary
Fields Modifier and Type Field Description private int
maxDepth
private ByteTrie.ByteTrieNode<T>
root
-
Constructor Summary
Constructors Constructor Description ByteTrie()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPath(T value, byte[]... parts)
Store the given value at the specified path.T
find(byte[] bytes)
Return the most specific value stored for this byte sequence.int
getMaxDepth()
Gets the maximum depth stored in this trie.void
setDefaultValue(T defaultValue)
Sets the default value to use infind(byte[])
when no path matches.
-
-
-
Field Detail
-
root
private final ByteTrie.ByteTrieNode<T> root
-
maxDepth
private int maxDepth
-
-
Method Detail
-
find
public T find(byte[] bytes)
Return the most specific value stored for this byte sequence. If not found, returnsnull
or a default values as specified by callingsetDefaultValue(T)
.- Parameters:
bytes
-- Returns:
-
addPath
public void addPath(T value, byte[]... parts)
Store the given value at the specified path.- Parameters:
value
-parts
-
-
setDefaultValue
public void setDefaultValue(T defaultValue)
Sets the default value to use infind(byte[])
when no path matches.- Parameters:
defaultValue
-
-
getMaxDepth
public int getMaxDepth()
Gets the maximum depth stored in this trie.- Returns:
-
-