Class UniqueAnchorNamesValidator

All Implemented Interfaces:
AutoCloseable, Markup, Sink

public class UniqueAnchorNamesValidator extends SinkWrapper
Validates that each anchor name only appears once per document. Otherwise logs a warning.
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • usedAnchorNames

      private final Set<String> usedAnchorNames
  • Constructor Details

    • UniqueAnchorNamesValidator

      public UniqueAnchorNamesValidator(Sink sink)
  • Method Details

    • anchor

      public void anchor(String name, SinkEventAttributes attributes)
      Description copied from interface: Sink
      Starts an element which defines an anchor.

      The name parameter has to be a valid SGML NAME token. According to the HTML 4.01 specification section 6.2 SGML basic types:

      ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

      Supported attributes are the base attributes. If NAME is specified in the SinkEventAttributes, it will be overwritten by the name parameter.

      Specified by:
      anchor in interface Sink
      Overrides:
      anchor in class SinkWrapper
      Parameters:
      name - the name of the anchor. This has to be a valid SGML NAME token.
      attributes - A set of SinkEventAttributes, may be null.