예제 #1
0
 /// <summary>Adds a label and it data value to Primitive GeneratedClass Comments in a table format</summary>
 /// <param name="genClass">a GeneratedPrimitive
 /// </param>
 /// <param name="label">optional comment label to add to the class header document table
 /// </param>
 /// <param name="data">the data value to add to the class header document table
 /// </param>
 private void  addOptionalComment(GeneratedPrimitive genClass, System.String label, System.String data)
 {
     if (data != null && (System.Object)data != (System.Object) "")
     {
         genClass.addClassComment("   <tr><td>" + label + "</td><td>" + data + "</td></tr>");
     }
 }
예제 #2
0
        /// <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);
        }
예제 #3
0
 /// <summary>Adds Class Comments to a Generated Primitive Class</summary>
 /// <param name="genClass">a GeneratedConformanceContainer
 /// </param>
 /// <param name="ac">the AbstractComponent for which the comments are being added to
 /// </param>
 public void  decoratePrimitive(GeneratedPrimitive genClass, AbstractComponent ac)
 {
     genClass.addClassComment("This represents a constrained " + ac.Name + " field, with the following properties:");
     genClass.addClassComment("<table>");
     addOptionalComment(genClass, "Name", ac.Name);
     addOptionalComment(genClass, "Usage", ac.Usage);
     addOptionalComment(genClass, "Data Type", ac.Datatype);
     addOptionalComment(genClass, "Constant Value", ac.ConstantValue);
     addOptionalComment(genClass, "Description", ac.Description);
     addOptionalComment(genClass, "Implementation Note", ac.ImpNote);
     addOptionalComment(genClass, "Predicate", ac.Predicate);
     addOptionalComment(genClass, "Reference", ac.Reference);
     addOptionalComment(genClass, "Length", ac.Length + "");
     if (ac.Table != null && Regex.IsMatch(ac.Table, "[^0]"))
     {
         addOptionalComment(genClass, "Table", ac.Table + "");
     }
     genClass.addClassComment("</table>");
 }
		/// <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>This method will build a primitive conformance class (ST, NM, etc) which is
		/// a Field. 
		/// </summary>
		public virtual void  buildClass(Genetibase.NuGenHL7.conf.spec.message.Field primitive, System.String parentUnderlyingType, ProfileName profileName)
		{
			GeneratedPrimitive genClass = new GeneratedPrimitive();
			
			// Check for possible snags in the Runtime Profile Component
			if (primitive.Name == null || primitive.Name.Length < 1)
				throw new ConformanceError("Error building ConformanceSegment: Runtime AbstractComponent does not contain a name.");
			
			GeneratedMethod theConstructor = new GeneratedMethod();
			genClass.Constructor = theConstructor;
			genClass.addClassImport("Genetibase.NuGenHL7.model.*");
			
			UnderlyingAccessor underlyingAccessor = new UnderlyingAccessor(parentUnderlyingType, profileName.AccessorName);
			theConstructor.addParam(parentUnderlyingType + " parentSeg", "The parent underlying data type");
			theConstructor.addParam("int rep", "The desired repetition");
			theConstructor.Name = profileName.ClassName;
			theConstructor.Visibility = "public ";
			theConstructor.addToThrows("Genetibase.NuGenHL7.HL7Exception");
			theConstructor.addToBody("super( (Primitive)parentSeg." + underlyingAccessor + " );");
			theConstructor.addToBody("if ( parentSeg." + underlyingAccessor + " == null )");
			theConstructor.addToBody("   throw new Genetibase.NuGenHL7.HL7Exception( \"Error accussing underlying object. This is a bug.\", 0 );");
			
			// Set up class
			genClass.ClassPackage = packageName;
			//genClass.addClassImport("Genetibase.NuGenHL7.model.*");
			genClass.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*");
			//genClass.addClassImport( "Genetibase.NuGenHL7.conf.classes.exceptions.*" );
			genClass.Properties = "extends AbstractConformanceDataType implements Repeatable";
			
			// Add min and max reps stuff
			genClass.setMinMaxReps(primitive.Min, primitive.Max);
			
			genClass.Name = profileName.ClassName;
			docBuilder.decorateConstructor(genClass.Constructor, profileName.ClassName);
			
			// Add constant value constraints if there are any, if not, add a setter method
			if (primitive.ConstantValue != null && primitive.ConstantValue.Length > 0)
			{
				genClass.addConstantValue(primitive.ConstantValue);
			}
			else
			{
				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);
		}
예제 #6
0
        /// <summary>This method will build a primitive conformance class (ST, NM, etc) which is
        /// a Field.
        /// </summary>
        public virtual void  buildClass(Genetibase.NuGenHL7.conf.spec.message.Field primitive, System.String parentUnderlyingType, ProfileName profileName)
        {
            GeneratedPrimitive genClass = new GeneratedPrimitive();

            // Check for possible snags in the Runtime Profile Component
            if (primitive.Name == null || primitive.Name.Length < 1)
            {
                throw new ConformanceError("Error building ConformanceSegment: Runtime AbstractComponent does not contain a name.");
            }

            GeneratedMethod theConstructor = new GeneratedMethod();

            genClass.Constructor = theConstructor;
            genClass.addClassImport("Genetibase.NuGenHL7.model.*");

            UnderlyingAccessor underlyingAccessor = new UnderlyingAccessor(parentUnderlyingType, profileName.AccessorName);

            theConstructor.addParam(parentUnderlyingType + " parentSeg", "The parent underlying data type");
            theConstructor.addParam("int rep", "The desired repetition");
            theConstructor.Name       = profileName.ClassName;
            theConstructor.Visibility = "public ";
            theConstructor.addToThrows("Genetibase.NuGenHL7.HL7Exception");
            theConstructor.addToBody("super( (Primitive)parentSeg." + underlyingAccessor + " );");
            theConstructor.addToBody("if ( parentSeg." + underlyingAccessor + " == null )");
            theConstructor.addToBody("   throw new Genetibase.NuGenHL7.HL7Exception( \"Error accussing underlying object. This is a bug.\", 0 );");

            // Set up class
            genClass.ClassPackage = packageName;
            //genClass.addClassImport("Genetibase.NuGenHL7.model.*");
            genClass.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*");
            //genClass.addClassImport( "Genetibase.NuGenHL7.conf.classes.exceptions.*" );
            genClass.Properties = "extends AbstractConformanceDataType implements Repeatable";

            // Add min and max reps stuff
            genClass.setMinMaxReps(primitive.Min, primitive.Max);

            genClass.Name = profileName.ClassName;
            docBuilder.decorateConstructor(genClass.Constructor, profileName.ClassName);

            // Add constant value constraints if there are any, if not, add a setter method
            if (primitive.ConstantValue != null && primitive.ConstantValue.Length > 0)
            {
                genClass.addConstantValue(primitive.ConstantValue);
            }
            else
            {
                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);
        }