Class WikiTextParentNode
java.lang.Object
com.lucaskjaerozhang.wikitext_parser.ast.base.WikiTextNode
com.lucaskjaerozhang.wikitext_parser.ast.base.WikiTextParentNode
- All Implemented Interfaces:
WikiTextElement
- Direct Known Subclasses:
Article,Bold,CategoryList,CategoryList.Category,ExternalLink,IndentedBlock,Italic,ListItem,Section,WikiLink,WikiTextList,XMLContainerElement
A node that has child nodes. This abstract class contains the logic for serializing the node into
XML.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedWikiTextParentNode(List<WikiTextNode> children) Constructs the node -
Method Summary
Modifier and TypeMethodDescriptionCategory links are leaf nodes but we want to include them as attributes of an article.getFieldValuesFromChildren(List<WikiTextNode> children, Function<? super WikiTextNode, Set<String>> getter) There is data that flow up to the root from leaf nodes.Methods inherited from class com.lucaskjaerozhang.wikitext_parser.ast.base.WikiTextNode
accept, getAttributes
-
Constructor Details
-
WikiTextParentNode
Constructs the node- Parameters:
children- The child nodes
-
-
Method Details
-
getCategories
Description copied from interface:WikiTextElementCategory links are leaf nodes but we want to include them as attributes of an article. This gives us three cases to consider:- Leaf nodes that are category links. We want to pass these up to the parent nodes. This is handled in Category objects.
- Other leaf nodes. These aren't categories and should return nothing. This is the default case in the WikiTextNode interface.
- Parent nodes. These aren't categories by themselves, and should return the union of the categories of their children. This is handled in WikiTextParent nodes
- Returns:
- A set of categories as strings.
-
getFieldValuesFromChildren
public static Set<String> getFieldValuesFromChildren(List<WikiTextNode> children, Function<? super WikiTextNode, Set<String>> getter) There is data that flow up to the root from leaf nodes. In this case we can think of it as the union of the child node data.- Parameters:
children- The child elements to get data from.getter- The function that gets the data- Returns:
- All data from the child elements.
-
rebuildWithContext
- Overrides:
rebuildWithContextin classWikiTextNode
-