Class EncodingProbeCache
An instance is held by EncodingDetectorContext, so it inherits that
context's per-detection lifecycle: created fresh per detection and discarded
with the context immediately afterwards. That matters because a
ParseContext flows on into recursive
(attachment/embedded) parsing — a probe must never outlive the single detection
it was read for.
Not thread-safe: a single detection runs its detectors sequentially on one
thread. The cache is keyed by the probe parameters — get(int, int) returns the
cached probe only when both contentTarget and rawCap match what
it was stored with, so a detector that wants a differently-sized probe
transparently reads (and caches) its own.
The cached array is shared read-only state; callers must not mutate it in place.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
EncodingProbeCache
public EncodingProbeCache()
-
-
Method Details
-
get
public byte[] get(int contentTarget, int rawCap) - Returns:
- the cached probe if one was stored with the same
contentTargetandrawCap; otherwisenull
-
put
public void put(byte[] probe, int contentTarget, int rawCap) Stores the probe bytes read with the given parameters.
-