/// <summary>Parses a component profile </summary> private AbstractComponent parseComponentProfile(System.Xml.XmlElement elem, bool isSubComponent) { AbstractComponent comp = null; if (isSubComponent) { comp = new SubComponent(); } else { comp = new Component(); int childIndex = 1; System.Xml.XmlNodeList children = elem.ChildNodes; for (int i = 0; i < children.Count; i++) { System.Xml.XmlNode n = children.Item(i); if (System.Convert.ToInt16(n.NodeType) == (short)System.Xml.XmlNodeType.Element) { System.Xml.XmlElement child = (System.Xml.XmlElement)n; if (child.Name.ToUpper().Equals("SubComponent".ToUpper())) { SubComponent subcomp = (SubComponent)parseComponentProfile(child, true); ((Component)comp).setSubComponent(childIndex++, subcomp); } } } } parseAbstractComponentData(comp, elem); return(comp); }
/// <summary>Parses common features of AbstractComponents (ie field, component, subcomponent) </summary> private void parseAbstractComponentData(AbstractComponent comp, System.Xml.XmlElement elem) { comp.Name = elem.GetAttribute("Name"); comp.Usage = elem.GetAttribute("Usage"); comp.Datatype = elem.GetAttribute("Datatype"); System.String length = elem.GetAttribute("Length"); if (length != null && length.Length > 0) { try { comp.Length = System.Int64.Parse(length); } catch (System.FormatException e) { throw new NuGenProfileException("Length must be a long integer: " + length, e); } } comp.ConstantValue = elem.GetAttribute("ConstantValue"); System.String table = elem.GetAttribute("Table"); if (table != null && table.Length > 0) { try { comp.Table = table; } catch (System.FormatException e) { throw new NuGenProfileException("Table must be a short integer: " + table, e); } } comp.ImpNote = getValueOfFirstElement("ImpNote", elem); comp.Description = getValueOfFirstElement("Description", elem); comp.Reference = getValueOfFirstElement("Reference", elem); comp.Predicate = getValueOfFirstElement("Predicate", elem); int dataValIndex = 0; System.Xml.XmlNodeList children = elem.ChildNodes; for (int i = 0; i < children.Count; i++) { System.Xml.XmlNode n = children.Item(i); if (System.Convert.ToInt16(n.NodeType) == (short)System.Xml.XmlNodeType.Element) { System.Xml.XmlElement child = (System.Xml.XmlElement)n; if (child.Name.ToUpper().Equals("DataValues".ToUpper())) { DataValue val = new DataValue(); val.ExValue = child.GetAttribute("ExValue"); comp.setDataValues(dataValIndex++, val); } } } }
/// <summary>This method will build a primitive conformance class (ST, NM, etc) which is /// a Component or Subcomponent. /// </summary> public virtual void buildClass(Genetibase.NuGenHL7.conf.spec.message.AbstractComponent primitive, int profileType) { GeneratedPrimitive genClass = new GeneratedPrimitive(); ProfileName profileName = new ProfileName(primitive.Name, profileType); // Set up class genClass.ClassPackage = packageName; genClass.addClassImport("Genetibase.NuGenHL7.model.*"); genClass.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*"); genClass.Properties = "extends AbstractConformanceDataType"; genClass.Name = profileName.ClassName; docBuilder.decorateConstructor(genClass.Constructor, profileName.ClassName); if (primitive.ConstantValue != null && primitive.ConstantValue.Length > 0) { // Add constant value constraints if there are any genClass.addConstantValue(primitive.ConstantValue); } else { // if no constant value, then we add a setter method GeneratedMethod setter = new GeneratedMethod(); setter.addParam("java.lang.String value"); setter.addToThrows("ConfDataException"); setter.addToBody("super.setValue( value );"); setter.ReturnType = "void"; setter.Visibility = "public"; setter.Name = "setValue"; docBuilder.decorateSetValue(setter, primitive.Length); genClass.addMethod(setter); genClass.addClassImport("Genetibase.NuGenHL7.conf.classes.exceptions.*"); } genClass.addMaxLength(primitive.Length); // Decorate with comments docBuilder.decoratePrimitive(genClass, primitive); if (depManager.Verbose) { System.Console.Out.WriteLine("Generating Primitive: " + packageName + "." + genClass.Name); } depManager.generateFile(genClass, packageName, genClass.Name); }
/// <summary>Parses common features of AbstractComponents (ie field, component, subcomponent) </summary> private void parseAbstractComponentData(AbstractComponent comp, System.Xml.XmlElement elem) { comp.Name = elem.GetAttribute("Name"); comp.Usage = elem.GetAttribute("Usage"); comp.Datatype = elem.GetAttribute("Datatype"); System.String length = elem.GetAttribute("Length"); if (length != null && length.Length > 0) { try { comp.Length = System.Int64.Parse(length); } catch (System.FormatException e) { throw new NuGenProfileException("Length must be a long integer: " + length, e); } } comp.ConstantValue = elem.GetAttribute("ConstantValue"); System.String table = elem.GetAttribute("Table"); if (table != null && table.Length > 0) { try { comp.Table = table; } catch (System.FormatException e) { throw new NuGenProfileException("Table must be a short integer: " + table, e); } } comp.ImpNote = getValueOfFirstElement("ImpNote", elem); comp.Description = getValueOfFirstElement("Description", elem); comp.Reference = getValueOfFirstElement("Reference", elem); comp.Predicate = getValueOfFirstElement("Predicate", elem); int dataValIndex = 0; System.Xml.XmlNodeList children = elem.ChildNodes; for (int i = 0; i < children.Count; i++) { System.Xml.XmlNode n = children.Item(i); if (System.Convert.ToInt16(n.NodeType) == (short) System.Xml.XmlNodeType.Element) { System.Xml.XmlElement child = (System.Xml.XmlElement) n; if (child.Name.ToUpper().Equals("DataValues".ToUpper())) { DataValue val = new DataValue(); val.ExValue = child.GetAttribute("ExValue"); comp.setDataValues(dataValIndex++, val); } } } }