Package gov.nasa.pds.tools.validate
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 Summary
Modifier and Type Method Description voidaddIdentifierReference(String referenceLocation, Identifier identifier)Adds a reference to a target identifier.voidaddTarget(String parentLocation, TargetType type, String location)Indicates that a target was discovered in the subtree being validated.voidaddTargetReference(String referenceLocation, String targetLocation)Adds a reference from a label to a target.Collection<ValidationTarget>getChildTargets(ValidationTarget parent)Gets the locations of children of a given target.Collection<IdentifierReference>getDanglingReferences()Gets a collection of identifiers that are referenced but not defined.Map<Identifier,String>getIdentifierDefinitions()Gets a mapping of identifiers to their locations.StringgetIdentifierReferenceLocation(Identifier id)Gets the location of where the given identifier is referenced.intgetLabelCount()Gets the number of labels encountered so far.Collection<Identifier>getReferencedIdentifiers()Gets a collection of referenced identifiers.ValidationTargetgetRoot()Gets the root location.intgetTargetCount(TargetType type)Gets the number of targets encountered so far for a target type.StringgetTargetForIdentifier(Identifier identifier)Gets the location where an identifier was defined.Collection<Identifier>getUnreferencedIdentifiers()Gets a collection of identifiers that are defined but never referenced.Collection<String>getUnreferencedTargets()Gets a collection of target locations that are never referenced.booleanhasTarget(String targetLocation)Tests whether a target exists for a location.booleanisIdentifierReferenced(Identifier identifier)Tests whether an identifier was referenced.booleanisTargetReferenced(String location)Tests whether a target was referenced.voidsetTargetIdentifier(String location, Identifier identifier)Sets an identifier for uniquely identifying the target.voidsetTargetIsLabel(String location, boolean isLabel)Indicates whether a target is a label.
-
Method Details
-
getRoot
ValidationTarget getRoot()Gets the root location.- Returns:
- the root location
-
addTarget
Indicates that a target was discovered in the subtree being validated.- Parameters:
parentLocation- the parent target location, or null, if this is the root targettype- the target typelocation- the target location
-
getChildTargets
Gets the locations of children of a given target.- Parameters:
parent- the parent target- Returns:
- a collection of child targets
-
hasTarget
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
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
Indicates whether a target is a label.- Parameters:
location- the target locationisLabel- true, if the target is a label
-
getLabelCount
int getLabelCount()Gets the number of labels encountered so far.- Returns:
- the label count
-
setTargetIdentifier
Sets an identifier for uniquely identifying the target.- Parameters:
location- the target locationidentifier- the target identifier
-
addTargetReference
Adds a reference from a label to a target.- Parameters:
referenceLocation- the label locationtargetLocation- the target location referred to in the label
-
isTargetReferenced
Tests whether a target was referenced.- Parameters:
location- the target location- Returns:
- true, if the target was referenced
-
addIdentifierReference
Adds a reference to a target identifier.- Parameters:
referenceLocation- the location of the referenceidentifier- the target identifier being referenced
-
isIdentifierReferenced
Tests whether an identifier was referenced.- Parameters:
identifier- the identifier- Returns:
- true, if the identifier was referenced
-
getTargetForIdentifier
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
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.
-