123456789101112131415161718192021222324252627282930313233343536373839 |
- import { XMLElem, type IToXML } from "@/util/XmlElem";
- import type { NamespaceTable } from "./NameSpaceTable";
- import { assert } from "@/util/assert";
- import { NodeId, coerceNodeId } from "./NodeId";
- import { UABaseNode } from "./UABaseNode";
- export class UAReference implements IToXML{
- public fromNode:UABaseNode = UABaseNode.nullBaseNode;
- public toNode:UABaseNode = UABaseNode.nullBaseNode;
- constructor(public fromRef: NodeId,
- public referenceType: string,
- public toRef: NodeId,
- public isForward: boolean) {
- }
- reIndex(nst: NamespaceTable, onst: NamespaceTable) {
- const nsName=onst.getUri(this.toRef.namespace);
- assert(nsName!=undefined)
- const newIndex=nst.getIndex(nsName);
- assert(newIndex!=undefined)
- this.toRef.namespace=newIndex;
- }
- toXML(lnst:NamespaceTable, gnst:NamespaceTable): XMLElem {
- const nid=UABaseNode.localNodeId(this.toRef, lnst, gnst);
- return new XMLElem('Reference', nid.toString())
- .attr('ReferenceType', this.referenceType.toString())
- .attr('IsForward',this.isForward);
- }
- static fromXML(uaReference: any, fromRef: NodeId): UAReference {
- return new UAReference( fromRef,
- uaReference['@_ReferenceType'],
- coerceNodeId(uaReference['#text']),
- uaReference['@_IsForward']!="false");
- }
- }
|