public override void startElement(System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
        {
            currentChars = "";
            if ("entry".Equals(local) && !"bibtex:entry".Equals(raw) && !inEntry)
            {
                inEntry = true;
                entry = new Entry();
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    if (atts.GetFullName(i).Equals("id"))
                    {
                        entry.ID = atts.GetValue(i);
                    }
                    else if (atts.GetFullName(i).Equals("term"))
                    {
                        entry.Label = atts.GetValue(i);
                    }
                }
            }
            if ("metadataList".Equals(local) && !inMetadataList)
            {
                inMetadataList = true;
            }

            // if we're in a metadataList then look at individual
            // metadata nodes and check for any whose content refers
            // to QSAR metadata and save that. Currently it does'nt 
            // differentiate between descriptorType or descriptorClass.
            // Do we need to differentiate?
            //
            // RG: I think so and so I save a combination of the dictRef attribute
            // and the content attribute
            if ("metadata".Equals(local) && inMetadataList)
            {
                for (int i = 0; i < atts.GetLength() - 1; i += 2)
                {

                    System.String dictRefValue = "";
                    if (atts.GetFullName(i).Equals("dictRef"))
                    {
                        dictRefValue = atts.GetValue(i);
                    }
                    if (atts.GetFullName(i + 1).Equals("content"))
                    {
                        System.String content = atts.GetValue(i + 1);
                        if (content.IndexOf("qsar-descriptors-metadata:") == 0)
                        {
                            entry.setDescriptorMetadata(dictRefValue + "/" + content);
                        }
                    }
                }
            }
        }
 public override void startElement(CMLStack xpath, System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
 {
     System.String name = local;
     if (name.Equals("list"))
     {
         //logger.debug("Oke, JMOLANIMATION seems to be kicked in :)");
         cdo.startObject("Animation");
         base.startElement(xpath, uri, local, raw, atts);
     }
     else if (name.Equals("molecule"))
     {
         cdo.startObject("Frame");
         //logger.debug("New frame being parsed.");
         base.startElement(xpath, uri, local, raw, atts);
     }
     else if (name.Equals("float"))
     {
         bool isEnergy = false;
         //logger.debug("FLOAT found!");
         for (int i = 0; i < atts.GetLength(); i++)
         {
             //logger.debug(" att: ", atts.GetFullName(i), " -> ", atts.GetValue(i));
             if (atts.GetFullName(i).Equals("title") && atts.GetValue(i).Equals("FRAME_ENERGY"))
             {
                 isEnergy = true;
             }
         }
         if (isEnergy)
         {
             // oke, this is the frames energy!
             current = ENERGY;
         }
         else
         {
             base.startElement(xpath, uri, local, raw, atts);
         }
     }
     else
     {
         base.startElement(xpath, uri, local, raw, atts);
     }
 }
 private IIsotope createIsotopeOfElement(System.String currentElement, SaxAttributesSupport atts)
 {
     IIsotope isotope = builder.newIsotope(currentElement);
     for (int i = 0; i < atts.GetLength(); i++)
     {
         try
         {
             if ("id".Equals(atts.GetFullName(i)))
             {
                 isotope.ID = atts.GetValue(i);
             }
             else if ("isotopeNumber".Equals(atts.GetFullName(i)))
             {
                 isotope.MassNumber = System.Int32.Parse(atts.GetValue(i));
             }
             else if ("elementType".Equals(atts.GetFullName(i)))
             {
                 isotope.Symbol = atts.GetValue(i);
             }
         }
         catch (System.FormatException exception)
         {
             //logger.error("Value of isotope@", atts.GetFullName(i), " is not as expected.");
             //logger.debug(exception);
         }
     }
     return isotope;
 }
 public override void startElement(System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
 {
     currentChars = "";
     dictRef = "";
     //logger.debug("startElement: ", raw);
     //logger.debug("uri: ", uri);
     //logger.debug("local: ", local);
     //logger.debug("raw: ", raw);
     if ("isotope".Equals(local))
     {
         workingIsotope = createIsotopeOfElement(currentElement, atts);
     }
     else if ("isotopeList".Equals(local))
     {
         currentElement = getElementSymbol(atts);
     }
     else if ("abundance".Equals(local))
     {
         //logger.warn("Disregarding dictRef for now...");
     }
     else if ("scalar".Equals(local))
     {
         for (int i = 0; i < atts.GetLength(); i++)
         {
             if ("dictRef".Equals(atts.GetFullName(i)))
             {
                 dictRef = atts.GetValue(i);
             }
         }
     }
 }
 public override void startElement(System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
 {
     currentChars = "";
     dictRef = "";
     //logger.debug("startElement: ", raw);
     //logger.debug("uri: ", uri);
     //logger.debug("local: ", local);
     //logger.debug("raw: ", raw);
     if ("elementType".Equals(local))
     {
         for (int i = 0; i < atts.GetLength(); i++)
         {
             if ("id".Equals(atts.GetFullName(i)))
             {
                 elementType = new PeriodicTableElement(atts.GetValue(i));
             }
         }
     }
     else if ("scalar".Equals(local))
         for (int i = 0; i < atts.GetLength(); i++)
         {
             if ("dictRef".Equals(atts.GetFullName(i)))
             {
                 if ("cas:id".Equals(atts.GetValue(i)))
                 {
                     scalarType = LABEL_CAS;
                 }
                 else if ("cdk:name".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_NAME;
                 }
                 else if ("cdk:atomicNumber".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_ATOMICNUMBER;
                 }
                 else if ("cdk:name".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_NAME;
                 }
                 else if ("cdk:chemicalSerie".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_CHEMICALSERIE;
                 }
                 else if ("cdk:period".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_PERIOD;
                 }
                 else if ("cdk:group".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_GROUP;
                 }
                 else if ("cdk:phase".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_PHASE;
                 }
             }
         }
 }
Beispiel #6
0
        public override void startElement(System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
        {
            xpath.push(local);
            //if (debug)
            //    logger.debug("<", raw, "> -> ", xpath);
            // Detect CML modules, like CRML and CCML
            if (local.StartsWith("reaction"))
            {
                // e.g. reactionList, reaction -> CRML module
                //logger.info("Detected CRML module");
                conv = new CMLReactionModule(conv);
                conventionStack.push(conventionStack.current());
            }
            else
            {
                // assume CML Core

                // Detect conventions
                System.String convName = "";
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    if (atts.GetFullName(i).Equals("convention"))
                    {
                        convName = atts.GetValue(i);
                    }
                }
                if (convName.Length > 0)
                {
                    if (convName.Equals(conventionStack.current()))
                    {
                        //logger.debug("Same convention as parent");
                    }
                    else
                    {
                        //logger.info("New Convention: ", convName);
                        if (convName.Equals("CML"))
                        {
                            /* Don't reset the convention handler to CMLCore,
                            becuase all handlers should extend this handler,
                            and use it for any content other then specifically
                            put into the specific convention */
                        }
                        else if (convName.Equals("PDB"))
                        {
                            conv = new PDBConvention(conv);
                        }
                        else if (convName.Equals("PMP"))
                        {
                            conv = new PMPConvention(conv);
                        }
                        else if (convName.Equals("MDLMol"))
                        {
                            //if (debug)
                            //    logger.debug("MDLMolConvention instantiated...");
                            conv = new MDLMolConvention(conv);
                        }
                        else if (convName.Equals("JMOL-ANIMATION"))
                        {
                            conv = new JMOLANIMATIONConvention(conv);
                        }
                        else if (userConventions.ContainsKey(convName))
                        {
                            //unknown convention. userConvention?
                            ICMLConvention newconv = (ICMLConvention)userConventions[convName];
                            newconv.inherit(conv);
                            conv = newconv;
                        }
                        else
                        {
                            //logger.warn("Detected unknown convention: ", convName);
                        }
                    }
                    conventionStack.push(convName);
                }
                else
                {
                    // no convention set/reset: take convention of parent
                    conventionStack.push(conventionStack.current());
                }
            }
            //if (debug)
            //    logger.debug("ConventionStack: ", conventionStack);
            conv.startElement(xpath, uri, local, raw, atts);
        }
 /// <summary>
 /// This method manage the event when a start element node were found
 /// </summary>
 /// <param name="namespaceURI">The namespace uri of the element tag</param>
 /// <param name="localName">The local name of the element</param>
 /// <param name="qName">The Qualify (long) name of the element</param>
 /// <param name="atts">The list of attributes of the element</param>
 public virtual void startElement(System.String uri, System.String localName, System.String qName, SaxAttributesSupport attributes)
 {
 }
 /// <summary>
 /// Creates a new instance of SaxAttributesSupport from an ArrayList of Att_Instance class.
 /// </summary>
 /// <param name="arrayList">An ArraList of Att_Instance class instances.</param>
 /// <returns>A new instance of SaxAttributesSupport</returns>
 public SaxAttributesSupport(SaxAttributesSupport List)
 {
     SaxAttributesSupport temp = new SaxAttributesSupport();
     temp.MainList = (System.Collections.ArrayList)List.MainList.Clone();
 }
 public override void startElement(CMLStack xpath, System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
 {
     if ("reaction".Equals(local))
     {
         cdo.startObject("Reaction");
         for (int i = 0; i < atts.GetLength(); i++)
         {
             System.String att = atts.GetFullName(i);
             System.String value_Renamed = atts.GetValue(i);
             if (att.Equals("id"))
             {
                 cdo.setObjectProperty("Reaction", "id", value_Renamed);
             }
         }
     }
     else if ("reactionList".Equals(local))
     {
         cdo.startObject("SetOfReactions");
         for (int i = 0; i < atts.GetLength(); i++)
         {
             System.String att = atts.GetFullName(i);
             System.String value_Renamed = atts.GetValue(i);
             if (att.Equals("id"))
             {
                 cdo.setObjectProperty("SetOfReactions", "id", value_Renamed);
             }
         }
     }
     else if ("reactant".Equals(local))
     {
         cdo.startObject("Reactant");
         for (int i = 0; i < atts.GetLength(); i++)
         {
             System.String att = atts.GetFullName(i);
             System.String value_Renamed = atts.GetValue(i);
             if (att.Equals("id"))
             {
                 cdo.setObjectProperty("Reactant", "id", value_Renamed);
             }
         }
     }
     else if ("product".Equals(local))
     {
         cdo.startObject("Product");
         for (int i = 0; i < atts.GetLength(); i++)
         {
             System.String att = atts.GetFullName(i);
             System.String value_Renamed = atts.GetValue(i);
             if (att.Equals("id"))
             {
                 cdo.setObjectProperty("Product", "id", value_Renamed);
             }
         }
     }
     else if ("molecule".Equals(local))
     {
         // do nothing for now
         base.newMolecule();
     }
     else
     {
         base.startElement(xpath, uri, local, raw, atts);
     }
 }
Beispiel #10
0
        /// <summary>
        /// Emulates the behavior of a SAX parser, it realizes the callback events of the parser.
        /// </summary>
        private void DoParsing()
        {
            System.Collections.Hashtable prefixes = new System.Collections.Hashtable();
            System.Collections.Stack stackNameSpace = new System.Collections.Stack();
            locator = new XmlSaxLocatorImpl();
            try
            {
                UpdateLocatorData(this.locator, (System.Xml.XmlTextReader)(this.reader.Reader));
                if (this.callBackHandler != null)
                    this.callBackHandler.setDocumentLocator(locator);
                if (this.callBackHandler != null)
                    this.callBackHandler.startDocument();
                while (this.reader.Read())
                {
                    UpdateLocatorData(this.locator, (System.Xml.XmlTextReader)(this.reader.Reader));
                    switch (this.reader.NodeType)
                    {
                        case System.Xml.XmlNodeType.Element:
                            bool Empty = reader.IsEmptyElement;
                            System.String namespaceURI = "";
                            System.String localName = "";
                            if (this.namespaceAllowed)
                            {
                                namespaceURI = reader.NamespaceURI;
                                localName = reader.LocalName;
                            }
                            System.String name = reader.Name;
                            SaxAttributesSupport attributes = new SaxAttributesSupport();
                            if (reader.HasAttributes)
                            {
                                for (int i = 0; i < reader.AttributeCount; i++)
                                {
                                    reader.MoveToAttribute(i);
                                    System.String prefixName = (reader.Name.IndexOf(":") > 0) ? reader.Name.Substring(reader.Name.IndexOf(":") + 1, reader.Name.Length - reader.Name.IndexOf(":") - 1) : "";
                                    System.String prefix = (reader.Name.IndexOf(":") > 0) ? reader.Name.Substring(0, reader.Name.IndexOf(":")) : reader.Name;
                                    bool IsXmlns = prefix.ToLower().Equals("xmlns");
                                    if (this.namespaceAllowed)
                                    {
                                        if (!IsXmlns)
                                            attributes.Add(reader.NamespaceURI, reader.LocalName, reader.Name, "" + reader.NodeType, reader.Value);
                                    }
                                    else
                                        attributes.Add("", "", reader.Name, "" + reader.NodeType, reader.Value);
                                    if (IsXmlns)
                                    {
                                        System.String namespaceTemp = "";
                                        namespaceTemp = (namespaceURI.Length == 0) ? reader.Value : namespaceURI;
                                        if (this.namespaceAllowed && !prefixes.ContainsKey(namespaceTemp) && namespaceTemp.Length > 0)
                                        {
                                            stackNameSpace.Push(name);
                                            System.Collections.Stack namespaceStack = new System.Collections.Stack();
                                            namespaceStack.Push(prefixName);
                                            prefixes.Add(namespaceURI, namespaceStack);
                                            if (this.callBackHandler != null)
                                                ((XmlSaxContentHandler)this.callBackHandler).startPrefixMapping(prefixName, namespaceTemp);
                                        }
                                        else
                                        {
                                            if (this.namespaceAllowed && namespaceTemp.Length > 0 && !((System.Collections.Stack)prefixes[namespaceTemp]).Contains(reader.Name))
                                            {
                                                ((System.Collections.Stack)prefixes[namespaceURI]).Push(prefixName);
                                                if (this.callBackHandler != null)
                                                    ((XmlSaxContentHandler)this.callBackHandler).startPrefixMapping(prefixName, reader.Value);
                                            }
                                        }
                                    }
                                }
                            }
                            if (this.callBackHandler != null)
                                this.callBackHandler.startElement(namespaceURI, localName, name, attributes);
                            if (Empty)
                            {
                                if (this.NamespaceAllowed)
                                {
                                    if (this.callBackHandler != null)
                                        this.callBackHandler.endElement(namespaceURI, localName, name);
                                }
                                else
                                    if (this.callBackHandler != null)
                                        this.callBackHandler.endElement("", "", name);
                            }
                            break;

                        case System.Xml.XmlNodeType.EndElement:
                            if (this.namespaceAllowed)
                            {
                                if (this.callBackHandler != null)
                                    this.callBackHandler.endElement(reader.NamespaceURI, reader.LocalName, reader.Name);
                            }
                            else
                                if (this.callBackHandler != null)
                                    this.callBackHandler.endElement("", "", reader.Name);
                            if (this.namespaceAllowed && prefixes.ContainsKey(reader.NamespaceURI) && ((System.Collections.Stack)stackNameSpace).Contains(reader.Name))
                            {
                                stackNameSpace.Pop();
                                System.Collections.Stack namespaceStack = (System.Collections.Stack)prefixes[reader.NamespaceURI];
                                while (namespaceStack.Count > 0)
                                {
                                    System.String tempString = (System.String)namespaceStack.Pop();
                                    if (this.callBackHandler != null)
                                        ((XmlSaxContentHandler)this.callBackHandler).endPrefixMapping(tempString);
                                }
                                prefixes.Remove(reader.NamespaceURI);
                            }
                            break;

                        case System.Xml.XmlNodeType.Text:
                            if (this.callBackHandler != null)
                                this.callBackHandler.characters(reader.Value.ToCharArray(), 0, reader.Value.Length);
                            break;

                        case System.Xml.XmlNodeType.Whitespace:
                            if (this.callBackHandler != null)
                                this.callBackHandler.ignorableWhitespace(reader.Value.ToCharArray(), 0, reader.Value.Length);
                            break;

                        case System.Xml.XmlNodeType.ProcessingInstruction:
                            if (this.callBackHandler != null)
                                this.callBackHandler.processingInstruction(reader.Name, reader.Value);
                            break;

                        case System.Xml.XmlNodeType.Comment:
                            if (this.lexical != null)
                                this.lexical.comment(reader.Value.ToCharArray(), 0, reader.Value.Length);
                            break;

                        case System.Xml.XmlNodeType.CDATA:
                            if (this.lexical != null)
                            {
                                lexical.startCDATA();
                                if (this.callBackHandler != null)
                                    this.callBackHandler.characters(this.reader.Value.ToCharArray(), 0, this.reader.Value.ToCharArray().Length);
                                lexical.endCDATA();
                            }
                            break;

                        case System.Xml.XmlNodeType.DocumentType:
                            if (this.lexical != null)
                            {
                                System.String lname = this.reader.Name;
                                System.String systemId = null;
                                if (this.reader.Reader.AttributeCount > 0)
                                    systemId = this.reader.Reader.GetAttribute(0);
                                this.lexical.startDTD(lname, null, systemId);
                                this.lexical.startEntity("[dtd]");
                                this.lexical.endEntity("[dtd]");
                                this.lexical.endDTD();
                            }
                            break;
                    }
                }
                if (this.callBackHandler != null)
                    this.callBackHandler.endDocument();
            }
            catch (System.Xml.XmlException e)
            {
                throw e;
            }
        }
Beispiel #11
0
 /// <summary>
 /// This method manage the event when a start element node were found
 /// </summary>
 /// <param name="namespaceURI">The namespace uri of the element tag</param>
 /// <param name="localName">The local name of the element</param>
 /// <param name="qName">The Qualify (long) name of the element</param>
 /// <param name="qAtts">The list of attributes of the element</param>
 public virtual void startElement(System.String namespaceURI, System.String localName, System.String qName, SaxAttributesSupport qAtts) { }
 public override void startElement(CMLStack xpath, System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
 {
     ////logger.debug("MDLMol element: name");
     base.startElement(xpath, uri, local, raw, atts);
 }
        public virtual void startElement(CMLStack xpath, System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
        {

            System.String name = local;
            ////logger.debug("StartElement");
            currentChars = "";

            BUILTIN = "";
            DICTREF = "";

            for (int i = 0; i < atts.GetLength(); i++)
            {
                System.String qname = atts.GetFullName(i);
                if (qname.Equals("builtin"))
                {
                    BUILTIN = atts.GetValue(i);
                    ////logger.debug(name, "->BUILTIN found: ", atts.GetValue(i));
                }
                else if (qname.Equals("dictRef"))
                {
                    DICTREF = atts.GetValue(i);
                    ////logger.debug(name, "->DICTREF found: ", atts.GetValue(i));
                }
                else if (qname.Equals("title"))
                {
                    elementTitle = atts.GetValue(i);
                    ////logger.debug(name, "->TITLE found: ", atts.GetValue(i));
                }
                else
                {
                    ////logger.debug("Qname: ", qname);
                }
            }

            if ("atom".Equals(name))
            {
                atomCounter++;
                for (int i = 0; i < atts.GetLength(); i++)
                {

                    System.String att = atts.GetFullName(i);
                    System.String value_Renamed = atts.GetValue(i);

                    if (att.Equals("id"))
                    {
                        // this is supported in CML 1.x
                        elid.Add(value_Renamed);
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("elementType"))
                    {
                        elsym.Add(value_Renamed);
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("title"))
                    {
                        eltitles.Add(value_Renamed);
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("x2"))
                    {
                        x2.Add(value_Renamed);
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("xy2"))
                    {
                        SupportClass.Tokenizer tokenizer = new SupportClass.Tokenizer(value_Renamed);
                        x2.Add(tokenizer.NextToken());
                        y2.Add(tokenizer.NextToken());
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("xyzFract"))
                    {
                        SupportClass.Tokenizer tokenizer = new SupportClass.Tokenizer(value_Renamed);
                        xfract.Add(tokenizer.NextToken());
                        yfract.Add(tokenizer.NextToken());
                        zfract.Add(tokenizer.NextToken());
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("xyz3"))
                    {
                        SupportClass.Tokenizer tokenizer = new SupportClass.Tokenizer(value_Renamed);
                        x3.Add(tokenizer.NextToken());
                        y3.Add(tokenizer.NextToken());
                        z3.Add(tokenizer.NextToken());
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("y2"))
                    {
                        y2.Add(value_Renamed);
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("x3"))
                    {
                        x3.Add(value_Renamed);
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("y3"))
                    {
                        y3.Add(value_Renamed);
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("z3"))
                    {
                        z3.Add(value_Renamed);
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("xFract"))
                    {
                        xfract.Add(value_Renamed);
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("yFract"))
                    {
                        yfract.Add(value_Renamed);
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("zFract"))
                    {
                        zfract.Add(value_Renamed);
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("formalCharge"))
                    {
                        formalCharges.Add(value_Renamed);
                    }
                    // this is supported in CML 2.0 
                    else if (att.Equals("hydrogenCount"))
                    {
                        hCounts.Add(value_Renamed);
                    }
                    else if (att.Equals("isotope"))
                    {
                        isotope.Add(value_Renamed);
                    }
                    else if (att.Equals("dictRef"))
                    {
                        atomDictRefs.Add(value_Renamed);
                    }
                    else if (att.Equals("spinMultiplicity"))
                    {
                        spinMultiplicities.Add(value_Renamed);
                    }
                    else
                    {
                        ////logger.warn("Unparsed attribute: " + att);
                    }
                }
            }
            else if ("atomArray".Equals(name))
            {
                bool atomsCounted = false;
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    System.String att = atts.GetFullName(i);
                    int count = 0;
                    if (att.Equals("atomID"))
                    {
                        count = addArrayElementsTo(elid, atts.GetValue(i));
                    }
                    else if (att.Equals("elementType"))
                    {
                        count = addArrayElementsTo(elsym, atts.GetValue(i));
                    }
                    else if (att.Equals("x2"))
                    {
                        count = addArrayElementsTo(x2, atts.GetValue(i));
                    }
                    else if (att.Equals("y2"))
                    {
                        count = addArrayElementsTo(y2, atts.GetValue(i));
                    }
                    else if (att.Equals("x3"))
                    {
                        count = addArrayElementsTo(x3, atts.GetValue(i));
                    }
                    else if (att.Equals("y3"))
                    {
                        count = addArrayElementsTo(y3, atts.GetValue(i));
                    }
                    else if (att.Equals("z3"))
                    {
                        count = addArrayElementsTo(z3, atts.GetValue(i));
                    }
                    else if (att.Equals("xFract"))
                    {
                        count = addArrayElementsTo(xfract, atts.GetValue(i));
                    }
                    else if (att.Equals("yFract"))
                    {
                        count = addArrayElementsTo(yfract, atts.GetValue(i));
                    }
                    else if (att.Equals("zFract"))
                    {
                        count = addArrayElementsTo(zfract, atts.GetValue(i));
                    }
                    else
                    {
                        ////logger.warn("Unparsed attribute: " + att);
                    }
                    if (!atomsCounted)
                    {
                        atomCounter += count;
                        atomsCounted = true;
                    }
                }
            }
            else if ("bond".Equals(name))
            {
                bondCounter++;
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    System.String att = atts.GetFullName(i);
                    ////logger.debug("B2 ", att, "=", atts.GetValue(i));

                    if (att.Equals("id"))
                    {
                        bondid.Add(atts.GetValue(i));
                        ////logger.debug("B3 ", bondid);
                    }
                    else if (att.Equals("atomRefs") || att.Equals("atomRefs2"))
                    {
                        // this is CML 2.0 support

                        // expect exactly two references
                        try
                        {
                            SupportClass.Tokenizer st = new SupportClass.Tokenizer(atts.GetValue(i));
                            bondARef1.Add((System.String)st.NextToken());
                            bondARef2.Add((System.String)st.NextToken());
                        }
                        catch (System.Exception 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'"
                            ////logger.error("Error in CML file: ", e.Message);
                            ////logger.debug(e);
                        }
                    }
                    else if (att.Equals("order"))
                    {
                        // this is CML 2.0 support
                        order.Add(atts.GetValue(i).Trim());
                    }
                    else if (att.Equals("dictRef"))
                    {
                        bondDictRefs.Add(atts.GetValue(i).Trim());
                    }
                }

                stereoGiven = false;
                curRef = 0;
            }
            else if ("bondArray".Equals(name))
            {
                bool bondsCounted = false;
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    System.String att = atts.GetFullName(i);
                    int count = 0;
                    if (att.Equals("bondID"))
                    {
                        count = addArrayElementsTo(bondid, atts.GetValue(i));
                    }
                    else if (att.Equals("atomRefs1"))
                    {
                        count = addArrayElementsTo(bondARef1, atts.GetValue(i));
                    }
                    else if (att.Equals("atomRefs2"))
                    {
                        count = addArrayElementsTo(bondARef2, atts.GetValue(i));
                    }
                    else if (att.Equals("atomRef1"))
                    {
                        count = addArrayElementsTo(bondARef1, atts.GetValue(i));
                    }
                    else if (att.Equals("atomRef2"))
                    {
                        count = addArrayElementsTo(bondARef2, atts.GetValue(i));
                    }
                    else if (att.Equals("order"))
                    {
                        count = addArrayElementsTo(order, atts.GetValue(i));
                    }
                    else
                    {
                        ////logger.warn("Unparsed attribute: " + att);
                    }
                    if (!bondsCounted)
                    {
                        bondCounter += count;
                        bondsCounted = true;
                    }
                }
                curRef = 0;
            }
            else if ("molecule".Equals(name))
            {
                newMolecule();
                BUILTIN = "";
                cdo.startObject("Molecule");
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    if (atts.GetFullName(i).Equals("id"))
                    {
                        cdo.setObjectProperty("Molecule", "id", atts.GetValue(i));
                    }
                    else if (atts.GetFullName(i).Equals("dictRef"))
                    {
                        cdo.setObjectProperty("Molecule", "dictRef", atts.GetValue(i));
                    }
                }
            }
            else if ("crystal".Equals(name))
            {
                newCrystalData();
                cdo.startObject("Crystal");
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    System.String att = atts.GetFullName(i);
                    if (att.Equals("z"))
                    {
                        cdo.setObjectProperty("Crystal", "z", atts.GetValue(i));
                    }
                }
            }
            else if ("symmetry".Equals(name))
            {
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    System.String att = atts.GetFullName(i);
                    if (att.Equals("spaceGroup"))
                    {
                        cdo.setObjectProperty("Crystal", "spacegroup", atts.GetValue(i));
                    }
                }
            }
            else if ("scalar".Equals(name))
            {
                if (xpath.ToString().EndsWith("crystal/scalar/"))
                    crystalScalar++;
            }
            else if ("list".Equals(name))
            {
                cdo.startObject("SetOfMolecules");
            }
        }
        public override void startElement(CMLStack xpath, System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
        {
            System.String name = raw;
            isELSYM = false;

            if ("list".Equals(name))
            {

                for (int i = 0; i < atts.GetLength(); i++)
                {

                    if (atts.GetFullName(i).Equals("title") && atts.GetValue(i).Equals("sequence"))
                    {
                    }
                    else if (atts.GetFullName(i).Equals("title") && atts.GetValue(i).Equals("connections"))
                    {
                        // assume that Atom's have been read
                        //logger.debug("Assuming that Atom's have been read: storing them");
                        base.storeAtomData();
                        connectionTable = true;
                        //logger.debug("Start Connection Table");
                    }
                    else if (atts.GetFullName(i).Equals("title") && atts.GetValue(i).Equals("connect"))
                    {
                        //logger.debug("New connection");
                        isBond = true;
                    }
                    else if (atts.GetFullName(i).Equals("id") && isBond)
                    {
                        connect_root = atts.GetValue(i);
                    }

                    // ignore other list items at this moment
                }
            }
            else
            {
                base.startElement(xpath, uri, local, raw, atts);
            }
        }
 private System.String getElementSymbol(SaxAttributesSupport atts)
 {
     for (int i = 0; i < atts.GetLength(); i++)
     {
         if ("id".Equals(atts.GetFullName(i)))
         {
             return atts.GetValue(i);
         }
     }
     return "";
 }
        public override void startElement(System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
        {
            currentChars = "";
            //logger.debug("START Element: ", raw);
            //logger.debug("  uri: ", uri);
            //logger.debug("  local: ", local);
            //logger.debug("  raw: ", raw);

            if ("atomType".Equals(local))
            {
                atomType = builder.newAtomType("R");
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    if ("id".Equals(atts.GetFullName(i)))
                    {
                        atomType.AtomTypeName = atts.GetValue(i);
                    }
                }
            }
            else if ("atom".Equals(local))
            {
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    if ("elementType".Equals(atts.GetFullName(i)))
                    {
                        atomType.Symbol = atts.GetValue(i);
                    }
                    else if ("formalCharge".Equals(atts.GetFullName(i)))
                    {
                        try
                        {
                            atomType.setFormalCharge(System.Int32.Parse(atts.GetValue(i)));
                        }
                        catch (System.FormatException exception)
                        {
                            //logger.error("Value of <atom> @", atts.GetFullName(i), " is not an integer: ", atts.GetValue(i));
                            //logger.debug(exception);
                        }
                    }
                }
            }
            else if ("scalar".Equals(local))
            {
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    if ("dictRef".Equals(atts.GetFullName(i)))
                    {
                        if ("cdk:maxBondOrder".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_MAXBONDORDER;
                        }
                        else if ("cdk:bondOrderSum".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_BONDORDERSUM;
                        }
                        else if ("cdk:hybridization".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_HYBRIDIZATION;
                        }
                        else if ("cdk:formalNeighbourCount".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_FORMALNEIGHBOURCOUNT;
                        }
                        else if ("cdk:valency".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_VALENCY;
                        }
                        else if ("cdk:formalCharge".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_FORMALCHARGE;
                        }
                        else if ("cdk:DA".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_DA;
                        }
                        else if ("cdk:sphericalMatcher".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_SPHERICALMATCHER;
                        }
                        else if ("cdk:ringSize".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_RINGSIZE;
                        }
                        else if ("cdk:ringConstant".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_CHEMICALGROUPCONSTANT;
                        }
                        else if ("cdk:aromaticAtom".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_ISAROMATIC;
                        }
                        else if ("emboss:vdwrad".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_VANDERWAALSRADIUS;
                        }
                    }
                }
            }
        }
Beispiel #17
0
 /// <summary>
 /// Replaces all the list of Att_Instance of the given SaxAttributesSupport instance.
 /// </summary>
 /// <param name="Source">The source SaxAttributesSupport instance.</param>
 public virtual void SetAttributes(SaxAttributesSupport Source)
 {
     MainList = Source.MainList;
 }