Interface TargetRegistrar

  • All Known Implementing Classes:
    InMemoryRegistrar

    public interface TargetRegistrar
    Defines an interface for keeping track of validation targets and their attributes.

    The registrar enables answering these questions:

    • Is every target either a label or have a reference from a label?
    • Does every referenced identifier (e.g., PDS4 LID) have a definition in some target?
    • Is any identifier defined twice?
    • Method Detail

      • getRoot

        ValidationTarget getRoot()
        Gets the root location.
        Returns:
        the root location
      • addTarget

        void addTarget​(String parentLocation,
                       TargetType type,
                       String location)
        Indicates that a target was discovered in the subtree being validated.
        Parameters:
        parentLocation - the parent target location, or null, if this is the root target
        type - the target type
        location - the target location
      • getChildTargets

        Collection<ValidationTarget> getChildTargets​(ValidationTarget parent)
        Gets the locations of children of a given target.
        Parameters:
        parent - the parent target
        Returns:
        a collection of child targets
      • hasTarget

        boolean hasTarget​(String targetLocation)
        Tests whether a target exists for a location.
        Parameters:
        targetLocation - the target location
        Returns:
        true, if a target has been added for that location, false otherwise
      • getTargetCount

        int getTargetCount​(TargetType type)
        Gets the number of targets encountered so far for a target type.
        Parameters:
        type - the target type
        Returns:
        the target count for the given type
      • setTargetIsLabel

        void setTargetIsLabel​(String location,
                              boolean isLabel)
        Indicates whether a target is a label.
        Parameters:
        location - the target location
        isLabel - true, if the target is a label
      • getLabelCount

        int getLabelCount()
        Gets the number of labels encountered so far.
        Returns:
        the label count
      • setTargetIdentifier

        void setTargetIdentifier​(String location,
                                 Identifier identifier)
        Sets an identifier for uniquely identifying the target.
        Parameters:
        location - the target location
        identifier - the target identifier
      • addTargetReference

        void addTargetReference​(String referenceLocation,
                                String targetLocation)
        Adds a reference from a label to a target.
        Parameters:
        referenceLocation - the label location
        targetLocation - the target location referred to in the label
      • isTargetReferenced

        boolean isTargetReferenced​(String location)
        Tests whether a target was referenced.
        Parameters:
        location - the target location
        Returns:
        true, if the target was referenced
      • addIdentifierReference

        void addIdentifierReference​(String referenceLocation,
                                    Identifier identifier)
        Adds a reference to a target identifier.
        Parameters:
        referenceLocation - the location of the reference
        identifier - the target identifier being referenced
      • isIdentifierReferenced

        boolean isIdentifierReferenced​(Identifier identifier,
                                       boolean orNearNeighbor)
        Tests whether an identifier was referenced.
        Parameters:
        identifier - the identifier
        Returns:
        true, if the identifier was referenced
      • getTargetForIdentifier

        String getTargetForIdentifier​(Identifier identifier,
                                      boolean orNearNeighbor)
        Gets the location where an identifier was defined.
        Parameters:
        identifier - the identifier
        Returns:
        the location where it was defined, or null if not defined
      • getIdentifierDefinitions

        Map<Identifier,​String> getIdentifierDefinitions()
        Gets a mapping of identifiers to their locations.
        Returns:
        a mapping of identifiers to the location where it was defined.
      • getUnreferencedTargets

        Collection<String> getUnreferencedTargets()
        Gets a collection of target locations that are never referenced.
        Returns:
        a collection of unreferenced targets
      • getUnreferencedIdentifiers

        Collection<Identifier> getUnreferencedIdentifiers()
        Gets a collection of identifiers that are defined but never referenced.
        Returns:
        a collection of unreferenced identifiers
      • getDanglingReferences

        Collection<IdentifierReference> getDanglingReferences()
        Gets a collection of identifiers that are referenced but not defined.
        Returns:
        a collection of dangling identifier references
      • getReferencedIdentifiers

        Collection<Identifier> getReferencedIdentifiers()
        Gets a collection of referenced identifiers.
        Returns:
        a collection of referenced identifiers.
      • getIdentifierReferenceLocation

        String getIdentifierReferenceLocation​(Identifier id,
                                              boolean orNearNeighbor)
        Gets the location of where the given identifier is referenced.
        Parameters:
        id - The identifier to find.
        Returns:
        The location where the given identifier is referenced.