Package org.apache.nifi.util.search
Class SearchTerm<T>
java.lang.Object
org.apache.nifi.util.search.SearchTerm<T>
This is an immutable thread safe object representing a search term
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSearchTerm
(byte[] bytes) Constructs a SearchTerm.SearchTerm
(byte[] bytes, boolean defensiveCopy, T reference) Constructs a search term. -
Method Summary
-
Field Details
-
bytes
private final byte[] bytes -
hashCode
private final int hashCode -
reference
-
-
Constructor Details
-
SearchTerm
public SearchTerm(byte[] bytes) Constructs a SearchTerm. Defensively copies the given byte array- Parameters:
bytes
- the bytes of the search term- Throws:
IllegalArgumentException
- if given bytes are null or 0 length
-
SearchTerm
Constructs a search term. Optionally performs a defensive copy of the given byte array. If the caller indicates a defensive copy is not necessary then they must not change the given arrays state any longer- Parameters:
bytes
- the bytes of the new search termdefensiveCopy
- if true will make a defensive copy; false otherwisereference
- a holder for an object which can be retrieved when this search term hits
-
-
Method Details
-
get
public int get(int index) -
size
public int size()- Returns:
- size in of search term in bytes
-
getReference
- Returns:
- reference object for this given search term
-
startsWith
public boolean startsWith(byte[] window, int windowLength) Determines if the given window starts with the same bytes as this term- Parameters:
window
- bytes from the haystack being evaluatedwindowLength
- The length of the window to consider- Returns:
- true if this term starts with the same bytes of the given window
-
getBytes
public byte[] getBytes()- Returns:
- a defensive copy of the internal byte structure
-
hashCode
public int hashCode() -
equals
-
toString
-
toString
-