/// /// <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); }
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"); }
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")); }
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)); }
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"); }
// // * (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); }
public virtual void testadd() { VString v = new VString(); v.Add(EnumType.AdhesiveBinding); Assert.AreEqual(EnumType.AdhesiveBinding.getName(), StringUtil.setvString(v, " ", null, null)); }
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); }
/// /// <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); }
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"); }
/// /// <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); }
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")); }