Class TextContainer<T>


  • public class TextContainer<T>
    extends Component
    This container can be used for components including a mix of text and elements, where each character and element are components. Instead of a list of this mixed components only a list of the elements is being held
    Author:
    svante.schubertATgmail.com
    • Constructor Detail

    • Method Detail

      • appendText

        public void appendText​(Text text)
      • removeText

        public void removeText​(int start,
                               int end)
      • appendChild

        public Node appendChild​(Node node)
      • addChild

        public void addChild​(int index,
                             Component c)
        Adds the given component to the root element
        Overrides:
        addChild in class Component
        Parameters:
        index - starting with 0 representing the position of the child, if -1 the new child will be appended
      • getChildNode

        public Node getChildNode​(int index)
        Overrides:
        getChildNode in class Component
        Returns:
        either a text node of size 1 or an element being the root element of a component
      • getChildNode

        public Node getChildNode​(int startIndex,
                                 int endIndex)
        Overrides:
        getChildNode in class Component
        Returns:
        either a text node from start index and cut after endIndex) or an element being the root element of a component
      • remove

        public Node remove​(int index)
        Removes a component from the text element container. Removes either an element representing a component or text node of size 1
        Overrides:
        remove in class Component
      • size

        public int size()
        All children of the root element will be traversed. If it is a text node the size is added, if it is an element and a component a size of one is added, if it is a marker, for known text marker elements (text:span, text:bookmark) the children are recursive checked
        Overrides:
        size in class Component
        Returns:
        the number of child components