Class AdaptiveProbe
java.lang.Object
org.apache.tika.ml.chardetect.AdaptiveProbe
Reads an encoding-detection probe sized by content, not raw bytes.
A fixed raw probe (e.g. 16 KB) starves the detectors when a page
leads with a large <head>/inline script: after tag-stripping there's
little body text, and the bytes that distinguish charsets sit past the
window. This grows the read until ~contentTarget bytes of
tag-stripped content are present, capped at rawCap raw bytes.
Text-rich pages stop early (~one chunk); markup-heavy pages read deeper,
bounded by the cap. Multi-byte encodings (UTF-16/32) register no ASCII tags
so they stop at contentTarget raw bytes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault body-content target.static final intDefault hard ceiling on raw bytes read. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]read(TikaInputStream tis, int contentTarget, int rawCap) Reads fromtis(mark/reset preserved) until tag-stripped content reachescontentTarget, the raw read reachesrawCap, or EOF — whichever first.
-
Field Details
-
DEFAULT_CONTENT_TARGET
public static final int DEFAULT_CONTENT_TARGETDefault body-content target.- See Also:
-
DEFAULT_RAW_CAP
public static final int DEFAULT_RAW_CAPDefault hard ceiling on raw bytes read.- See Also:
-
-
Method Details
-
read
Reads fromtis(mark/reset preserved) until tag-stripped content reachescontentTarget, the raw read reachesrawCap, or EOF — whichever first. Returns the raw bytes read.- Throws:
IOException
-