Esempio n. 1
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (GetType() != obj.GetType())
            {
                return(false);
            }
            DataFormatEntry objC = (DataFormatEntry)obj;

            return(((ReferenceEquals(dataFormatEntryName, null)) ? ReferenceEquals(objC.dataFormatEntryName, null) : dataFormatEntryName.Equals(objC.dataFormatEntryName)) && ((ReferenceEquals(type, null)) ? ReferenceEquals(objC.type, null) : type.Equals(objC.type)) && ((ReferenceEquals(category, null)) ? ReferenceEquals(objC.category, null) : category.Equals(objC.category)) && ((ReferenceEquals(defaultOutput, null)) ? ReferenceEquals(objC.defaultOutput, null) : defaultOutput.Equals(objC.defaultOutput)));
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void parseDataFormatXMLfile(java.net.URL url) throws org.maltparser.core.exception.MaltChainedException
        public virtual void parseDataFormatXMLfile(URL url)
        {
            if (url == null)
            {
                throw new DataFormatException("The data format specifcation file cannot be found. ");
            }

            try
            {
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                DocumentBuilder        db  = dbf.newDocumentBuilder();

                Element root = db.parse(url.openStream()).DocumentElement;
                if (root.NodeName.Equals("dataformat"))
                {
                    dataFormatName = root.getAttribute("name");
                    if (root.getAttribute("datastructure").length() > 0)
                    {
                        dataStructure = Enum.Parse(typeof(DataStructure), root.getAttribute("datastructure").ToUpper());
                    }
                    else
                    {
                        dataStructure = DataStructure.DEPENDENCY;
                    }
                }
                else
                {
                    throw new DataFormatException("Data format specification file must contain one 'dataformat' element. ");
                }
                NodeList cols = root.getElementsByTagName("column");
                Element  col  = null;
                for (int i = 0, n = cols.Length; i < n; i++)
                {
                    col = (Element)cols.item(i);
                    DataFormatEntry entry = new DataFormatEntry(col.getAttribute("name"), col.getAttribute("category"), col.getAttribute("type"), col.getAttribute("default"));
                    entries[entry.DataFormatEntryName] = entry;
                }
                NodeList deps = root.getElementsByTagName("dependencies");
                if (deps.Length > 0)
                {
                    NodeList dep = ((Element)deps.item(0)).getElementsByTagName("dependency");
                    for (int i = 0, n = dep.Length; i < n; i++)
                    {
                        Element e = (Element)dep.item(i);
                        dependencies.add(new Dependency(this, e.getAttribute("name"), e.getAttribute("url"), e.getAttribute("map"), e.getAttribute("urlmap")));
                    }
                }
            }
            catch (java.io.IOException e)
            {
                throw new DataFormatException("Cannot find the file " + url.ToString() + ". ", e);
            }
            catch (ParserConfigurationException e)
            {
                throw new DataFormatException("Problem parsing the file " + url.ToString() + ". ", e);
            }
            catch (SAXException e)
            {
                throw new DataFormatException("Problem parsing the file " + url.ToString() + ". ", e);
            }
        }
        public virtual void addEntry(string dataFormatEntryName, string category, string type, string defaultOutput)
        {
            DataFormatEntry entry = new DataFormatEntry(dataFormatEntryName, category, type, defaultOutput);

            entries[entry.DataFormatEntryName] = entry;
        }