Package cdc.util.data

Interface Child

  • All Superinterfaces:
    Node
    All Known Subinterfaces:
    Leaf
    All Known Implementing Classes:
    AbstractChild, AbstractContentNode, Comment, Element, Text

    public interface Child
    extends Node
    Interface implemented by child nodes: they have an optional parent.

    This may be:

    • Element
    • Text
    • Comment
    Author:
    Damien Carbonne
    • Method Detail

      • clone

        Child clone​(boolean recurse)
        Description copied from interface: Node
        Return a clone of this node.
        Specified by:
        clone in interface Node
        Parameters:
        recurse - If true, also clone children nodes.
        Returns:
        A clone of this node, and optionally its children.
      • getRootChild

        default Child getRootChild()
        Returns the highest ancestor of this child that is a child.

        This may be this child.

        Returns:
        The root child of this child.
      • getParent

        Parent getParent()
        Returns:
        The parent of this child. It may be null.
      • getParent

        default <E extends Parent> E getParent​(Class<E> parentClass)
        Returns the parent of this child, cast to a target class.
        Type Parameters:
        E - The target type.
        Parameters:
        parentClass - The target class.
        Returns:
        The parent of this child as a parentClass object.
      • setParent

        void setParent​(Parent parent)
        Sets or changes the parent of this child.
        Parameters:
        parent - The new parent. May be null.
        Throws:
        IllegalStateException - When parent can not not be set.
      • getIndex

        default int getIndex()
        Returns:
        The index of this child or -1.
      • setIndex

        default void setIndex​(int to)
        Set the index of this child.
        Parameters:
        to - The new index of this child.
        Throws:
        IllegalArgumentException - When this child has no parent,
        or to < 0 or to >= getParent().getChildrenCount().
      • detach

        default void detach()
        Detach this child from its parent.

        Equivalent to setParent(null).