Example #1
0
        /// <summary>
        /// Combines a list of elements. This method takes care to always
        /// concatenate adjacent string elements into a single string
        /// element.
        /// </summary>
        /// <param name="list">The list with elements</param>
        /// <returns>The combined element</returns>
        private Element CombineElements(ArrayList list)
        {
            Element prev;
            Element elem;
            string  str;
            int     i;

            // Concatenate string elements
            prev = (Element)list[0];
            for (i = 1; i < list.Count; i++)
            {
                elem = (Element)list[i];
                if ((prev is StringElement element1) && (elem is StringElement element2))
                {
                    str  = element1.String + element2.String;
                    elem = new StringElement(str);
                    list.RemoveAt(i);
                    list[i - 1] = elem;
                    i--;
                }

                prev = elem;
            }

            // Combine all remaining elements
            elem = (Element)list[list.Count - 1];
            for (i = list.Count - 2; i >= 0; i--)
            {
                prev = (Element)list[i];
                elem = new CombineElement(prev, elem);
            }

            return(elem);
        }
Example #2
0
 /**
  * Adds multiple characters to this character set.
  *
  * @param elem           the string element with characters to add
  */
 public void AddCharacters(StringElement elem)
 {
     AddCharacters(elem.GetString());
 }
Example #3
0
        /**
         * Combines a list of elements. This method takes care to always
         * concatenate adjacent string elements into a single string
         * element.
         *
         * @param list           the list with elements
         *
         * @return the combined element
         */
        private Element CombineElements(ArrayList list) {
            Element  prev;
            Element  elem;
            string   str;
            int      i;

            // Concatenate string elements
            prev = (Element) list[0];
            for (i = 1; i < list.Count; i++) {
                elem = (Element) list[i];
                if (prev is StringElement
                 && elem is StringElement) {

                    str = ((StringElement) prev).GetString() +
                          ((StringElement) elem).GetString();
                    elem = new StringElement(str);
                    list.RemoveAt(i);
                    list[i - 1] = elem;
                    i--;
                }
                prev = elem;
            }

            // Combine all remaining elements
            elem = (Element) list[list.Count - 1];
            for (i = list.Count - 2; i >= 0; i--) {
                prev = (Element) list[i];
                elem = new CombineElement(prev, elem);
            }

            return elem;
        }
Example #4
0
 /**
  * Adds multiple characters to this character set.
  *
  * @param elem           the string element with characters to add
  */
 public void AddCharacters(StringElement elem) {
     AddCharacters(elem.GetString());
 }
 /// <summary>
 /// Adds multiple characters to this character set.
 /// </summary>
 /// <param name="elem">The string element with characters to be added</param>
 public void AddCharacters(StringElement elem)
 {
     this.AddCharacters(elem.String);
 }