diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/third_party/asn1js/src/ObjectIdentifier.ts | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/third_party/asn1js/src/ObjectIdentifier.ts')
-rw-r--r-- | comm/third_party/asn1js/src/ObjectIdentifier.ts | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/comm/third_party/asn1js/src/ObjectIdentifier.ts b/comm/third_party/asn1js/src/ObjectIdentifier.ts new file mode 100644 index 0000000000..7608a3cf7d --- /dev/null +++ b/comm/third_party/asn1js/src/ObjectIdentifier.ts @@ -0,0 +1,53 @@ +import { BaseBlock, BaseBlockJson, BaseBlockParams } from "./BaseBlock"; +import { LocalObjectIdentifierValueBlockParams, LocalObjectIdentifierValueBlock, LocalObjectIdentifierValueBlockJson } from "./internals/LocalObjectIdentifierValueBlock"; +import { typeStore } from "./TypeStore"; + +export interface ObjectIdentifierParams extends BaseBlockParams, LocalObjectIdentifierValueBlockParams { } +export interface ObjectIdentifierJson extends BaseBlockJson<LocalObjectIdentifierValueBlockJson> { + value: string; +} + +export class ObjectIdentifier extends BaseBlock<LocalObjectIdentifierValueBlock, LocalObjectIdentifierValueBlockJson> { + + static { + typeStore.ObjectIdentifier = this; + } + + public static override NAME = "OBJECT IDENTIFIER"; + + /** + * Gets string representation of Object Identifier + * @since 3.0.0 + */ + public getValue(): string { + return this.valueBlock.toString(); + } + + /** + * Sets Object Identifier value from string + * @param value String value + * @since 3.0.0 + */ + public setValue(value: string): void { + this.valueBlock.fromString(value); + } + + constructor(parameters: ObjectIdentifierParams = {}) { + super(parameters, LocalObjectIdentifierValueBlock); + + this.idBlock.tagClass = 1; // UNIVERSAL + this.idBlock.tagNumber = 6; // OBJECT IDENTIFIER + } + + protected override onAsciiEncoding(): string { + return `${(this.constructor as typeof ObjectIdentifier).NAME} : ${this.valueBlock.toString() || "empty"}`; + } + + public override toJSON(): ObjectIdentifierJson { + return { + ...super.toJSON(), + value: this.getValue(), + }; + } + +} |