Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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;
 }