Example #1
0
        ///
        ///	 <summary> * Returns a list of element names matching the requested validity for the specified JDF version.
        ///	 *  </summary>
        ///	 * <param name="EnumElementValidity"> elemValidity: requested validity </param>
        ///	 * <returns> VString: list of strings containing the names of the matching elements </returns>
        ///
        private VString conformingElements(EnumElementValidity elemValidity1, EnumElementValidity elemValidity2, EnumElementValidity elemValidity3, EnumElementValidity elemValidity4)
        {
            VString     matchingElements = new VString();
            IEnumerator iter             = elementInfoTable.Keys.GetEnumerator();

            long l2 = JDFVersions.getTheMask(version);
            long v2 = JDFVersions.getTheOffset(version);

            while (iter.MoveNext())
            {
                string   theKey      = (string)iter.Current;
                ElemInfo ei          = (ElemInfo)elementInfoTable[theKey];
                long     eiValStatus = ei.getElemValidityStatus() & l2;
                if (eiValStatus == ((long)elemValidity1.getValue() << (int)v2))
                {
                    matchingElements.Add(theKey);
                }
                else if (eiValStatus == ((long)elemValidity2.getValue() << (int)v2))
                {
                    matchingElements.Add(theKey);
                }
                else if (eiValStatus == ((long)elemValidity3.getValue() << (int)v2))
                {
                    matchingElements.Add(theKey);
                }
                else if (eiValStatus == ((long)elemValidity4.getValue() << (int)v2))
                {
                    matchingElements.Add(theKey);
                }
            }

            return(matchingElements);
        }
Example #2
0
        //
        //	 * (non-Javadoc)
        //	 *
        //	 * @see org.cip4.jdflib.core.JDFElement#getInvalidAttributes(org.cip4.jdflib. core.KElement.EnumValidationLevel,
        //	 * boolean, int)
        //
        public override VString getInvalidAttributes(EnumValidationLevel level, bool bIgnorePrivate, int nMax)
        {
            VString         v  = base.getInvalidAttributes(level, bIgnorePrivate, nMax);
            JDFResourceLink rl = (JDFResourceLink)getDeepParentChild(ElementName.RESOURCELINKPOOL);

            if (rl != null)
            {
                JDFAttributeMap rlMap = rl.getAttributeMap();
                if (rlMap != null)
                {
                    JDFAttributeMap map = getAttributeMap();
                    if (map != null)
                    {
                        IEnumerator <string> it = map.getKeyIterator();
                        while (it.MoveNext())
                        {
                            string s = it.Current;
                            if (rlMap.ContainsKey(s))
                            {
                                v.Add(s);
                            }
                        }
                    }
                }
            }

            return(v);
        }
Example #3
0
        public virtual void testadd()
        {
            VString v = new VString();

            v.Add(EnumType.AdhesiveBinding);
            Assert.AreEqual(EnumType.AdhesiveBinding.getName(), StringUtil.setvString(v, " ", null, null));
        }
Example #4
0
 /// <summary>
 /// Add all of the strings in the list to this object
 /// </summary>
 /// <param name="strings"></param>
 public virtual void addAll(VString strings)
 {
     //ensureCapacity(size()+strings.Length);
     for (int i = 0; i < strings.Count; i++)
     {
         Add(strings[i]);
     }
 }
Example #5
0
        public virtual void testSort()
        {
            VString v = new VString();

            v.Add("a");
            v.Add("c");
            v.Add("b");
            v.Sort();
            Assert.AreEqual("a b c", StringUtil.setvString(v, " ", null, null), "a b c");
        }
Example #6
0
        ///
        ///	 <summary> * constructor </summary>
        ///
        public XMLDocUserData()
        {
            m_mapTarget = new Hashtable(); // default is on
            m_vDirtyID  = new VString();

            clearDirtyIDs();
            clearTargets();
            m_userData  = null;
            dirtyPolicy = EnumDirtyPolicy.None;
        }
Example #7
0
        public virtual void testGetAllString()
        {
            VString v = new VString();

            v.appendUnique("a");
            v.appendUnique("b");
            v.appendUnique("c");
            v.appendUnique("c");
            Assert.AreEqual("a b c", StringUtil.setvString(v, " ", null, null), "a b c");
        }
Example #8
0
        public virtual void testGetSet()
        {
            VString v = new VString();

            v.Add("a");
            v.Add("c");
            v.Add("b");
            SupportClass.SetSupport <string> s = v.getSet();
            Assert.AreEqual(v.Count, s.Count);
            Assert.IsTrue(s.Contains("c"));
        }
Example #9
0
        ///
        ///	 <summary> * remove a separationspec with a given name from this
        ///	 *  </summary>
        ///	 * <param name="sep"> the separation name </param>
        ///	 * <returns> int the index of the removed separation; -1 if none found </returns>
        ///
        public virtual int removeSeparation(string sep)
        {
            VString vs    = getSeparations();
            int     index = vs.index(sep);

            if (index >= 0)
            {
                getSeparationSpec(index).deleteNode();
            }
            return(index);
        }
Example #10
0
        ///
        ///	 <summary> * get the node names of this vector in the same order
        ///	 *  </summary>
        ///	 * <param name="bLocal"> if true use LocalName else Name o each item </param>
        ///	 * <returns> VString vector of node names </returns>
        ///
        public virtual VString getElementNameVector(bool bLocal)
        {
            VString v    = new VString();
            int     size = Count;

            v.Capacity = size;
            for (int i = 0; i < size; i++)
            {
                v.Add(bLocal ? item(i).LocalName : item(i).Name);
            }
            return(v);
        }
Example #11
0
        public virtual void testSetElementAt()
        {
            VString v = new VString();

            v.Add("a");
            v.Add("b");
            v.Add("c");
            v.Add("c");
            v.Add("e");
            v[3] = "d";
            Assert.AreEqual("a b c d e", StringUtil.setvString(v, " ", null, null));
        }
Example #12
0
        ///
        ///	 <summary> * set all separation names in the SeparationSpec elements, remove any prior elements
        ///	 *  </summary>
        ///	 * <param name="vSeps"> the vector of separation names to set </param>
        ///
        public virtual void setSeparations(VString vSeps)
        {
            removeChildren(ElementName.SEPARATIONSPEC, null, null);
            if (vSeps == null)
            {
                return;
            }

            for (int i = 0; i < vSeps.Count; i++)
            {
                appendSeparation(vSeps.stringAt(i));
            }
        }
Example #13
0
        ///
        ///	 <summary> * Get a list of all separation names in the SeparationSpec elements
        ///	 *  </summary>
        ///	 * <returns> the vector of separation names </returns>
        ///
        public virtual VString getSeparations()
        {
            VString  vName = new VString();
            VElement v     = getChildElementVector(ElementName.SEPARATIONSPEC, null, null, false, 0, false);
            int      nSep  = v.Count;

            for (int i = 0; i < nSep; i++)
            {
                JDFSeparationSpec sep     = (JDFSeparationSpec)v[i];
                string            sepName = sep.getName();
                vName.appendUnique(sepName);
            }
            return(vName);
        }
Example #14
0
        public virtual void testgetNodeNames()
        {
            XMLDoc   d = new XMLDoc("doc", null);
            KElement e = d.getRoot();

            e.appendElement("a1");
            e.appendElement("b:a2", "b");
            VElement v = e.getChildElementVector(null, null, null, true, 0, true);
            VString  s = v.getElementNameVector(false);

            CollectionAssert.AreEqual(new VString("a1 b:a2", " "), s);
            s = v.getElementNameVector(true);
            CollectionAssert.AreEqual(new VString("a1 a2", " "), s);
        }
Example #15
0
        public virtual void testAddAll()
        {
            VString v = new VString();

            v.Add("a");
            v.Add("b");
            v.Add("c");
            v.Add("c");
            string[] h = { "c", "b", "a", "d" };
            v.unify();
            Assert.AreEqual("a b c", StringUtil.setvString(v, " ", null, null), "a b c");
            v.addAll(h);
            v.unify();
            Assert.AreEqual("a b c d", StringUtil.setvString(v, " ", null, null), "a b c d");
        }
Example #16
0
        public virtual void testContainsAny()
        {
            VString v = new VString();

            v.appendUnique("a");
            v.appendUnique("b");
            v.appendUnique("c");
            v.appendUnique("c");
            Assert.IsFalse(v.containsAny(null));
            Assert.IsFalse(v.containsAny(new VString("d e", " ")));
            Assert.IsTrue(v.containsAny(new VString("b e", " ")));
            Assert.IsTrue(v.containsAny(new VString("e b", " ")));
            Assert.IsTrue(v.containsAny(new VString("g c h", " ")));
            Assert.IsTrue(v.containsAny(v));
        }
Example #17
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);
        }
Example #18
0
        ///
        ///     <summary> * checks whether at least one of a given vector of strings is contained
        ///     * in <code>this</code>
        ///     *  </summary>
        ///     * <param name="other"> the VSTring of values to test </param>
        ///     * <returns> true if at least one String in other is in <code>this</code> </returns>
        ///
        public virtual bool containsAny(VString other)
        {
            if (other == null)
            {
                return(false);
            }
            int size = other.Count;

            for (int i = 0; i < size; i++)
            {
                if (Contains(other[i]))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #19
0
        ///
        ///     <summary> * removeStrings - remove all occurrences of a string
        ///     * </summary>
        ///     * <param name="v">    the vector of strings to remove from <code>this</code> </param>
        ///     * <param name="nMax"> the max number of strings to remove </param>
        ///
        public virtual void removeStrings(VString v, int nMax)
        {
            int nMaxLocal = nMax;

            if (v == null)
            {
                return;
            }

            for (int i = this.Count - 1; i >= 0 && nMaxLocal > 0; i--)
            {
                if (v.Contains(this[i]))
                {
                    this.RemoveAt(i);
                    nMaxLocal--;
                }
            }
        }
Example #20
0
        public virtual string setvString(VString v, string sep, string front, string end)
        {
            string s   = front == null ? JDFConstants.EMPTYSTRING : front;
            int    siz = v.Count;

            for (int i = 0; i < siz; i++)
            {
                if (i != 0) //add seperator after every add
                {
                    s += sep;
                }
                s += v[i];
            }
            if (end != null)
            {
                s += end;
            }
            return(s);
        }
Example #21
0
        ///
        ///	 <summary> * Returns the list of optional attributes for the specified JDF version. Note: This includes attributes marked as
        ///	 * optional as well as attributes marked as deprecated (since, for backward compatibility, these are also optional).
        ///	 *  </summary>
        ///	 * <returns> VString: list of strings containing the names of the optional attributes </returns>
        ///
        public virtual VString optionalAttribs()
        {
            VString optionals = new VString(conformingAttribs(EnumAttributeValidity.Optional));

            optionals.appendUnique(conformingAttribs(EnumAttributeValidity.Deprecated));
            IEnumerator iter = attribInfoTable.Keys.GetEnumerator();

            // anything with a default is at least optional
            while (iter.MoveNext())
            {
                string theKey     = (string)iter.Current;
                string defaultVal = getAttributeDefault(theKey);
                if (defaultVal != null)
                {
                    optionals.appendUnique(theKey);
                }
            }

            return(optionals);
        }
Example #22
0
        private JDFCustomerInfo prepareInfo(JDFDoc doc)
        {
            JDFNode         n    = doc.getJDFRoot();
            JDFCustomerInfo info = n.appendCustomerInfo();
            VString         vct  = new VString();

            vct.Add("Customer");
            info.appendContact().setContactTypes(vct);
            vct.Add("Administrator");
            info.appendContact().setContactTypes(vct);
            JDFContact c = info.appendContact();

            vct = new VString();
            vct.Add("Delivery");
            c.setContactTypes(vct);
            c.makeRootResource(null, null, true);
            vct.Add("Customer");
            info.appendContact().setContactTypes(vct);
            return(info);
        }
Example #23
0
        /// <summary>
        /// Check if all the strings in the list are in this VString instance
        /// </summary>
        /// <param name="list">VString list of strings</param>
        /// <returns>true if all the strings in the list are in this VString instance</returns>
        public virtual bool ContainsAll(VString list)
        {
            if (list == null)
            {
                return(true);
            }

            if (list.Count > this.Count)
            {
                return(false);
            }

            foreach (string item in list)
            {
                if (!this.Contains(item))
                {
                    return(false);
                }
            }
            return(true);
        }
Example #24
0
        public virtual void testUnify()
        {
            VString v = new VString();

            v.Add("a");
            v.Add("b");
            v.Add("c");
            v.Add("c");
            VString w = new VString();

            w.Add("c");
            w.Add("b");
            w.Add("a");
            w.Add("a");
            w.Add("d");

            v.unify();
            Assert.AreEqual("a b c", StringUtil.setvString(v, " ", null, null), "a b c");
            v.appendUnique(w);
            Assert.AreEqual("a b c d", StringUtil.setvString(v, " ", null, null), "a b c d");
        }
Example #25
0
        ///
        ///	 <summary> * Returns a list of attributes matching the requested validity for the specified JDF version.
        ///	 *  </summary>
        ///	 * <param name="EnumAttributeValidity"> attrValidity: requested validity </param>
        ///	 * <returns> VString: list of strings containing the names of the matching attributes </returns>
        ///
        public virtual VString conformingAttribs(EnumAttributeValidity attrValidity)
        {
            VString matchingAttribs = new VString();
            long    l2 = JDFVersions.getTheMask(version);
            long    v2 = JDFVersions.getTheOffset(version);

            IEnumerator iter = attribInfoTable.Keys.GetEnumerator();
            bool        bOK  = attrValidity == null;

            while (iter.MoveNext())
            {
                string  theKey = (string)iter.Current;
                AtrInfo ai     = (AtrInfo)attribInfoTable[theKey];
                if (bOK)
                {
                    matchingAttribs.Add(theKey);
                }
                else
                {
                    if (attrValidity != null)
                    {
                        // grab values from tables
                        long l1 = ai.getAtrValidityStatus();
                        long l3 = l1 & l2;

                        // calculate correct mask from attrValidity and version
                        long v1 = attrValidity.getValue();
                        long v3 = v1 << (int)v2;

                        // tables and version coincide
                        if (l3 == v3)
                        {
                            matchingAttribs.Add(theKey);
                        }
                    }
                }
            }

            return(matchingAttribs);
        }
Example #26
0
        public virtual void testGetCombinedProcessTypes()
        {
            JDFDoc  d = new JDFDoc(ElementName.JDF);
            JDFNode n = d.getJDFRoot();

            n.setType("Combined", true);
            n.setTypes(new VString("a b c d e f e f", " "));
            JDFResource     r         = n.addResource(ElementName.ADHESIVEBINDINGPARAMS, EnumUsage.Input);
            JDFResourceLink rl        = n.getLink(r, null);
            VString         nodeTypes = n.getTypes();

            nodeTypes.unify();
            CollectionAssert.AreEqual(nodeTypes, rl.getCombinedProcessTypes());
            rl.setCombinedProcessType("c");
            CollectionAssert.AreEqual(new VString("c", " "), rl.getCombinedProcessTypes());
            rl.removeAttribute(AttributeName.COMBINEDPROCESSTYPE);
            CollectionAssert.AreEqual(nodeTypes, rl.getCombinedProcessTypes());
            rl.setCombinedProcessIndex(new JDFIntegerList("0 2 4 6"));
            CollectionAssert.AreEqual(new VString("a c e", " "), rl.getCombinedProcessTypes());
            rl.setCombinedProcessIndex(new JDFIntegerList("0 2 4 6 8 99"));
            CollectionAssert.AreEqual(new VString("a c e", " "), rl.getCombinedProcessTypes());
        }
Example #27
0
        ///
        ///     <summary> * AppendUnique - append a vector but ignore multiple entries
        ///     * </summary>
        ///     * <param name="v"> the vector to append </param>
        ///
        public virtual void appendUnique(VString v)
        {
            if (v == null)
            {
                return;
            }
            int size = v.Count;

            if (size == 1) // speedup for single append
            {
                string theOther = v[0];
                if (!this.Contains(theOther))
                {
                    Add(theOther);
                }
                return;
            }
            for (int i = 0; i < size; i++)
            {
                Add(v[i]);
            }

            unify();
        }
Example #28
0
        ///
        ///	 <summary> * inline this refElement by replacing it with a copy of its target
        ///	 *  </summary>
        ///	 * <returns> JDFElement - the newly created element </returns>
        ///
        public virtual JDFElement inlineRef()
        {
            int         i;
            JDFResource targetRes = getTarget();

            if (targetRes == null)
            {
                throw new JDFException("inlineRef: inlining null refElement rRef=" + getrRef());
            }
            JDFResource newInline = (JDFResource)appendElement(targetRes.Name, null);

            // copy elements and attributes
            newInline.setAttributes(targetRes);
            VElement v = targetRes.getChildElementVector(null, null, null, true, 0, false);

            for (i = 0; i < v.Count; i++)
            {
                newInline.copyElement(v.item(i), null);
            }

            newInline.cleanResourceAttributes();
            VString partNames = targetRes.getPartIDKeys();

            for (i = 0; i < partNames.Count; i++)
            {
                newInline.removeAttribute(partNames[i], null);
            }

            // replace this (the refElement) with newInline.
            // This effectively repositions newInline from the back to the original
            // position of this
            replaceElement(newInline);

            targetRes.deleteUnLinked();
            return(newInline);
        }
Example #29
0
        public virtual void testRefElement()
        {
            JDFDoc  doc  = new JDFDoc(ElementName.JDF);
            JDFNode node = doc.getJDFRoot();

            node.setType("Product", true);
            node.setVersion(JDFElement.EnumVersion.Version_1_2);
            JDFNodeInfo ni = node.appendNodeInfo();

            ni.appendElement("foo:bar", "www.foo.com"); // want a non jdf ns element
            // to see if any class casts
            // occur
            JDFContact c       = (JDFContact)node.addResource(ElementName.CONTACT, null, null, null, null, null, null);
            VString    vCTypes = new VString();

            vCTypes.Add("Customer");
            c.setContactTypes(vCTypes);

            ni.refElement(c);
            JDFComChannel cc = (JDFComChannel)node.addResource(ElementName.COMCHANNEL, null, null, null, null, null, null);

            c.refElement(cc);

            Assert.AreEqual(c, ni.getChildWithMatchingAttribute(ElementName.CONTACT, "ContactTypes", null, "Customer", 0, true, null), "contact");
            Assert.AreEqual(c, ni.getParentJDF().getChildWithAttribute(ElementName.CONTACT, "ContactTypes", null, "Customer", 0, false), "contact");

            Assert.AreEqual(c, ni.getContact(), "contact");
            Assert.IsTrue(ni.hasChildElement(ElementName.CONTACT, null), "hasrefelement");
            JDFRefElement re = (JDFRefElement)ni.getElement("ContactRef");

            Assert.IsTrue(re.getTarget() == c, "refelementok");
            Assert.IsTrue(c.getComChannel(0) == cc, "comchannel");
            Assert.IsTrue(c.hasChildElement(ElementName.COMCHANNEL, null), "hasrefelement");
            JDFNode     n2  = node.addProduct();
            JDFNodeInfo ni2 = n2.appendNodeInfo();

            ni2.refElement(c);
            Assert.IsTrue(c.matchesPath("NodeInfo/Contact", true), "follow refs in matchespath");
            Assert.IsTrue(cc.matchesPath("NodeInfo/Contact/ComChannel", true), "follow refs in matchespath");
            Assert.IsFalse(c.matchesPath("NodeInfo/Contact/ComChannel", true), "follow refs in matchespath");

            Assert.IsTrue(ni2.getContact() == c, "contact 2");
            Assert.IsTrue(ni2.hasChildElement(ElementName.CONTACT, null), "hasrefelement 2");
            re = (JDFRefElement)ni2.getElement("ContactRef");
            Assert.IsTrue(re.getTarget() == c, "refelementok 2");

            ni2.inlineRefElements(null, null, true);
            Assert.IsNull(ni2.getElement("ContactRef"), "get ref post inline");
            Assert.IsNotNull(node.getResourcePool().getElement("Contact"), "refElement has been removed");
            Assert.IsTrue(ni2.hasChildElement(ElementName.CONTACT, null), "haselement 3");
            c  = ni2.getContact();
            re = (JDFRefElement)c.getElement("ComChannelRef");
            Assert.IsTrue(re.getTarget() == cc, "refelementok 2");
            ni2.inlineRefElements(null, null, false);
            Assert.IsNull(ni2.getElement("ComChannelRef"), "get ref post inline 2");
            Assert.IsTrue(c.hasChildElement(ElementName.COMCHANNEL, null), "haselement 4");

            ni.inlineRefElements(null, null, true);
            Assert.IsNull(ni.getElement("ContactRef"), "get ref post inline");
            Assert.IsNull(node.getResourcePool().getElement("Contact"), "refElement has been removed");
            Assert.IsTrue(ni.hasChildElement(ElementName.CONTACT, null), "haselement 3");

            c = ni.getContact();
            c.makeRootResource(null, null, true);
            re = (JDFRefElement)ni.getElement("ContactRef");
            re.deleteRef(true);
            Assert.IsNull(c.getElement("ContactRef"));
        }
Example #30
0
 public virtual void removeStrings(VString v)
 {
     removeStrings(v, int.MaxValue);
 }