Class CategoryLink
java.lang.Object
com.lucaskjaerozhang.wikitext_parser.ast.base.WikiTextNode
com.lucaskjaerozhang.wikitext_parser.ast.base.WikiTextParentNode
com.lucaskjaerozhang.wikitext_parser.ast.link.WikiLink
com.lucaskjaerozhang.wikitext_parser.ast.link.CategoryLink
- All Implemented Interfaces:
WikiTextElement
A special type of wikilink that places articles within categories.
WikiText: [[:category]] or [[:category|display]]
XML: category
WikiText: [[:category]] or [[:category|display]]
XML: category
-
Constructor Summary
ConstructorsConstructorDescriptionCategoryLink(WikiLinkTarget linkTarget, List<WikiTextNode> linkText, boolean visible) Creates a category link. -
Method Summary
Modifier and TypeMethodDescription<T> Optional<T>accept(WikiTextASTVisitor<T> visitor) Hook for an AST visitor.Category links are leaf nodes but we want to include them as attributes of an article.Methods inherited from class com.lucaskjaerozhang.wikitext_parser.ast.link.WikiLink
getAttributes, getAutomaticallyReformattedDisplayNameMethods inherited from class com.lucaskjaerozhang.wikitext_parser.ast.base.WikiTextParentNode
getFieldValuesFromChildren, rebuildWithContext
-
Constructor Details
-
CategoryLink
Creates a category link.- Parameters:
linkTarget- Which article to link to.linkText- What text to display on the linkvisible- Whether the link should be visible at all.
-
-
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
- Specified by:
getCategoriesin interfaceWikiTextElement- Overrides:
getCategoriesin classWikiTextParentNode- Returns:
- A set of categories as strings.
-
accept
Description copied from class:WikiTextNodeHook for an AST visitor.
-