Package com.inet.html

Class InetHtmlDocument.ElementEditBuffer

java.lang.Object
com.inet.html.InetHtmlDocument.ElementEditBuffer
Enclosing class:
InetHtmlDocument

protected static class InetHtmlDocument.ElementEditBuffer extends Object
Extension of the java.text way to store the adds and removes in two arrays. This class has the ability to gather all element changes on one parent. It supports to sort the elements stored in the remove or add lists and to calculate the effective start and end offset of the modification.
  • Constructor Details

    • ElementEditBuffer

      public ElementEditBuffer(Element parent, int index, Element[] removes, Element[] adds)
      Creates an element edit buffer based on the data of the first modification on an element
      Parameters:
      parent - the element whose children will be exchanged
      index - the index within the children where the modification starts
      removes - the removed elements
      adds - the inserted elements
  • Method Details

    • getChildrenAdded

      public Element[] getChildrenAdded()
      Returns the added elements as an array
      Returns:
      the added elements as an array
    • getChildrenRemoved

      public Element[] getChildrenRemoved()
      Returns the removed elements as an array
      Returns:
      the removed elements as an array
    • getElement

      public Element getElement()
      Returns the parent element
      Returns:
      the parent element
    • getIndex

      public int getIndex()
      Returns the modification index
      Returns:
      the modification index
    • setIndex

      public void setIndex(int index)
      Sets the modification index
      Parameters:
      index - the index where the first removed or inserted element is located within the children of the parent element
    • addRemove

      public boolean addRemove(Element e)
      Register a further remove
      Parameters:
      e - a child of the parent element, which was removed
      Returns:
      true, if the element was present in the added list. Which means an element which was created by the current parser run was removed. If false the element was not present as added element
    • addAdd

      public void addAdd(Element e)
      Register a further added element
      Parameters:
      e - a child which was added to the parents children-list
    • getElementEdit

      public AbstractDocument.ElementEdit getElementEdit()
      Constructs an AbstractDocument.ElementEdit from the registered adds and removes
      Returns:
      the created edit info
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getStartOffset

      public int getStartOffset()
      Calculates the start offset based on the added and removed elements
      Returns:
      the start offset based on the added and removed elements
    • getEndOffset

      public int getEndOffset()
      Calculates the end offset based on the added and removed elements
      Returns:
      the end offset based on the added and removed elements