Beispiel #1
0
        /// <summary> Note that the validation context of the resulting message is set to this parser's validation
        /// context.  The validation context is used within Primitive.setValue().
        ///
        /// </summary>
        /// <param name="name">name of the desired structure in the form XXX_YYY
        /// </param>
        /// <param name="version">HL7 version (e.g. "2.3")
        /// </param>
        /// <param name="isExplicit">true if the structure was specified explicitly in MSH-9-3, false if it
        /// was inferred from MSH-9-1 and MSH-9-2.  If false, a lookup may be performed to find
        /// an alternate structure corresponding to that message type and event.
        /// </param>
        /// <returns> a Message instance
        /// </returns>
        /// <throws>  HL7Exception if the version is not recognized or no appropriate class can be found or the Message  </throws>
        /// <summary>      class throws an exception on instantiation (e.g. if args are not as expected)
        /// </summary>
        protected internal virtual Message instantiateMessage(System.String theName, System.String theVersion, bool isExplicit)
        {
            Message result = null;

            try
            {
                System.Type messageClass = myFactory.getMessageClass(theName, theVersion, isExplicit);
                if (messageClass == null)
                {
                    //UPGRADE_NOTE: Exception 'java.lang.ClassNotFoundException' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"
                    throw new System.Exception("Can't find message class in current package list: " + theName);
                }
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                log.info("Instantiating msg of class " + messageClass.FullName);
                System.Reflection.ConstructorInfo constructor = messageClass.GetConstructor(new System.Type[] { typeof(ModelClassFactory) });
                result = (Message)constructor.Invoke(new System.Object[] { myFactory });
            }
            catch (System.Exception e)
            {
                throw new HL7Exception("Couldn't create Message object of type " + theName, HL7Exception.UNSUPPORTED_MESSAGE_TYPE, e);
            }

            result.ValidationContext = myContext;

            return(result);
        }