Class CompositeElement

java.lang.Object
com.aquima.interactions.composer.model.Element
com.aquima.interactions.composer.model.CompositeElement
All Implemented Interfaces:
ICompositeElement, IElement, Serializable
Direct Known Subclasses:
Container, ContentItem, Document

public abstract class CompositeElement extends Element implements ICompositeElement
Base class for composite elements. A composite element is an element that can have children elements.
Since:
7.0
Author:
O. Kerpershoek, Jon van Leuven
See Also:
  • Constructor Details

    • CompositeElement

      protected CompositeElement(String name, ContentStyle contentStyle)
      Constructs an empty composite element with a name and content style.
      Parameters:
      name - The name of the composite element.
      contentStyle - The content style for the composite element (may be null)
    • CompositeElement

      protected CompositeElement(CompositeElement other, boolean duplicateContents)
      Copy constructor that creates a composite element based on another composite element. The duplicateContents parameter may be used to specify if all contents should be duplicated. Note: Duplicating a composite element can be quite expensive depending on the amount of content that is present on the composite element. If the duplicate contents is false the children of the composite element are not copied or used thus creating an empty composite element. This constructor is mainly available for implementations of the duplicate method.
      Parameters:
      other - The container which should be imitated.
      duplicateContents - A boolean indicating it should create copies of the contents of the other composite element, or when false to ignore the other composite element children.
    • CompositeElement

      protected CompositeElement(ElementDefinition definition, ContentStyle contentStyle)
      Constructs a composite element from a definition.

      Note: This constructor will not add any child elements.

      Parameters:
      definition - The definition of the composite element.
      contentStyle - The content style for the composite element.
  • Method Details

    • getContentStyle

      public ContentStyle getContentStyle()
      This method returns the content style of the element.
      Specified by:
      getContentStyle in interface ICompositeElement
      Returns:
      The content style of the element, may be null.
    • setContentStyle

      public void setContentStyle(ContentStyle contentStyle)
      This method sets the content style of the element.
      Parameters:
      contentStyle - The content style of the element, may not be null.
    • getElementCount

      public int getElementCount()
      Description copied from interface: ICompositeElement
      This method returns the number of elements that is contained in this container.
      Specified by:
      getElementCount in interface ICompositeElement
      Returns:
      The number of child elements of this container.
    • getElement

      public IElement getElement(RuntimeKey key)
      Description copied from interface: ICompositeElement
      This method returns the element for the specified runtime key.
      Specified by:
      getElement in interface ICompositeElement
      Parameters:
      key - The runtime key of the element that is requested.
      Returns:
      The element for the specified runtime key.
    • getElement

      public IElement getElement(int index)
      Description copied from interface: ICompositeElement
      This method returns the child element at the specified position.
      Specified by:
      getElement in interface ICompositeElement
      Parameters:
      index - The position of the child element that is requested.
      Returns:
      The child element at the specified position.
    • getElements

      public IElement[] getElements()
      Description copied from interface: ICompositeElement
      This method returns an array containing all the elements that are directly included in this container.
      Specified by:
      getElements in interface ICompositeElement
      Returns:
      Array with the direct sub elements of the container.
    • setElements

      public void setElements(Element[] elements)
      This method will add the array of elements to the composite model. The elements will be appended at the end after any existing elements. This method has the same effect as calling the addElement method for each element in the array.
      Parameters:
      elements - The array of elements that should be added to the container.
    • insertElement

      public final IElement insertElement(int index, IElement element)
      This method will add the element to the container at the specified position.
      Parameters:
      index - The position at which the element should be added.
      element - The element that should be added to the container.
      Returns:
      The element that was just added.
    • replaceElementWithElements

      protected final void replaceElementWithElements(Element element, Element[] replacements)
    • addElement

      public final IElement addElement(IElement element)
      This method will add the element to the container. The element will be appended at the end after any existing elements.
      Parameters:
      element - The element that should be added to the container.
      Returns:
      The element that was just added.
    • addElements

      public final void addElements(IElement[] elements)
      This method will add the array of elements to the container. The elements will be appended at the end after any existing elements. This method has the same effect as calling the addElement method for each element in the array.
      Parameters:
      elements - The array of elements that should be added to the container.
    • removeElement

      public final IElement removeElement(int index)
      This method will remove the element at the specified position.
      Parameters:
      index - The position of the element that should be removed.
      Returns:
      The element that was removed from the container.
    • removeAllElements

      public final IElement[] removeAllElements()
      This method will remove all the elements from the container.
      Returns:
      Array of all the children that were removed from the container.
    • accept

      public IVisitor accept(IVisitor visitor)
      Description copied from class: Element
      This method will invoke the visitor for this runtime element.
      Specified by:
      accept in interface ICompositeElement
      Specified by:
      accept in interface IElement
      Overrides:
      accept in class Element
      Parameters:
      visitor - The visitor that should be invoked.
      Returns:
      The visitor passed to this method.
    • equalsContent

      public boolean equalsContent(ICompositeElement other)
      Description copied from interface: ICompositeElement
      Method indicating if the composite element has the same content as another composite element.
      Specified by:
      equalsContent in interface ICompositeElement
      Parameters:
      other - composite element to compare with
      Returns:
      boolean indicating if the content of this composite element is equal to the content of the provided composite element.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Element
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Element
    • toString

      public String toString()
      Overrides:
      toString in class Object