コード例 #1
0
        public virtual void testIsEqual()
        {
            XMLDoc   d  = new XMLDoc("doc", null);
            KElement e  = d.getRoot();
            KElement e1 = e.appendElement("e1");

            e1.setAttribute("a", "b");
            KElement e2 = e.appendElement("e1");

            e2.setAttribute("a", "c");
            KElement e3 = e.appendElement("e1");

            e3.setAttribute("a", "c");
            KElement e4 = e.appendElement("e1");

            e4.setAttribute("a", "d");
            VElement v = new VElement();

            v.Add(e1);
            v.Add(e2);
            VElement v2 = new VElement(v);

            Assert.IsTrue(v.isEqual(v2));
            v2[1] = e3;
            Assert.IsTrue(v.isEqual(v2));
            v2[1] = e4;
            Assert.IsFalse(v.isEqual(v2));
        }
コード例 #2
0
ファイル: JDFNodeInfo.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * Get the linked resources matching some conditions
        ///	 *  </summary>
        ///	 * <param name="mResAtt"> map of Resource attributes to search for </param>
        ///	 * <param name="bFollowRefs"> true if internal references shall be followed </param>
        ///	 * <returns> vResource: vector with all elements matching the conditions default: GetLinkedResources(new
        ///	 *         JDFAttributeMap(), false) </returns>
        ///
        public virtual VElement getLinkedResources(JDFAttributeMap mResAtt, bool bFollowRefs)
        {
            VElement vChild = getChildElementVector(null, null, null, true, 0, false);
            VElement vElem  = new VElement();

            for (int i = 0; i < vChild.Count; i++)
            {
                if (!(vChild[i] is JDFRefElement))
                {
                    continue;
                }

                JDFRefElement l = (JDFRefElement)vChild[i];
                JDFResource   r = l.getTarget();
                r = r == null ? null : r.getResourceRoot();
                if (r != null && r.includesAttributes(mResAtt, true))
                {
                    vElem.Add(r); // vElem.push_back(r);
                    if (bFollowRefs)
                    {
                        vElem.appendUnique(r.getvHRefRes(bFollowRefs, true));
                    }
                }
            }
            return(vElem);
        }
コード例 #3
0
        ///
        ///	 <summary> * Get the linked resources matching some conditions
        ///	 *  </summary>
        ///	 * <param name="mResAtt"> map of Resource attributes to search for </param>
        ///	 * <param name="bFollowRefs"> true if internal references shall be followed
        ///	 *  </param>
        ///	 * <returns> VResource - vector with all elements matching the conditions
        ///	 *
        ///	 *         default: GetLinkedResources(new JDFAttributeMap(), false) </returns>
        ///
        public virtual VElement getLinkedResources(JDFAttributeMap mResAtt, bool bFollowRefs)
        {
            VElement v  = getChildElementVector(null, null, null, true, 0, false);
            VElement vL = new VElement();

            for (int i = 0; i < v.Count; i++)
            {
                if ((v[i]) is JDFRefElement)
                {
                    JDFRefElement l = (JDFRefElement)v[i];
                    JDFResource   r = l.getTarget();
                    r = r == null ? null : r.getResourceRoot();

                    if (r != null && r.includesAttributes(mResAtt, true))
                    {
                        vL.Add(r);
                        if (bFollowRefs)
                        {
                            vL.appendUnique(r.getvHRefRes(bFollowRefs, true));
                        }
                    }
                }
            }

            return(vL);
        }
コード例 #4
0
        public virtual void testSort()
        {
            XMLDoc   d  = new XMLDoc("doc", null);
            KElement e  = d.getRoot();
            KElement e1 = e.appendElement("e1");

            e1.setAttribute("a", "z");
            KElement e2 = e.appendElement("e1");

            e2.setAttribute("a", "c");
            VElement v = new VElement();

            v.Add(e1);
            v.Add(e2);
            v.Sort();
            Assert.AreEqual(e2, v[0]);
        }
コード例 #5
0
        public virtual void testUnify()
        {
            XMLDoc   d  = new XMLDoc("doc", null);
            KElement e  = d.getRoot();
            KElement e1 = e.appendElement("e1");

            e1.setAttribute("a", "b");
            VElement v = new VElement();

            v.Add(e1);
            v.Add(e1);
            e1 = e.appendElement("e1");
            e1.setAttribute("a", "b");
            v.Add(e1);
            Assert.AreEqual(3, v.Count);
            v.unify();
            Assert.AreEqual(2, v.Count);
            v.unifyElement();
            Assert.AreEqual(1, v.Count);
        }
コード例 #6
0
 /// <summary>
 /// Convert a generic list of elements to VElement
 /// </summary>
 /// <typeparam name="T">Type of Element</typeparam>
 /// <param name="list">List of elements</param>
 /// <returns>VElement list</returns>
 public static VElement ToVElement <T>(List <T> list) where T : KElement
 {
     if (list != null)
     {
         VElement vList = new VElement();
         foreach (KElement element in list)
         {
             vList.Add(element);
         }
         return(vList);
     }
     return(null);
 }
コード例 #7
0
        public virtual void testAddAll()
        {
            XMLDoc   d = new XMLDoc("doc", null);
            KElement e = d.getRoot();
            VElement v = new VElement();

            v.addAll((VElement)null);
            Assert.AreEqual(0, v.Count);
            v.Add(e);
            Assert.AreEqual(1, v.Count);
            v.addAll(v);
            Assert.AreEqual(2, v.Count);
            v.addAll(v);
            Assert.AreEqual(4, v.Count);
        }
コード例 #8
0
        ///
        ///	 <summary> * get a list of contacts with at least one contacttype set
        ///	 *  </summary>
        ///	 * <param name="contactType"> the contatcttype to look for </param>
        ///	 * <returns> VElement the vector of matching JDFContacts, null if none are found </returns>
        ///
        public virtual VElement getContactVectorWithContactType(string contactType)
        {
            VElement v   = getChildElementVector(ElementName.CONTACT, null, null, true, 0, true);
            VElement v2  = new VElement();
            int      siz = v.Count;

            for (int i = 0; i < siz; i++)
            {
                JDFContact contact      = (JDFContact)v[i];
                VString    contactTypes = contact.getContactTypes();
                if (contactTypes.Contains(contactType))
                {
                    v2.Add(contact);
                }
            }
            return(v2.Count > 0 ? v2 : null);
        }
コード例 #9
0
        ///
        ///	 <summary> * ToVector - parse a node list for elements spezified through parameters note that the vector is static - i.e. the
        ///	 * elements are NOT modified by operations to the nodeList. This behavior is different than that of the actual
        ///	 * nodelist!
        ///	 *  </summary>
        ///	 * <param name="element"> name of the element typ you want </param>
        ///	 * <param name="mAttrib"> a attribute typ you want </param>
        ///	 * <param name="bAnd"> true, if you want to add the element if mAttrib was found in the element </param>
        ///	 * <param name="nameSpaceURI"> the namespace to search in </param>
        ///	 * <returns> VElement - vector of all elements matching the conditions above </returns>
        ///
        public virtual VElement toVector(string element, JDFAttributeMap mAttrib, bool bAnd, string nameSpaceURI)
        {
            VElement v         = new VElement();
            bool     bWantName = KElement.isWildCard(element);
            bool     bWantNS   = KElement.isWildCard(nameSpaceURI);

            // loop over the list
            int len = Count;

            // optimize -> walk tree once to set it up!
            if (len > 0)
            {
                KElement temp = this[len - 1];
            }
            for (int i = 0; i < len; i++)
            {
                KElement k = this[i];
                if (bWantName)
                {
                    // want only named elements
                    if (!k.Name.Equals(element))
                    {
                        continue;
                    }
                }
                if (bWantNS)
                {
                    // want only named elements
                    if (!k.getNamespaceURI().Equals(nameSpaceURI))
                    {
                        continue;
                    }
                }
                if (k.includesAttributes(mAttrib, bAnd))
                {
                    v.Add(k);
                }
            }
            return(v);
        }