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
-
-
Field Summary
-
Fields inherited from interface cdc.util.data.Node
ANY_NODE, ELEMENT_NAME_AND_ATTRIBUTES_COMPARATOR, ELEMENT_NAME_COMPARATOR, IS_COMMENT, IS_ELEMENT, IS_IGNORABLE_TEXT, IS_PURE_ELEMENT, IS_TEXT
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Childclone(boolean recurse)Return a clone of this node.default voiddetach()Detach this child from its parent.default intgetIndex()ParentgetParent()default <E extends Parent>
EgetParent(Class<E> parentClass)Returns the parent of this child, cast to a target class.default ChildgetRootChild()Returns the highest ancestor of this child that is a child.default voidsetIndex(int to)Set the index of this child.voidsetParent(Parent parent)Sets or changes the parent of this child.-
Methods inherited from interface cdc.util.data.Node
deepEquals, getDocument, getQName, getRootElement, getType
-
-
-
-
Method Detail
-
clone
Child clone(boolean recurse)
Description copied from interface:NodeReturn a clone of this node.
-
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
parentClassobject.
-
setParent
void setParent(Parent parent)
Sets or changes the parent of this child.- Parameters:
parent- The new parent. May benull.- Throws:
IllegalStateException- Whenparentcan 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,
orto < 0 or to >= getParent().getChildrenCount().
-
detach
default void detach()
Detach this child from its parent.Equivalent to
setParent(null).
-
-