Record Class StructuralEncodingRules.Utf8Stats
- Enclosing class:
StructuralEncodingRules
StructuralEncodingRules.checkUtf8(byte[]) but without the early exit — scans the entire range,
resyncing after each error.
errors counts one event per bad lead, orphaned continuation,
overlong, surrogate, or out-of-range codepoint regardless of how many
bytes the bad sequence spans — matching Java's
new String(bytes, UTF_8) U+FFFD-per-error semantics, the
convention callers use for tolerance thresholds. A truncated sequence
at probe-end is neither an error nor a sequence.
sequences gauges how much genuine multi-byte UTF-8 evidence
the probe carries independent of its error count.
truncatedTailInvalid: the probe ends in a truncated sequence
whose partial continuations are provably NOT UTF-8 (e.g. E0 41
at probe-end). Not an error event (no U+FFFD equivalent — the
decoder would ask for more input), but it disqualifies the sample from
StructuralEncodingRules.Utf8Result.LIKELY_UTF8/StructuralEncodingRules.Utf8Result.AMBIGUOUS.
-
Constructor Summary
ConstructorsConstructorDescriptionUtf8Stats(int errors, int sequences, boolean truncatedTailInvalid) Creates an instance of aUtf8Statsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.interrors()Returns the value of theerrorsrecord component.final inthashCode()Returns a hash code value for this object.intReturns the value of thesequencesrecord component.toResult()Collapse to theStructuralEncodingRules.checkUtf8(byte[])tri-state: any invalidity → NOT_UTF8; else ≥1 complete multi-byte sequence → LIKELY_UTF8 (a lone truncated lead is no structural evidence); else AMBIGUOUS (pure ASCII, or truncated-lead-only).final StringtoString()Returns a string representation of this record class.booleanReturns the value of thetruncatedTailInvalidrecord component.
-
Constructor Details
-
Utf8Stats
public Utf8Stats(int errors, int sequences, boolean truncatedTailInvalid) Creates an instance of aUtf8Statsrecord class.- Parameters:
errors- the value for theerrorsrecord componentsequences- the value for thesequencesrecord componenttruncatedTailInvalid- the value for thetruncatedTailInvalidrecord component
-
-
Method Details
-
toResult
Collapse to theStructuralEncodingRules.checkUtf8(byte[])tri-state: any invalidity → NOT_UTF8; else ≥1 complete multi-byte sequence → LIKELY_UTF8 (a lone truncated lead is no structural evidence); else AMBIGUOUS (pure ASCII, or truncated-lead-only). -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
errors
public int errors()Returns the value of theerrorsrecord component.- Returns:
- the value of the
errorsrecord component
-
sequences
public int sequences()Returns the value of thesequencesrecord component.- Returns:
- the value of the
sequencesrecord component
-
truncatedTailInvalid
public boolean truncatedTailInvalid()Returns the value of thetruncatedTailInvalidrecord component.- Returns:
- the value of the
truncatedTailInvalidrecord component
-