* 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)
| 2575 | * @throws {XmlSyntaxError} If the tokenizer is in an incomplete state. |
| 2576 | */ |
| 2577 | finalize(callbacks: XmlTokenCallbacks): void { |
| 2578 | this.#callbacks = callbacks; |
| 2579 | this.#flushText(); |
| 2580 | |
| 2581 | if (this.#state !== State.INITIAL) { |
| 2582 | // Provide specific error messages based on state |
| 2583 | const message = this.#getEndOfInputErrorMessage(); |
| 2584 | this.#error(message); |
| 2585 | } |
| 2586 | } |
| 2587 | |
| 2588 | #getEndOfInputErrorMessage(): string { |
| 2589 | switch (this.#state) { |
no test coverage detected