Exemplo n.º 1
0
 private void  parseTableFile(System.String filename)
 {
     try
     {
         //UPGRADE_TODO: Method 'javax.xml.parsers.SAXParser.getXMLReader' was converted to 'SupportClass.XmlSAXDocumentManager' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
         XmlSAXDocumentManager parser = XmlSAXDocumentManager.CloneInstance(XmlSAXDocumentManager.NewInstance());
         //UPGRADE_ISSUE: Class hierarchy differences between 'java.io.Reader' and 'System.IO.StreamReader' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
         //UPGRADE_TODO: Constructor 'java.io.FileReader.FileReader' was converted to 'System.IO.StreamReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
         System.IO.StreamReader r = new System.IO.StreamReader(filename, System.Text.Encoding.Default);
         parser.setContentHandler(this);
         parser.parse(new XmlSourceSupport(r));
     }
     //UPGRADE_ISSUE: Class 'javax.xml.parsers.ParserConfigurationException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxxmlparsersParserConfigurationException'"
     catch (javax.xml.parsers.ParserConfigurationException err)
     {
         System.Console.Out.WriteLine("Error while parsing XML in table.xml");
         SupportClass.WriteStackTrace(err, Console.Error);
     }
     //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
     catch (System.Xml.XmlException err)
     {
         System.Console.Out.WriteLine("Error while parsing XML in table.xml");
         SupportClass.WriteStackTrace(err, Console.Error);
     }
     catch (System.IO.IOException err)
     {
         System.Console.Out.WriteLine("Error while reading file table.xml");
         SupportClass.WriteStackTrace(err, Console.Error);
     }
 }
Exemplo n.º 2
0
 public MatchesParser(System.String[] commentaries)
 {
     dateDriven = false;
     vMatches   = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
     for (int i = 0; i < commentaries.Length; i++)
     {
         try
         {
             //UPGRADE_TODO: Method 'javax.xml.parsers.SAXParser.getXMLReader' was converted to 'SupportClass.XmlSAXDocumentManager' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
             XmlSAXDocumentManager parser = XmlSAXDocumentManager.CloneInstance(XmlSAXDocumentManager.NewInstance());
             //UPGRADE_ISSUE: Class hierarchy differences between 'java.io.Reader' and 'System.IO.StreamReader' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
             //UPGRADE_TODO: Constructor 'java.io.FileReader.FileReader' was converted to 'System.IO.StreamReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
             System.IO.StreamReader r = new System.IO.StreamReader(commentaries[i], System.Text.Encoding.Default);
             parser.setContentHandler(this);
             parser.parse(new XmlSourceSupport(r));
         }
         //UPGRADE_ISSUE: Class 'javax.xml.parsers.ParserConfigurationException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxxmlparsersParserConfigurationException'"
         catch (javax.xml.parsers.ParserConfigurationException err)
         {
             System.Console.Out.WriteLine("Error while parsing XML in " + commentaries[i] + " file");
             SupportClass.WriteStackTrace(err, Console.Error);
         }
         //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
         catch (System.Xml.XmlException err)
         {
             System.Console.Out.WriteLine("Error while parsing XML in " + commentaries[i] + " file");
             SupportClass.WriteStackTrace(err, Console.Error);
         }
         catch (System.IO.IOException err)
         {
             System.Console.Out.WriteLine("Error while reading " + commentaries[i] + ".xml file");
             SupportClass.WriteStackTrace(err, Console.Error);
         }
     }
 }
Exemplo n.º 3
0
            public virtual void  load()
            {
                if (loaded)
                {
                    return;
                }
                try
                {
                    System.IO.Stream      inStream = new System.IO.BufferedStream(System.Net.WebRequest.Create(this.url).GetResponse().GetResponseStream());
                    XmlSAXDocumentManager factory  = XmlSAXDocumentManager.NewInstance();
                    factory.NamespaceAllowed = false;                     // FIXME

                    XLRHandler   xmlHandler   = new XLRHandler(Enclosing_Instance.nodedict, prefix);
                    CDATAHandler cdataHandler = new CDATAHandler(xmlHandler);

                    XmlSAXDocumentManager parser = XmlSAXDocumentManager.CloneInstance(factory);
                    //UPGRADE_TODO: Method 'javax.xml.parsers.SAXParser.setProperty' was converted to 'XmlSAXDocumentManager.setProperty' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxxmlparsersSAXParsersetProperty_javalangString_javalangObject'"
                    parser.setProperty("http://xml.org/sax/properties/lexical-handler", cdataHandler);
                    parser.parse(inStream, xmlHandler);
                }
                catch (System.Exception e)
                {
                    SupportClass.WriteStackTrace(e, Console.Error);
                }
                loaded = true;
            }
Exemplo n.º 4
0
        //UPGRADE_ISSUE: Class hierarchy differences between 'java.io.Reader' and 'System.IO.StreamReader' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
        public static Dictionary unmarshal(System.IO.StreamReader reader)
        {
            //LoggingTool //logger = new LoggingTool(typeof(Dictionary));
            DictionaryHandler     handler = new DictionaryHandler();
            XmlSAXDocumentManager parser  = null;

            try
            {
                parser = XmlSAXDocumentManager.NewInstance();
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                //logger.debug("Using " + parser);
            }
            catch (System.Exception e)
            {
                //logger.error("Could not instantiate any JAXP parser!");
                //logger.debug(e);
            }

            try
            {
                parser.setFeature("http://xml.org/sax/features/validation", false);
                //logger.debug("Deactivated validation");
            }
            //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            catch (System.Xml.XmlException e)
            {
                //logger.warn("Cannot deactivate validation.");
                //logger.debug(e);
            }
            parser.setContentHandler(handler);
            Dictionary dict = null;

            try
            {
                parser.parse(new XmlSourceSupport(reader));
                dict = handler.Dictionary;
            }
            catch (System.IO.IOException e)
            {
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                //logger.error("IOException: " + e.ToString());
                //logger.debug(e);
            }
            //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            catch (System.Xml.XmlException saxe)
            {
                //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'"
                //logger.error("SAXException: " + saxe.GetType().FullName);
                //logger.debug(saxe);
            }
            return(dict);
        }
Exemplo n.º 5
0
        //[STAThread]
        //public static void  Main(string[] args)
        //{
        //    //UPGRADE_ISSUE: Constructor 'java.text.SimpleDateFormat.SimpleDateFormat' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javatextSimpleDateFormat'"
        //    //UPGRADE_TODO: The equivalent in .NET for method 'java.util.Calendar.getTime' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
        //    System.Console.Out.WriteLine(Version.Name + " Language.dat Importer Version " + Version.getVersion() + " - " + Version.Codename + " (" + SupportClass.FormatDateTime(new SimpleDateFormat("dd MMM yyyy"), SupportClass.CalendarManager.manager.GetDateTime(Version.LastBuild)) + ")\r\n" + Version.Features + "\r\n" + Version.Author);
        //    try
        //    {
        //        convertFromESMS(new System.IO.FileInfo(args[0]), new System.IO.FileInfo(args[1]));
        //    }
        //    catch (System.IO.IOException err)
        //    {
        //        //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
        //        System.Console.Out.WriteLine(err.ToString());
        //    }
        //}

        //private static void  convertFromESMS(System.IO.FileInfo source, System.IO.FileInfo destination)
        //{
        //    //UPGRADE_TODO: The differences in the expected value  of parameters for constructor 'java.io.BufferedReader.BufferedReader'  may cause compilation errors.  "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'"
        //    //UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'"
        //    //UPGRADE_TODO: Constructor 'java.io.FileReader.FileReader' was converted to 'System.IO.StreamReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
        //    System.IO.StreamReader read = new System.IO.StreamReader(new System.IO.StreamReader(source.FullName, System.Text.Encoding.Default).BaseStream, new System.IO.StreamReader(source.FullName, System.Text.Encoding.Default).CurrentEncoding);
        //    //UPGRADE_TODO: Constructor 'java.io.OutputStreamWriter.OutputStreamWriter' was converted to 'System.IO.StreamWriter.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioOutputStreamWriterOutputStreamWriter_javaioOutputStream_javalangString'"
        //    //UPGRADE_TODO: Constructor 'java.io.FileOutputStream.FileOutputStream' was converted to 'System.IO.FileStream.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileOutputStreamFileOutputStream_javaioFile'"
        //    System.IO.StreamWriter w = new System.IO.StreamWriter(new System.IO.FileStream(destination.FullName, System.IO.FileMode.Create), System.Text.Encoding.GetEncoding("iso-8859-1"));

        //    w.Write("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
        //    w.Write("<Language>");
        //    Pattern p = Pattern.compile("\\[([A-Z,_]*)\\]\\ \\{\\\\n\\ *(...|.*)(.*)\\}");
        //    string text;
        //    while (read.Peek() != -1 && (text = read.ReadLine()) != null)
        //    {
        //        //String text = read.readLine();
        //        Matcher m = p.matcher(text);
        //        while (!m.matches())
        //        {
        //            if (!(read.Peek() != -1))
        //            {
        //                w.Write("</Language>");
        //                w.Flush();
        //                w.Close();
        //                return ;
        //            }
        //            text = read.ReadLine();
        //            m = p.matcher(text);
        //        }
        //        w.Write("<Comment type=\"" + m.group(1) + "\" followup=\"");
        //        w.Write(Boolean.toString(m.group(2).equals("...")) + "\">");
        //        if (!m.group(2).equals("..."))
        //            w.write(m.group(2));
        //        w.write(m.group(3));
        //        w.Write("</Comment>");
        //        w.Write("\r\n");
        //        w.Flush();
        //    }
        //    w.Write("</Language>");
        //    w.Flush();
        //    w.Close();
        //}

        /// <summary>Creates a new instance of Comment </summary>
        private Comment(string fileName)
        {
            throw new NotImplementedException("Error en ESMS.Comment.Comment(string fileName) - HZ: este metodo no se si sirve de mucho, ver donde se utiliza. Cambiar el XML por el DAL.");

            /* Usually this function is called
             *          from inside the ESMS so the RandomGenerator has been already
             *          instantiated but, just in case, if the RandomGenerator has still to be
             *          instantiated we will raise an instance with randomized seed */
            //      try
            //      {
            _rnd = CSEsMS.ESMS.ESMS.Random;
            //      }
            //      catch(NullPointerException err)
            //      {
            //          ESMS.setRandomEngine();
            //          _rnd = ESMS.getRandom();
            //      }

            _table    = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
            _tagStack = new System.Collections.ArrayList();

            try
            {
                //UPGRADE_TODO: Method 'javax.xml.parsers.SAXParser.getXMLReader' was converted to 'SupportClass.XmlSAXDocumentManager' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                XmlSAXDocumentManager parser = XmlSAXDocumentManager.CloneInstance(XmlSAXDocumentManager.NewInstance());
                //UPGRADE_ISSUE: Class hierarchy differences between 'java.io.Reader' and 'System.IO.StreamReader' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
                //UPGRADE_TODO: Constructor 'java.io.FileReader.FileReader' was converted to 'System.IO.StreamReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                System.IO.StreamReader r = new System.IO.StreamReader(fileName, System.Text.Encoding.Default);
                parser.setContentHandler(this);
                parser.parse(new XmlSourceSupport(r));
            }
            //UPGRADE_ISSUE: Class 'javax.xml.parsers.ParserConfigurationException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxxmlparsersParserConfigurationException'"
            //catch (javax.xml.parsers.ParserConfigurationException err)
            catch (Exception err)
            {
                System.Console.Out.WriteLine("Error while parsing XML in language.xml");
                SupportClass.WriteStackTrace(err, Console.Error);
            }
            //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            //catch (System.Xml.XmlException err)
            //{
            //    System.Console.Out.WriteLine("Error while parsing XML in language.xml");
            //    SupportClass.WriteStackTrace(err, Console.Error);
            //}
            //catch (System.IO.IOException err)
            //{
            //    System.Console.Out.WriteLine("Error while reading file language.xml");
            //    SupportClass.WriteStackTrace(err, Console.Error);
            //}
        }
Exemplo n.º 6
0
        /// <summary>Creates a new instance of League </summary>
        public League(System.String fileName, System.String fixtures)
        {
            vTeams   = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
            tagStack = new System.Collections.ArrayList();

            try
            {
                //UPGRADE_TODO: Method 'javax.xml.parsers.SAXParser.getXMLReader' was converted to 'SupportClass.XmlSAXDocumentManager' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                XmlSAXDocumentManager parser = XmlSAXDocumentManager.CloneInstance(XmlSAXDocumentManager.NewInstance());
                //UPGRADE_ISSUE: Class hierarchy differences between 'java.io.Reader' and 'System.IO.StreamReader' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
                //UPGRADE_TODO: Constructor 'java.io.FileReader.FileReader' was converted to 'System.IO.StreamReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                System.IO.StreamReader r = new System.IO.StreamReader(fileName, System.Text.Encoding.Default);
                parser.setContentHandler(this);
                parser.parse(new XmlSourceSupport(r));
            }
            //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            catch (System.Xml.XmlException err)
            {
                System.Console.Out.WriteLine("Error while parsing XML in " + fileName + ".xml file");
                SupportClass.WriteStackTrace(err, Console.Error);
            }
            catch (System.IO.IOException err)
            {
                System.Console.Out.WriteLine("Error while reading " + fileName + ".xml file");
                SupportClass.WriteStackTrace(err, Console.Error);
            }

            //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
            for (System.Collections.IEnumerator e = vTeams.Values.GetEnumerator(); e.MoveNext();)
            {
                //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
                ((Team)e.Current).Clean();
            }

            FixturesParser parser2 = new FixturesParser(fixtures);

            Engine.Match[] m = parser2.Matches;
            for (int i = 0; i < m.Length; i++)
            {
                Team home = (Team)vTeams[m[i].HomeTeam];
                Team away = (Team)vTeams[m[i].AwayTeam];

                if (m[i].hasBeenPlayed())
                {
                    home.addMatch(m[i].HomeScore, m[i].AwayScore);
                    away.addMatch(m[i].AwayScore, m[i].HomeScore);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>parse message according to our HL7 XML handler, and dump the data found
        /// to props.
        /// </summary>
        /// <summary>returns true if we parsed ok, which means well-formed XML, and
        /// that's about it.  We just barely check against HL7 structure, and ignore any
        /// elements / text that is unexpected (that is, impossible in any HL7 message:
        /// independant of any message / segment definitions).
        /// "message" should be an XML document with one top-level element -- that being
        /// the message.  (<ACK> or whatever).  We're only expecting one message to be in
        /// "message".
        /// props can be null if you don't want the data (we still parse).  The message
        /// data found in message (that passes msgMask) will be added to props as key /
        /// value pairs with the key a toString() of the appropriate DatumPath for the
        /// location where the data is found (i.e. in the ZYX[a]-b[c]-d-e style), and
        /// the value the corresponding text.  So, after calling parseMessage
        /// successfully, if you wanted to retrieve the message data from props you
        /// might call something like
        /// props.getProperty((new DatumPath()).add("MSH").add(1).toString())
        /// and that would return a String with "|", probably.
        /// Note that this package facilitates the extraction of message data in a way
        /// independent of message version (i.e. components and whatever getting added):
        /// With a message of "<FOO><ZYX><ZYX.42>fieldy-field-field</ZYX.42></ZYX></FOO>",
        /// "ZYX[0]-1[0]-1-1" will be the key that ends up in props (see notes at
        /// DatumPath.toString())
        /// So if you, coding for a future version of the FOO message but
        /// recieving old-version message data, tried
        /// props.getProperty((new DatumPath()).add("ZYX").add(0).add(42).add(0).add(1).toString())
        /// with the message above (that is, trying to extract a repetition and
        /// component that aren't there), you would get "ZYX[0]-42[0]-1-1" mapping to
        /// "fieldy-field-field" in the resulting props.
        /// If the message was
        /// "<FOO><ZYX><ZYX.42><ARG.1>component data</ARG.1></ZYX.42></ZYX></FOO>"
        /// and you, coding for an old version of this FOO message but recieving
        /// new-version FOO message data, tried
        /// props.getProperty((new DatumPath()).add("ZYX").add(0).add(42).toString())
        /// you would get "ZYX[0]-42[0]-1-1" mapping to "component data" in the resulting
        /// props.
        /// msgMask lets you specify which parts of the message you want dumped to props.
        /// Passing in null gets you everything.  Otherwise, msgMask's elements should
        /// all be DatumPaths (! => ClassCastException), and a particular part of the
        /// message will be dumped to props only if it's location, as represented by a
        /// DatumPath, startsWith (as in DatumPath.startsWith()) at least one element of
        /// msgMask.  So if one element of msgMask was a (new DatumPath()).add(new
        /// String("ZYX")), then everything in all ZYX segment would get dumped to props.
        /// A (new DatumPath()).add(new String("ZYX")).add(1) would get only the first
        /// repetitions of same (if there is one) dumped to props.  etc. etc.  Note that
        /// a DatumPath of size() == 0 in msgMask will get you everything, no matter what
        /// the other elements of msgMask are, because all DatumPaths startsWith the
        /// zero-length DatumPath.
        /// Segment group elements (eg. ADT_A01.PROCEDURE) are handled fine, but they
        /// aren't addressed in msgMask or in the output in props -- basically any
        /// element tags at the level immediately inside the message element, and having
        /// a name that starts with the message element name + '.', is ignored (meaning
        /// it's contents are dealt with the same as if the start and end tags' just
        /// wasn't there.)
        /// </summary>
        public static bool parseMessage(System.Collections.Specialized.NameValueCollection props, System.String message, System.Collections.ICollection msgMask)
        {
            bool ret = false;

            try
            {
                XmlSAXDocumentManager factory = XmlSAXDocumentManager.NewInstance();
                XmlSAXDocumentManager parser  = XmlSAXDocumentManager.CloneInstance(factory);

                XmlSourceSupport inSrc = new XmlSourceSupport(new System.IO.MemoryStream(new System.Text.ASCIIEncoding().GetBytes(message)));

                HL7MessageHandler handler = new HL7MessageHandler();
                handler.m_props = (props != null?props:new System.Collections.Specialized.NameValueCollection());                 // it's expecting a props.

                if (msgMask != null)
                {
                    handler.m_msgMask = msgMask;
                }
                else
                {
                    handler.m_msgMask = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
                    SupportClass.ICollectionSupport.Add(handler.m_msgMask, new NuGenDatumPath());
                }

                parser.parse(inSrc, handler);
                ret = true;
            }
            catch (System.IO.IOException e)
            {
                throw new NuGenHL7Exception(e);
            }
            catch (StopParsingException e)
            {
                throw new NuGenHL7Exception(e);
            }
            catch (System.Xml.XmlException e)
            {
                throw new NuGenHL7Exception(e);
            }

            return(ret);
        }
Exemplo n.º 8
0
 public MatchesParser(System.String dirbase)
 {
     vMatches = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
     initDate();
     System.IO.FileInfo f = new System.IO.FileInfo(dirbase);
     //UPGRADE_TODO: The equivalent in .NET for method 'java.io.File.list' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
     System.String[] xmlfiles = System.IO.Directory.GetFileSystemEntries(f.FullName);
     for (int i = 0; i < xmlfiles.Length; i++)
     {
         if (xmlfiles[i].ToLower().EndsWith(".xml"))
         {
             try
             {
                 //UPGRADE_TODO: Method 'javax.xml.parsers.SAXParser.getXMLReader' was converted to 'SupportClass.XmlSAXDocumentManager' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                 XmlSAXDocumentManager parser = XmlSAXDocumentManager.CloneInstance(XmlSAXDocumentManager.NewInstance());
                 //UPGRADE_ISSUE: Class hierarchy differences between 'java.io.Reader' and 'System.IO.StreamReader' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
                 //UPGRADE_TODO: Constructor 'java.io.FileReader.FileReader' was converted to 'System.IO.StreamReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                 System.IO.StreamReader r = new System.IO.StreamReader(xmlfiles[i], System.Text.Encoding.Default);
                 parser.setContentHandler(this);
                 parser.parse(new XmlSourceSupport(r));
             }
             //UPGRADE_ISSUE: Class 'javax.xml.parsers.ParserConfigurationException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxxmlparsersParserConfigurationException'"
             catch (javax.xml.parsers.ParserConfigurationException err)
             {
                 System.Console.Out.WriteLine("Error while parsing XML in " + xmlfiles[i] + " file");
                 SupportClass.WriteStackTrace(err, Console.Error);
             }
             //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
             catch (System.Xml.XmlException err)
             {
                 System.Console.Out.WriteLine("Error while parsing XML in " + xmlfiles[i] + " file");
                 SupportClass.WriteStackTrace(err, Console.Error);
             }
             catch (System.IO.IOException err)
             {
                 System.Console.Out.WriteLine("Error while reading " + xmlfiles[i] + ".xml file");
                 SupportClass.WriteStackTrace(err, Console.Error);
             }
         }
     }
 }
Exemplo n.º 9
0
        /// <summary>Creates a new instance of Fixtures </summary>
        public Fixtures(System.String tableFile, System.String output)
        {
            vTeams = new System.Collections.ArrayList();
            try
            {
                //UPGRADE_TODO: Method 'javax.xml.parsers.SAXParser.getXMLReader' was converted to 'SupportClass.XmlSAXDocumentManager' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                XmlSAXDocumentManager parser = XmlSAXDocumentManager.CloneInstance(XmlSAXDocumentManager.NewInstance());
                //UPGRADE_ISSUE: Class hierarchy differences between 'java.io.Reader' and 'System.IO.StreamReader' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'"
                //UPGRADE_TODO: Constructor 'java.io.FileReader.FileReader' was converted to 'System.IO.StreamReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                System.IO.StreamReader r = new System.IO.StreamReader(tableFile, System.Text.Encoding.Default);
                parser.setContentHandler(this);
                parser.parse(new XmlSourceSupport(r));
            }
            //UPGRADE_ISSUE: Class 'javax.xml.parsers.ParserConfigurationException' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxxmlparsersParserConfigurationException'"
            catch (javax.xml.parsers.ParserConfigurationException err)
            {
                System.Console.Out.WriteLine("Error while parsing XML in " + tableFile + " file");
                SupportClass.WriteStackTrace(err, Console.Error);
            }
            //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            catch (System.Xml.XmlException err)
            {
                System.Console.Out.WriteLine("Error while parsing XML in " + tableFile + " file");
                SupportClass.WriteStackTrace(err, Console.Error);
            }
            catch (System.IO.IOException err)
            {
                System.Console.Out.WriteLine("Error while reading " + tableFile + " file");
                SupportClass.WriteStackTrace(err, Console.Error);
            }

            IGenerator gen = new LeagueGenerator();

            gen.Generate(Teams, cname, wname);
            if (seed)
            {
                PunkBuster.GenerateSeeds(gen);
            }
            gen.WriteCompetition(output);
        }
Exemplo n.º 10
0
        /// <summary> Triggers the XML parsing of the data file and returns the read Isotopes.
        /// It turns of XML validation before parsing.
        ///
        /// </summary>
        /// <returns> a Vector of Isotope's. Returns an empty vector is some reading error
        /// occured.
        /// </returns>
        public virtual List <PeriodicTableElement> readElements()
        {
            List <PeriodicTableElement> elements = new List <PeriodicTableElement>();

            try
            {
                parser.setFeature("http://xml.org/sax/features/validation", false);
                //logger.info("Deactivated validation");
            }
            //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            catch (System.Xml.XmlException exception)
            {
                //logger.warn("Cannot deactivate validation: ", exception.Message);
                //logger.debug(exception);
            }
            ElementPTHandler handler = new ElementPTHandler();

            parser.setContentHandler(handler);
            try
            {
                parser.parse(new XmlSourceSupport(input));
                elements = new List <PeriodicTableElement>((PeriodicTableElement[])handler.Elements.ToArray(typeof(PeriodicTableElement)));
            }
            catch (System.IO.IOException exception)
            {
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                //logger.error("IOException: ", exception.Message);
                //logger.debug(exception);
            }
            //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            catch (System.Xml.XmlException saxe)
            {
                //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'"
                //logger.error("SAXException: ", saxe.GetType().FullName);
                //logger.error(saxe.Message);
                //logger.debug(saxe);
            }
            return(elements);
        }
Exemplo n.º 11
0
        /// <summary> Triggers the XML parsing of the data file and returns the read Isotopes.
        /// It turns of XML validation before parsing.
        ///
        /// </summary>
        /// <returns> a Vector of Isotope's. Returns an empty vector is some reading error
        /// occured.
        /// </returns>
        public virtual System.Collections.ArrayList readIsotopes()
        {
            System.Collections.ArrayList isotopes = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
            try
            {
                parser.setFeature("http://xml.org/sax/features/validation", false);
                //logger.info("Deactivated validation");
            }
            //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            catch (System.Xml.XmlException exception)
            {
                //logger.warn("Cannot deactivate validation: ", exception.Message);
                //logger.debug(exception);
            }
            IsotopeHandler handler = new IsotopeHandler(builder);

            parser.setContentHandler(handler);
            try
            {
                parser.parse(new XmlSourceSupport(input));
                isotopes = handler.Isotopes;
            }
            catch (System.IO.IOException exception)
            {
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                //logger.error("IOException: ", exception.Message);
                //logger.debug(exception);
            }
            //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            catch (System.Xml.XmlException saxe)
            {
                //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'"
                //logger.error("SAXException: ", saxe.GetType().FullName);
                //logger.error(saxe.Message);
                //logger.debug(saxe);
            }
            return(isotopes);
        }
Exemplo n.º 12
0
        // private functions

        private IChemFile readChemFile(IChemFile file)
        {
            //logger.debug("Started parsing from input...");
            ChemFileCDO cdo = new ChemFileCDO(file);

            try
            {
                parser.setFeature("http://xml.org/sax/features/validation", false);
                //logger.info("Deactivated validation");
            }
            //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            catch (System.Xml.XmlException e)
            {
                //logger.warn("Cannot deactivate validation.");
                return(cdo);
            }
            parser.setContentHandler(new CMLHandler((IChemicalDocumentObject)cdo));
            parser.setEntityResolver(new CMLResolver());
            //UPGRADE_TODO: Method 'org.xml.sax.XMLReader.setErrorHandler' was converted to 'XmlSAXDocumentManager.SetErrorHandler' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_orgxmlsaxXMLReadersetErrorHandler_orgxmlsaxErrorHandler'"
            parser.setErrorHandler(new CMLErrorHandler());
            try
            {
                if (input == null)
                {
                    //logger.debug("Parsing from URL: ", url);
                    parser.parse(url);
                }
                else
                {
                    //logger.debug("Parsing from Reader");
                    input.BaseStream.Seek(0, SeekOrigin.Begin);
                    parser.parse(new XmlSourceSupport(input));
                }
            }
            catch (System.IO.IOException e)
            {
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                System.String error = "Error while reading file: " + e.Message;
                //logger.error(error);
                //logger.debug(e);
                throw new CDKException(error, e);
            }
            //UPGRADE_TODO: Class 'org.xml.sax.SAXParseException' was converted to 'System.xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            catch (System.Xml.XmlException saxe)
            {
                //UPGRADE_TODO: Class 'org.xml.sax.SAXParseException' was converted to 'System.xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                System.Xml.XmlException spe   = (System.Xml.XmlException)saxe;
                System.String           error = "Found well-formedness error in line " + spe.LineNumber;
                //logger.error(error);
                //logger.debug(saxe);
                throw new CDKException(error, saxe);
            }
            //UPGRADE_TODO: Class 'org.xml.sax.SAXException' was converted to 'System.Xml.XmlException' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            //catch (System.Xml.XmlException saxe)
            //{
            //    System.String error = "Error while parsing XML: " + saxe.Message;
            //    //logger.error(error);
            //    //logger.debug(saxe);
            //    throw new CDKException(error, saxe);
            //}
            return(cdo);
        }