Exemple #1
0
        /// <summary>Parses a primitive type by filling it with text child, if any </summary>
        private void  parsePrimitive(Primitive datatypeObject, System.Xml.XmlElement datatypeElement)
        {
            System.Xml.XmlNodeList children = datatypeElement.ChildNodes;
            int  c    = 0;
            bool full = false;

            while (c < children.Count && !full)
            {
                System.Xml.XmlNode child = children.Item(c++);
                if (System.Convert.ToInt16(child.NodeType) == (short)System.Xml.XmlNodeType.Text)
                {
                    try
                    {
                        if (child.Value != null && !child.Value.Equals(""))
                        {
                            if (keepAsOriginal(child.ParentNode))
                            {
                                datatypeObject.Value = child.Value;
                            }
                            else
                            {
                                datatypeObject.Value = removeWhitespace(child.Value);
                            }
                        }
                    }
                    catch (System.Exception)
                    {
                    }
                    full = true;
                }
            }
        }
Exemple #2
0
 private static System.String encodePrimitive(Primitive p, NuGenEncodingCharacters encodingChars)
 {
     System.String val = ((Primitive)p).Value;
     if (val == null)
     {
         val = "";
     }
     else
     {
         val = NuGenEscape.escape(val, encodingChars);
     }
     return(val);
 }
        /// <summary>Constructor for AbstractConformanceDataType</summary>
        /// <param name="hapiPrimitive">the underlying primitive that the extending class represents
        /// </param>
        public AbstractConformanceDataType(Primitive hapiPrimitive)
        {
            this.hapiPrimitive = hapiPrimitive;

            try
            {
                if (ConstantValue != null)
                {
                    Value = ConstantValue;
                }
            }
            catch (ConfDataException)
            {
            }
        }
Exemple #4
0
 /// <summary> Encodes the given Type, using the given encoding characters.
 /// It is assumed that the Type represents a complete field rather than a component.
 /// </summary>
 public static System.String encode(Type source, NuGenEncodingCharacters encodingChars)
 {
     System.Text.StringBuilder field = new System.Text.StringBuilder();
     for (int i = 1; i <= Terser.numComponents(source); i++)
     {
         System.Text.StringBuilder comp = new System.Text.StringBuilder();
         for (int j = 1; j <= Terser.numSubComponents(source, i); j++)
         {
             Primitive p = Terser.getPrimitive(source, i, j);
             comp.Append(encodePrimitive(p, encodingChars));
             comp.Append(encodingChars.SubcomponentSeparator);
         }
         field.Append(stripExtraDelimiters(comp.ToString(), encodingChars.SubcomponentSeparator));
         field.Append(encodingChars.ComponentSeparator);
     }
     return(stripExtraDelimiters(field.ToString(), encodingChars.ComponentSeparator));
     //return encode(source, encodingChars, false);
 }
Exemple #5
0
        private void  parse(System.String field, Segment segment, int num, NuGenEncodingCharacters ec)
        {
            if (field != null)
            {
                int  rep          = 0;
                int  component    = 1;
                int  subcomponent = 1;
                Type type         = segment.getField(num, rep);

                System.String delim = System.Convert.ToString(new char[] { ec.RepetitionSeparator, ec.ComponentSeparator, ec.SubcomponentSeparator });
                for (SupportClass.Tokenizer tok = new SupportClass.Tokenizer(field, delim, true); tok.HasMoreTokens();)
                {
                    System.String token = tok.NextToken();
                    char          c     = token[0];
                    if (c == ec.RepetitionSeparator)
                    {
                        rep++;
                        component    = 1;
                        subcomponent = 1;
                        type         = segment.getField(num, rep);
                    }
                    else if (c == ec.ComponentSeparator)
                    {
                        component++;
                        subcomponent = 1;
                    }
                    else if (c == ec.SubcomponentSeparator)
                    {
                        subcomponent++;
                    }
                    else
                    {
                        Primitive p = Terser.getPrimitive(type, component, subcomponent);
                        p.Value = token;
                    }
                }
            }
        }
Exemple #6
0
        /// <summary> Encodes a Primitive in XML by adding it's value as a child of the given Element.
        /// Returns true if the given Primitive contains a value.
        /// </summary>
        private bool encodePrimitive(Primitive datatypeObject, System.Xml.XmlElement datatypeElement)
        {
            bool hasValue = false;

            if (datatypeObject.Value != null && !datatypeObject.Value.Equals(""))
            {
                hasValue = true;
            }

            System.Xml.XmlText t = datatypeElement.OwnerDocument.CreateTextNode(datatypeObject.Value);
            if (hasValue)
            {
                try
                {
                    datatypeElement.AppendChild(t);
                }
                catch (System.Exception e)
                {
                    throw new DataTypeException("DOMException encoding Primitive: ", e);
                }
            }
            return(hasValue);
        }
		/// <summary>Constructor for AbstractConformanceDataType</summary>
		/// <param name="hapiPrimitive">the underlying primitive that the extending class represents
		/// </param>
		public AbstractConformanceDataType(Primitive hapiPrimitive)
		{
			this.hapiPrimitive = hapiPrimitive;
			
			try
			{
				if (ConstantValue != null)
					Value = ConstantValue;
			}
			catch (ConfDataException)
			{
			}
		}
		private static System.String encodePrimitive(Primitive p, NuGenEncodingCharacters encodingChars)
		{
			System.String val = ((Primitive) p).Value;
			if (val == null)
			{
				val = "";
			}
			else
			{
				val = NuGenEscape.escape(val, encodingChars);
			}
			return val;
		}
		/// <seealso cref="Genetibase.NuGenHL7.validation.ValidationContext.getDataTypeRules(java.lang.String, java.lang.String)">
		/// </seealso>
		/// <param name="theType">ignored 
		/// </param>
		public virtual NuGenPrimitiveTypeRule[] getPrimitiveRules(System.String theVersion, System.String theTypeName, Primitive theType)
		{
			System.Collections.IList active = new System.Collections.ArrayList(myPrimitiveRuleBindings.Count);
			for (int i = 0; i < myPrimitiveRuleBindings.Count; i++)
			{
				System.Object o = myPrimitiveRuleBindings[i];
				if (!(o is NuGenRuleBinding))
				{
					throw new System.InvalidCastException("Item in rule binding list is not a RuleBinding");
				}
				
				NuGenRuleBinding binding = (NuGenRuleBinding) o;
				if (binding.Active && binding.appliesToVersion(theVersion) && binding.appliesToScope(theTypeName))
				{
					active.Add(binding.Rule);
				}
			}

            NuGenPrimitiveTypeRule[] retVal = new NuGenPrimitiveTypeRule[active.Count];
            active.CopyTo(retVal, 0);

            return retVal;
		}
Exemple #10
0
        /// <seealso cref="Genetibase.NuGenHL7.validation.ValidationContext.getDataTypeRules(java.lang.String, java.lang.String)">
        /// </seealso>
        /// <param name="theType">ignored
        /// </param>
        public virtual NuGenPrimitiveTypeRule[] getPrimitiveRules(System.String theVersion, System.String theTypeName, Primitive theType)
        {
            System.Collections.IList active = new System.Collections.ArrayList(myPrimitiveRuleBindings.Count);
            for (int i = 0; i < myPrimitiveRuleBindings.Count; i++)
            {
                System.Object o = myPrimitiveRuleBindings[i];
                if (!(o is NuGenRuleBinding))
                {
                    throw new System.InvalidCastException("Item in rule binding list is not a RuleBinding");
                }

                NuGenRuleBinding binding = (NuGenRuleBinding)o;
                if (binding.Active && binding.appliesToVersion(theVersion) && binding.appliesToScope(theTypeName))
                {
                    active.Add(binding.Rule);
                }
            }

            NuGenPrimitiveTypeRule[] retVal = new NuGenPrimitiveTypeRule[active.Count];
            active.CopyTo(retVal, 0);

            return(retVal);
        }
		/// <summary> Encodes a Primitive in XML by adding it's value as a child of the given Element.  
		/// Returns true if the given Primitive contains a value.  
		/// </summary>
		private bool encodePrimitive(Primitive datatypeObject, System.Xml.XmlElement datatypeElement)
		{
			bool hasValue = false;
			if (datatypeObject.Value != null && !datatypeObject.Value.Equals(""))
				hasValue = true;
			
			System.Xml.XmlText t = datatypeElement.OwnerDocument.CreateTextNode(datatypeObject.Value);
			if (hasValue)
			{
				try
				{
					datatypeElement.AppendChild(t);
				}
				catch (System.Exception e)
				{
					throw new DataTypeException("DOMException encoding Primitive: ", e);
				}
			}
			return hasValue;
		}
		/// <summary>Parses a primitive type by filling it with text child, if any </summary>
		private void  parsePrimitive(Primitive datatypeObject, System.Xml.XmlElement datatypeElement)
		{
			System.Xml.XmlNodeList children = datatypeElement.ChildNodes;
			int c = 0;
			bool full = false;
			while (c < children.Count && !full)
			{
				System.Xml.XmlNode child = children.Item(c++);
				if (System.Convert.ToInt16(child.NodeType) == (short) System.Xml.XmlNodeType.Text)
				{
					try
					{
						if (child.Value != null && !child.Value.Equals(""))
						{
							if (keepAsOriginal(child.ParentNode))
							{
								datatypeObject.Value = child.Value;
							}
							else
							{
								datatypeObject.Value = removeWhitespace(child.Value);
							}
						}
					}
					catch (System.Exception)
					{
					}
					full = true;
				}
			}
		}