示例#1
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);
        }
示例#2
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;
        }