write(str, offset) {
        switch (this.state) {
            case EntityDecoderState.EntityStart: {
                if (str.charCodeAt(offset) === CharCodes.NUM) {
                    this.state = EntityDecoderState.NumericStart;
                    this.consumed += 1;
                    return this.stateNumericStart(str, offset + 1);
                }
                this.state = EntityDecoderState.NamedEntity;
                return this.stateNamedEntity(str, offset);
            }
            case EntityDecoderState.NumericStart: {
                return this.stateNumericStart(str, offset);
            }
            case EntityDecoderState.NumericDecimal: {
                return this.stateNumericDecimal(str, offset);
            }
            case EntityDecoderState.NumericHex: {
                return this.stateNumericHex(str, offset);
            }
            case EntityDecoderState.NamedEntity: {
                return this.stateNamedEntity(str, offset);
            }
        }
    }
Write an entity to the decoder. This can be called multiple times with partial entities.
If the entity is incomplete, the decoder will return -1.

Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
entity is incomplete, and resume when the next string is written.

@param string The string containing the entity (or a continuation of the entity).
@param offset The offset at which the entity begins. Should be 0 if this is not the first call.
@returns The number of characters that were consumed, or -1 if the entity is incomplete.