* Finalize tokenization using callbacks. * * This method should be called after all chunks have been processed. * It flushes any pending text content and validates that the tokenizer * is in a valid end state. * * @throws {XmlSyntaxError} If the tokenizer is in an incomplete state.
(callbacks: XmlTokenCallbacks)
| 2526 | * @throws {XmlSyntaxError} If the tokenizer is in an incomplete state. |
| 2527 | */ |
| 2528 | finalize(callbacks: XmlTokenCallbacks): void { |
| 2529 | this.#callbacks = callbacks; |
| 2530 | this.#flushText(); |
| 2531 | |
| 2532 | if (this.#state !== State.INITIAL) { |
| 2533 | // Provide specific error messages based on state |
| 2534 | const message = this.#getEndOfInputErrorMessage(); |
| 2535 | this.#error(message); |
| 2536 | } |
| 2537 | } |
| 2538 | |
| 2539 | #getEndOfInputErrorMessage(): string { |
| 2540 | switch (this.#state) { |
no test coverage detected