Class CategoryLink

All Implemented Interfaces:
WikiTextElement

public class CategoryLink extends WikiLink
A special type of wikilink that places articles within categories.
WikiText: [[:category]] or [[:category|display]]
XML: category
  • Constructor Details

    • CategoryLink

      public CategoryLink(WikiLinkTarget linkTarget, List<WikiTextNode> linkText, boolean visible)
      Creates a category link.
      Parameters:
      linkTarget - Which article to link to.
      linkText - What text to display on the link
      visible - Whether the link should be visible at all.
  • Method Details

    • getCategories

      public Set<String> getCategories()
      Description copied from interface: WikiTextElement
      Category links are leaf nodes but we want to include them as attributes of an article. This gives us three cases to consider:
      1. Leaf nodes that are category links. We want to pass these up to the parent nodes. This is handled in Category objects.
      2. Other leaf nodes. These aren't categories and should return nothing. This is the default case in the WikiTextNode interface.
      3. 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:
      getCategories in interface WikiTextElement
      Overrides:
      getCategories in class WikiTextParentNode
      Returns:
      A set of categories as strings.
    • accept

      public <T> Optional<T> accept(WikiTextASTVisitor<T> visitor)
      Description copied from class: WikiTextNode
      Hook for an AST visitor.
      Overrides:
      accept in class WikiLink
      Type Parameters:
      T - Whatever the visitor produces.
      Parameters:
      visitor - The visitor doing the visitor.
      Returns:
      Whatever the visitor produced.