Esempio n. 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)
        {
            //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            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);
                            }
                        }
                    }
                    //UPGRADE_TODO: Class 'org.w3c.dom.DOMException' was converted to 'System.Exceptiont' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                    catch (System.Exception e)
                    {
                        log.error("Error parsing primitive value from TEXT_NODE", e);
                    }
                    full = true;
                }
            }
        }
Esempio n. 2
0
 private static System.String encodePrimitive(Primitive p, EncodingCharacters encodingChars)
 {
     System.String val = ((Primitive)p).Value;
     if (val == null)
     {
         val = "";
     }
     else
     {
         val = Escape.escape(val, encodingChars);
     }
     return(val);
 }
Esempio n. 3
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, EncodingCharacters 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);
 }
Esempio n. 4
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);
                }
                //UPGRADE_TODO: Class 'org.w3c.dom.DOMException' was converted to 'System.Exceptiont' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                catch (System.Exception e)
                {
                    throw new DataTypeException("DOMException encoding Primitive: ", e);
                }
            }
            return(hasValue);
        }
        /// <seealso cref="ca.uhn.hl7v2.validation.ValidationContext.getDataTypeRules(java.lang.String, java.lang.String)">
        /// </seealso>
        /// <param name="theType">ignored
        /// </param>
        public virtual PrimitiveTypeRule[] 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 RuleBinding))
                {
                    throw new System.InvalidCastException("Item in rule binding list is not a RuleBinding");
                }

                RuleBinding binding = (RuleBinding)o;
                if (binding.Active && binding.appliesToVersion(theVersion) && binding.appliesToScope(theTypeName))
                {
                    active.Add(binding.Rule);
                }
            }
            return((PrimitiveTypeRule[])SupportClass.ICollectionSupport.ToArray(active, new PrimitiveTypeRule[0]));
        }
Esempio n. 6
0
        /// <seealso cref="ca.uhn.hl7v2.validation.ValidationContext.getDataTypeRules(java.lang.String, java.lang.String)">
        /// </seealso>
        /// <param name="theType">ignored 
        /// </param>
        public virtual PrimitiveTypeRule[] 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 RuleBinding))
                {
                    throw new System.InvalidCastException("Item in rule binding list is not a RuleBinding");
                }

                RuleBinding binding = (RuleBinding) o;
                if (binding.Active && binding.appliesToVersion(theVersion) && binding.appliesToScope(theTypeName))
                {
                    active.Add(binding.Rule);
                }
            }
            return (PrimitiveTypeRule[]) SupportClass.ICollectionSupport.ToArray(active, new PrimitiveTypeRule[0]);
        }
Esempio n. 7
0
 /// <summary>Parses a primitive type by filling it with text child, if any </summary>
 private void parsePrimitive(Primitive datatypeObject, System.Xml.XmlElement datatypeElement)
 {
     //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
     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);
                     }
                 }
             }
                 //UPGRADE_TODO: Class 'org.w3c.dom.DOMException' was converted to 'System.Exceptiont' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
             catch (System.Exception e)
             {
                 log.error("Error parsing primitive value from TEXT_NODE", e);
             }
             full = true;
         }
     }
 }
Esempio n. 8
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);
                }
                    //UPGRADE_TODO: Class 'org.w3c.dom.DOMException' was converted to 'System.Exceptiont' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                catch (System.Exception e)
                {
                    throw new DataTypeException("DOMException encoding Primitive: ", e);
                }
            }
            return hasValue;
        }
Esempio n. 9
0
 private static System.String encodePrimitive(Primitive p, EncodingCharacters encodingChars)
 {
     System.String val = ((Primitive) p).Value;
     if (val == null)
     {
         val = "";
     }
     else
     {
         val = Escape.escape(val, encodingChars);
     }
     return val;
 }
Esempio n. 10
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>
        protected virtual Control encode(Type source, EncodingCharacters encodingChars)
        {
            if (source is ca.uhn.hl7v2.model.Composite)
            {
                TableCell td;
                TableRow  tr;
                Table     tbl = new Table();
                tbl.Attributes["border"] = _componentBorder.ToString();
                tbl.CellSpacing          = _componentCellSpacing;
                tbl.CellPadding          = _componentCellPadding;
                for (int i = 1; i <= Terser.numComponents(source); i++)
                {
                    for (int j = 1; j <= Terser.numSubComponents(source, i); j++)
                    {
                        tr = new TableRow();
                        Primitive p    = Terser.getPrimitive(source, i, j);
                        Type      type = (Type)p;
                        td = new TableCell();
                        if (_cssComponentField != null)
                        {
                            td.CssClass = _cssComponentField;
                        }
                        string desc = "&nbsp;";
                        if (type.Description != null && type.Description.Trim().Length > 0)
                        {
                            desc = type.Description;
                        }
                        if (j > 1)
                        {
                            desc = "&nbsp;&nbsp;&nbsp;-" + desc;
                        }

                        td.Text = desc;
                        tr.Cells.Add(td);
                        string val = "&nbsp;";
                        if (p.Value != null && p.Value.Trim().Length > 0)
                        {
                            val = p.Value;
                            val = val.Replace(@"\.br\", "<BR>");
                        }
                        td      = new TableCell();
                        td.Text = val;
                        tr.Cells.Add(td);
                        tbl.Rows.Add(tr);
                    }
                }
                return(tbl);
            }
            else
            {
                Primitive p   = Terser.getPrimitive(source, 1, 1);
                string    val = "&nbsp;";

                if (p.Value != null && p.Value.Trim().Length > 0)
                {
                    val = p.Value;
                    val = val.Replace(@"\.br\", "<BR>");
                }
                return(new LiteralControl(val));
            }
        }