/// <summary> /// Initializes a new instance of the <see cref="CodelistRefCore"/> class. /// </summary> /// <param name="codelistRefMutableObject"> /// The sdmxObject. /// </param> /// <param name="parent"> /// The parent. /// </param> public CodelistRefCore(ICodelistRefMutableObject codelistRefMutableObject, ISdmxStructure parent) : base(codelistRefMutableObject, parent) { this.alias = codelistRefMutableObject.Alias; if (codelistRefMutableObject.CodelistReference != null) { this.codelistReference = new CrossReferenceImpl(this, codelistRefMutableObject.CodelistReference); } this.Validate(); }
/// <summary> /// The write codelist ref. /// </summary> /// <param name="codelistRef"> /// The codelist ref. /// </param> private void WriteCodelistRef(ICodelistRefMutableObject codelistRef) { this.WriteStartElement(this.DefaultNS, ElementNameTable.CodelistRef); this.TryToWriteElement(this.DefaultNS, ElementNameTable.URN, codelistRef.CodelistReference.MaintainableUrn); this.TryToWriteElement( this.DefaultNS, ElementNameTable.AgencyID, codelistRef.CodelistReference.MaintainableReference.AgencyId); this.TryToWriteElement( this.DefaultNS, ElementNameTable.CodelistID, codelistRef.CodelistReference.MaintainableReference.MaintainableId); this.TryToWriteElement( this.DefaultNS, ElementNameTable.Version, codelistRef.CodelistReference.MaintainableReference.Version); this.TryToWriteElement(this.DefaultNS, ElementNameTable.Alias, codelistRef.Alias); this.WriteEndElement(); }
/// <summary> /// Handles the CodelistRef element child elements /// </summary> /// <param name="parent"> /// The parent ICodelistRefMutableObject object /// </param> /// <param name="localName"> /// The name of the current xml element /// </param> private void HandleTextChildElement(ICodelistRefMutableObject parent, object localName) { if (!this.HandleReferenceTextChildElement(this._currentReference, localName)) { if (NameTableCache.IsElement(localName, ElementNameTable.CodelistID)) { this._currentReference.ID = this.Text; } else if (NameTableCache.IsElement(localName, ElementNameTable.AgencyID)) { this._currentReference.AgencyId = this.Text; } else if (NameTableCache.IsElement(localName, ElementNameTable.Alias)) { parent.Alias = this.Text; } } }
/// <summary> /// Handles the HierarchicalCodelist element child elements /// </summary> /// <param name="parent"> /// The parent IHierarchicalCodelistMutableObject object /// </param> /// <param name="localName"> /// The name of the current xml element /// </param> /// <returns> /// The <see cref="StructureReaderBaseV20.ElementActions"/>. /// </returns> private ElementActions HandleChildElements(IHierarchicalCodelistMutableObject parent, object localName) { ElementActions actions = null; if (NameTableCache.IsElement(localName, ElementNameTable.CodelistRef)) { var codelistRefMutableCore = new CodelistRefMutableCore(); parent.AddCodelistRef(codelistRefMutableCore); this._currentCodelistRef = codelistRefMutableCore; IReferenceInfo reference = new ReferenceInfo(SdmxStructureEnumType.CodeList); this._currentReference = reference; actions = this.BuildElementActions(codelistRefMutableCore, DoNothingComplex, HandleTextChildElement); } else if (NameTableCache.IsElement(localName, ElementNameTable.Hierarchy)) { var hc = new HierarchyMutableCore(); ParseAttributes(hc, this.Attributes); this._currentHierarchy = hc; //// TODO java 0.9.9 no isFinal ////hc.IsFinal = Helper.TrySetFromAttribute(this.Attributes, AttributeNameTable.isFinal, hc.IsFinal); parent.AddHierarchies(hc); actions = this.AddNameableAction(hc, this.HandleChildElements); } return actions; }
/// <summary> /// When override handles end element. /// </summary> /// <param name="localName"> /// The element local name. /// </param> protected override void HandleEndElement(object localName) { if (NameTableCache.IsElement(localName, ElementNameTable.CodelistRef)) { if (this._currentReference != null && this._currentCodelistRef != null) { this._currentCodelistRef.CodelistReference = this._currentReference.CreateReference(); } this._currentCodelistRef = null; this._currentReference = null; } else if (NameTableCache.IsElement(localName, ElementNameTable.Hierarchy)) { var levelMutableObjects = this._currentLevels; var currentHierarchy = this._currentHierarchy; SetupHierarchyLevels(levelMutableObjects, currentHierarchy); SetupCodeRefLevels(currentHierarchy); levelMutableObjects.Clear(); } }