Example #1
0
        /// <summary>
        /// Add a dotted named variable to the pool to be retrieved by calling getDotted.
        /// If it exists but the new value is null or empty, then the dotted variable
        /// is removed.
        /// </summary>
        /// <param name="name">The id of the variable.</param>
        /// <param name="value">The variable called by name.</param>
        public void add(string name, string dotted, string value)
        {
            if (name == null || name == "")
            {
                return;
            }
            EmptyElement ee = (EmptyElement)m_vars[name];

            if (ee != null)
            {               // the variable is defined
                if (dotted != null && dotted != "")
                {
                    if (value != null && value != "")
                    {
                        ee.addAttribute(dotted, value);
                    }
                    else                     // remove the dotted value
                    {
                        ee.removeAttribute(dotted);
                    }
                }
            }
            else if (dotted != null && dotted != "" && value != null && value != "")
            {               // the dotted variable is NOT defined
                ee = new EmptyElement(name);
                ee.addAttribute(dotted, value);
                m_vars.Add(name, ee);
            }
        }
Example #2
0
        public static EmptyElement readXml(XmlNode emptyElt)
        {
            EmptyElement ee = null;

            if (emptyElt == null)
            {
                return(ee);
            }
            if (emptyElt.HasChildNodes)
            {             // this is not empty!
                Log log = Log.getOnly();
                log.writeElt("fail");
                log.writeAttr("node", emptyElt.Name);
                log.writeAttr("expected", "empty");
                log.endElt();
            }
            else             // this is a truly empty node
            {
                ee = new EmptyElement(emptyElt.Name);
                XmlAttributeCollection attrs = emptyElt.Attributes;
                for (int a = 0; a < attrs.Count; a++)
                {                 // read all attributes
                    XmlNode attr = attrs.Item(a);
                    ee.addAttribute(attr.Name, attr.Value);
                }
            }
            return(ee);
        }
Example #3
0
        /// <summary>
        /// Add a named variable to the pool to be retrieved by calling get.
        /// </summary>
        /// <param name="name">The id of the variable.</param>
        /// <param name="value">The variable called by name.</param>
        public void add(string name, string value)
        {
            EmptyElement ee = new EmptyElement(name);

            ee.addAttribute(name, value);
            m_vars.Add(name, ee);
        }
Example #4
0
        /**
         * Makes a deep copy of an empty element.
         * Contents are not copied.
         * @return A copy.
         */
        public EmptyElement copy()
        {
            EmptyElement ee = new EmptyElement(m_name);

            foreach (Attribute a in m_attributes)
            {
                ee.addAttribute(a.name, a.value);
            }
            return(ee);
        }
Example #5
0
        /// <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);
        }
Example #6
0
 /// <summary>
 /// Add a dotted named variable to the pool to be retrieved by calling getDotted.
 /// If it exists but the new value is null or empty, then the dotted variable
 /// is removed.
 /// </summary>
 /// <param name="name">The id of the variable.</param>
 /// <param name="value">The variable called by name.</param>
 public void add(string name, string dotted, string value)
 {
     if (name == null || name == "") return;
     EmptyElement ee = (EmptyElement)m_vars[name];
     if (ee != null)
     {   // the variable is defined
         if (dotted != null && dotted != "")
         {
             if (value != null && value != "")
                 ee.addAttribute(dotted, value);
             else // remove the dotted value
                 ee.removeAttribute(dotted);
         }
     }
     else if (dotted != null && dotted != "" && value != null && value != "")
     {   // the dotted variable is NOT defined
         ee = new EmptyElement(name);
         ee.addAttribute(dotted, value);
         m_vars.Add(name, ee);
     }
 }
Example #7
0
 public static EmptyElement readXml(XmlNode emptyElt)
 {
     EmptyElement ee = null;
     if (emptyElt == null) return ee;
     if (emptyElt.HasChildNodes)
     { // this is not empty!
         Log log = Log.getOnly();
         log.writeElt("fail");
         log.writeAttr("node", emptyElt.Name);
         log.writeAttr("expected", "empty");
         log.endElt();
     }
     else // this is a truly empty node
     {
         ee = new EmptyElement(emptyElt.Name);
         XmlAttributeCollection attrs = emptyElt.Attributes;
         for (int a = 0; a < attrs.Count; a++)
         { // read all attributes
             XmlNode attr = attrs.Item(a);
             ee.addAttribute(attr.Name, attr.Value);
         }
     }
     return ee;
 }
Example #8
0
 /** Creates a parameter known by the application.
  * @param name designation of the parameter.
  */
 public void addParameter(string name)
 {
     m_params.addAttribute(name, NoValue);
 }
Example #9
0
 /// <summary>
 /// Add a named variable to the pool to be retrieved by calling get.
 /// </summary>
 /// <param name="name">The id of the variable.</param>
 /// <param name="value">The variable called by name.</param>
 public void add(string name, string value)
 {
     EmptyElement ee = new EmptyElement(name);
     ee.addAttribute(name, value);
     m_vars.Add(name, ee);
 }
Example #10
0
 /**
  * Makes a deep copy of an empty element.
  * Contents are not copied.
  * @return A copy.
  */
 public EmptyElement copy()
 {
     EmptyElement ee = new EmptyElement(m_name);
     foreach (Attribute a in m_attributes)
     {
        ee.addAttribute(a.name, a.value);
     }
     return ee;
 }