Class UniqueAnchorNamesValidator

  • All Implemented Interfaces:
    java.lang.AutoCloseable, Markup, Sink

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

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • usedAnchorNames

        private final java.util.Set<java.lang.String> usedAnchorNames
    • Constructor Detail

      • UniqueAnchorNamesValidator

        public UniqueAnchorNamesValidator​(Sink sink)
    • Method Detail

      • anchor

        public void anchor​(java.lang.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.