![JAR search and dependency download from the Maven repository](/logo.png)
com.itextpdf.styledxmlparser.css.selector.item.CssPseudoClassChildSelectorItem Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of styled-xml-parser Show documentation
Show all versions of styled-xml-parser Show documentation
Styled XML parser is used by iText7 modules to parse HTML and XML
package com.itextpdf.styledxmlparser.css.selector.item;
import com.itextpdf.styledxmlparser.node.IElementNode;
import com.itextpdf.styledxmlparser.node.INode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class CssPseudoClassChildSelectorItem extends CssPseudoClassSelectorItem {
/**
* Creates a new {@link CssPseudoClassSelectorItem} instance.
*
* @param pseudoClass the pseudo class name
*/
CssPseudoClassChildSelectorItem(String pseudoClass) {
super(pseudoClass);
}
CssPseudoClassChildSelectorItem(String pseudoClass, String arguments) {
super(pseudoClass, arguments);
}
/**
* Gets the all the siblings of a child node.
*
* @param node the child node
* @return the sibling nodes
*/
List getAllSiblings(INode node) {
INode parentElement = node.parentNode();
if (parentElement != null) {
List childrenUnmodifiable = parentElement.childNodes();
List children = new ArrayList(childrenUnmodifiable.size());
for (INode iNode : childrenUnmodifiable) {
if (iNode instanceof IElementNode)
children.add(iNode);
}
return children;
}
return Collections.emptyList();
}
/**
* Gets all siblings of a child node with the type of a child node.
*
* @param node the child node
* @return the sibling nodes with the type of a child node
*/
List getAllSiblingsOfNodeType(INode node) {
INode parentElement = node.parentNode();
if (parentElement != null) {
List childrenUnmodifiable = parentElement.childNodes();
List children = new ArrayList(childrenUnmodifiable.size());
for (INode iNode : childrenUnmodifiable) {
if (iNode instanceof IElementNode && ((IElementNode) iNode).name().equals(((IElementNode) node).name()))
children.add(iNode);
}
return children;
}
return Collections.emptyList();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy