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"); }
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)); }
/// /// <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); }
/// /// <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); }
/// /// <summary> * add string id uniquely to the vector of dirty ids /// * </summary> /// * <param name="e"> the element to be added to the dirty list </param> /// * <param name="bAttribute"> if true, only attributes are dirty, else also sub-elements </param> /// * <returns> VString - the vector of element IDs after appending id </returns> /// internal virtual VString setDirty(KElement e, bool bAttribute) { globalDirty = true; if (dirtyPolicy == EnumDirtyPolicy.XPath) { string x = e.buildXPath(null, 1); if (bAttribute) { x += "/@"; } int i; int size = m_vDirtyID.Count; for (i = 0; i < size; i++) { string s = m_vDirtyID[i]; if (s.StartsWith(x)) { if (s.Equals(x)) // e is already dirty { return(m_vDirtyID); } m_vDirtyID.RemoveAt(i); i--; } else if (x.StartsWith(s)) // we have a dirty parent, do // nothing { return(m_vDirtyID); } else if (x.CompareTo(s) > 0) // keep sorted { break; } } m_vDirtyID.Insert(i, x); } else if (dirtyPolicy == EnumDirtyPolicy.ID) { m_vDirtyID.appendUnique(e.getInheritedAttribute(AttributeName.ID, null, JDFConstants.EMPTYSTRING)); } return(m_vDirtyID); }
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"); }