private Dictionary readDictionary(System.String databaseLocator, System.String type)
        {
            Dictionary dictionary = null;

            databaseLocator += ("." + type);
            //logger.info("Reading dictionary from ", databaseLocator);
            try
            {
                System.IO.StreamReader reader = new System.IO.StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("NuGenCDKSharp." + databaseLocator));
                //new System.IO.StreamReader(this.GetType().getClassLoader().getResourceAsStream(databaseLocator), System.Text.Encoding.Default);
                if (type.Equals("owl"))
                {
                    dictionary = OWLFile.unmarshal(reader);
                }
                else
                {
                    // assume XML using Castor
                    dictionary = Dictionary.unmarshal(reader);
                }
            }
            catch (System.Exception exception)
            {
                dictionary = null;
                //logger.error("Could not read dictionary ", databaseLocator);
                //logger.debug(exception);
            }
            return(dictionary);
        }
Beispiel #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 new Dictionary unmarshal(System.IO.StreamReader reader)
        {
            //LoggingTool //logger = new LoggingTool(typeof(OWLFile));
            Dictionary dict = new OWLFile();

            try
            {
                //Builder parser = new Builder();
                XmlDocument doc = new XmlDocument();          //parser.build(reader);
                doc.Load(reader);
                XmlElement root = (XmlElement)doc.FirstChild; // getRootElement();
                //logger.debug("Found root element: ", root.getQualifiedName());

                // Extract ownNS from root element
                //            final String ownNS = root.getBaseURI();
                //UPGRADE_NOTE: Final was removed from the declaration of 'ownNS '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
                System.String ownNS = root.BaseURI;// getBaseURI();
                dict.NS = ownNS;

                //logger.debug("Found ontology namespace: ", ownNS);

                // process the defined facts
                XmlNodeList entries = root.ChildNodes;
                //logger.info("Found #elements in OWL dict:", entries.size());
                for (int i = 0; i < entries.Count; i++)
                {
                    XmlElement entry = (XmlElement)entries.Item(i);// get_Renamed(i);
                    if (entry.NamespaceURI.Equals(ownNS))
                    {
                        Entry dbEntry = unmarshal(entry, ownNS);
                        dict.addEntry(dbEntry);
                        //logger.debug("Added entry: ", dbEntry);
                    }
                    else
                    {
                        //logger.debug("Found a non-fact: ", entry.getQualifiedName());
                    }
                }
            }
            //catch (ParsingException ex)
            //{
            //    //logger.error("Dictionary is not well-formed: ", ex.getMessage());
            //    //logger.debug("Error at line " + ex.getLineNumber(), ", column " + ex.getColumnNumber());
            //    dict = null;
            //}
            catch (System.IO.IOException ex)
            {
                //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("Due to an IOException, the parser could not check:", ex.Message);
                //logger.debug(ex);
                dict = null;
            }
            return(dict);
        }
Beispiel #3
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 new Dictionary unmarshal(System.IO.StreamReader reader)
        {
            //LoggingTool //logger = new LoggingTool(typeof(OWLFile));
            Dictionary dict = new OWLFile();
            try
            {
                //Builder parser = new Builder();
                XmlDocument doc = new XmlDocument();//parser.build(reader);
                doc.Load(reader);
                XmlElement root = (XmlElement)doc.FirstChild;// getRootElement();
                //logger.debug("Found root element: ", root.getQualifiedName());

                // Extract ownNS from root element
                //            final String ownNS = root.getBaseURI();
                //UPGRADE_NOTE: Final was removed from the declaration of 'ownNS '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
                System.String ownNS = root.BaseURI;// getBaseURI();
                dict.NS = ownNS;

                //logger.debug("Found ontology namespace: ", ownNS);

                // process the defined facts
                XmlNodeList entries = root.ChildNodes;
                //logger.info("Found #elements in OWL dict:", entries.size());
                for (int i = 0; i < entries.Count; i++)
                {
                    XmlElement entry = (XmlElement)entries.Item(i);// get_Renamed(i);
                    if (entry.NamespaceURI.Equals(ownNS))
                    {
                        Entry dbEntry = unmarshal(entry, ownNS);
                        dict.addEntry(dbEntry);
                        //logger.debug("Added entry: ", dbEntry);
                    }
                    else
                    {
                        //logger.debug("Found a non-fact: ", entry.getQualifiedName());
                    }
                }
            }
            //catch (ParsingException ex)
            //{
            //    //logger.error("Dictionary is not well-formed: ", ex.getMessage());
            //    //logger.debug("Error at line " + ex.getLineNumber(), ", column " + ex.getColumnNumber());
            //    dict = null;
            //}
            catch (System.IO.IOException ex)
            {
                //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("Due to an IOException, the parser could not check:", ex.Message);
                //logger.debug(ex);
                dict = null;
            }
            return dict;
        }