Record Class TopicHeader

java.lang.Object
java.lang.Record
network.ike.docs.plugin.registry.TopicHeader
Record Components:
file - the file, relative to the scan root, with / separators
topic - whether the file declares a :topic-id: before its heading
id - the topic id, or null for a file that is not a topic
title - the first heading's text: the level-1 heading for a topic; for any other file the first heading of any level, so a chapter file that starts at == still has a title
level - the heading level of title() (1 for =), or 0 when the file has no heading
attributes - every :topic-*: attribute in declaration order, keyed without the topic- prefix
documentAttributes - every other :name: value attribute in the header, before the heading or in the contiguous block after it (doctype, toc, ...), in order
anchor - present, missing or mismatched for a topic; null for other files
charCount - characters from the anchor line (or the heading, when there is no anchor) to the end of the file
includes - the number of include:: lines in the file
findings - what is wrong with the header, empty when nothing is

public record TopicHeader(String file, boolean topic, String id, String title, int level, Map<String,String> attributes, Map<String,String> documentAttributes, String anchor, long charCount, int includes, List<String> findings) extends Record
The parsed header of one AsciiDoc file: the :topic-*: attribute block, the anchor and the level-1 heading, read line by line without AsciidoctorJ. The layout is the one IKE-ASCIIDOC-FRAGMENT.md prescribes: an optional comment header, the attribute block (values may continue on the next line with a trailing backslash), a literal [[anchor]] equal to the topic id, then = Title.

A file with no :topic-id: before its heading is not a topic; it is recorded as an assembly (when it carries include:: lines) or a plain file, with its title and document attributes, and gets no header findings. Every kind of module the doc pipeline renders is covered: topic libraries, assemblies, doc-only and hybrid projects.

Since:
109
  • Field Details

    • REQUIRED

      public static final List<String> REQUIRED
      Attributes every topic must declare, without the topic- prefix.
    • TYPES

      public static final Set<String> TYPES
      The topic types IKE-TOPIC-REGISTRY.md allows, plus procedure, which ike-doc-ingest writes for task topics.
    • STATUSES

      public static final Set<String> STATUSES
      The topic statuses IKE-TOPIC-REGISTRY.md allows.
  • Constructor Details

    • TopicHeader

      public TopicHeader(String file, boolean topic, String id, String title, int level, Map<String,String> attributes, Map<String,String> documentAttributes, String anchor, long charCount, int includes, List<String> findings)
      Creates an instance of a TopicHeader record class.
      Parameters:
      file - the value for the file record component
      topic - the value for the topic record component
      id - the value for the id record component
      title - the value for the title record component
      level - the value for the level record component
      attributes - the value for the attributes record component
      documentAttributes - the value for the documentAttributes record component
      anchor - the value for the anchor record component
      charCount - the value for the charCount record component
      includes - the value for the includes record component
      findings - the value for the findings record component
  • Method Details

    • parse

      public static TopicHeader parse(Path file, Path root) throws IOException
      Parse one file.
      Parameters:
      file - the file to read, UTF-8
      root - the scan root the file lies under; file() is expressed relative to it
      Returns:
      the parsed header
      Throws:
      IOException - if the file cannot be read
    • parse

      public static TopicHeader parse(String relative, String content)
      Parse file content already in memory.
      Parameters:
      relative - the file's path relative to its scan root
      content - the file content
      Returns:
      the parsed header
    • missingRequired

      public List<String> missingRequired()
      The required attributes this header lacks, in the order of REQUIRED.
      Returns:
      the missing attribute names without the topic- prefix
    • keywords

      public List<String> keywords()
      The :topic-keywords: value split on commas and trimmed.
      Returns:
      the keywords, empty when the attribute is absent
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • file

      public String file()
      Returns the value of the file record component.
      Returns:
      the value of the file record component
    • topic

      public boolean topic()
      Returns the value of the topic record component.
      Returns:
      the value of the topic record component
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • title

      public String title()
      Returns the value of the title record component.
      Returns:
      the value of the title record component
    • level

      public int level()
      Returns the value of the level record component.
      Returns:
      the value of the level record component
    • attributes

      public Map<String,String> attributes()
      Returns the value of the attributes record component.
      Returns:
      the value of the attributes record component
    • documentAttributes

      public Map<String,String> documentAttributes()
      Returns the value of the documentAttributes record component.
      Returns:
      the value of the documentAttributes record component
    • anchor

      public String anchor()
      Returns the value of the anchor record component.
      Returns:
      the value of the anchor record component
    • charCount

      public long charCount()
      Returns the value of the charCount record component.
      Returns:
      the value of the charCount record component
    • includes

      public int includes()
      Returns the value of the includes record component.
      Returns:
      the value of the includes record component
    • findings

      public List<String> findings()
      Returns the value of the findings record component.
      Returns:
      the value of the findings record component