/// <summary> /// Substitutes the matching formal attribute values of the element /// with the values in the substitute attributes. /// </summary> /// <param name="substitutes">The list of substitute attribute/value pairs</param> /// <returns>A deep copy of the empty element with values substituted</returns> public EmptyElement SubstituteCopy(ArrayList substitutes) { EmptyElement xerox = copy(); // null valued subs remove attrs from the list, so itterate in reverse for (int a = xerox.countAttributes() - 1; a > -1; a--) { // if formal values are found, substitute String value = xerox.getAttributeValue(a); foreach (Substitute sub in substitutes) { if (sub.formal.Equals(value)) { xerox.addAttribute(xerox.getAttributeName(a), sub.value); } } } return(xerox); }
/** Determines if this EmptyElement has the same attributes as another. * @param ee another EmptyElement * @return true if it has the same attributes */ public bool hasSameAttributes(EmptyElement ee) { if (ee == null) { return(false); } bool same = countAttributes() == ee.countAttributes(); if (same && m_attributes != null) { // count is the same, so if extra, one will not be equal foreach (Attribute a in m_attributes) { Attribute a2 = ee.findAttribute(a.name); if (!a.equals(a2)) { return(false); } } } return(same); }
/// <summary> /// Counts the number of RuleSet formal parameters. /// </summary> /// <returns>The number of formal parameters.</returns> public int formals() { return(m_params.countAttributes()); }
/** Determines if this EmptyElement has the same attributes as another. * @param ee another EmptyElement * @return true if it has the same attributes */ public bool hasSameAttributes(EmptyElement ee) { if (ee == null) return false; bool same = countAttributes() == ee.countAttributes(); if (same && m_attributes != null) { // count is the same, so if extra, one will not be equal foreach (Attribute a in m_attributes) { Attribute a2 = ee.findAttribute(a.name); if (!a.equals(a2)) return false; } } return same; }