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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addIdentifierReference(String referenceLocation, Identifier identifier)
Adds a reference to a target identifier.void
addTarget(String parentLocation, TargetType type, String location)
Indicates that a target was discovered in the subtree being validated.void
addTargetReference(String referenceLocation, String targetLocation)
Adds a reference from a label to a target.Map<String,ValidationTarget>
getBundles()
Collection<ValidationTarget>
getChildTargets(ValidationTarget parent)
Gets the locations of children of a given target.Map<String,ValidationTarget>
getCollections()
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.String
getIdentifierReferenceLocation(Identifier id, boolean orNearNeighbor)
Gets the location of where the given identifier is referenced.int
getLabelCount()
Gets the number of labels encountered so far.Collection<Identifier>
getReferencedIdentifiers()
Gets a collection of referenced identifiers.ValidationTarget
getRoot()
Gets the root location.int
getTargetCount(TargetType type)
Gets the number of targets encountered so far for a target type.String
getTargetForIdentifier(Identifier identifier, boolean orNearNeighbor)
Gets the location where an identifier was defined.Map<String,ValidationTarget>
getTargets()
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.boolean
hasTarget(String targetLocation)
Tests whether a target exists for a location.boolean
isIdentifierReferenced(Identifier identifier, boolean orNearNeighbor)
Tests whether an identifier was referenced.boolean
isTargetReferenced(String location)
Tests whether a target was referenced.void
setBundles(Map<String,ValidationTarget> bundles)
void
setCollections(Map<String,ValidationTarget> collections)
void
setTargetIdentifier(String location, Identifier identifier)
Sets an identifier for uniquely identifying the target.void
setTargetIsLabel(String location, boolean isLabel)
Indicates whether a target is a label.void
setTargets(Map<String,ValidationTarget> targets)
-
-
-
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 targettype
- the target typelocation
- 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 locationisLabel
- 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 locationidentifier
- the target identifier
-
addTargetReference
void addTargetReference(String referenceLocation, String targetLocation)
Adds a reference from a label to a target.- Parameters:
referenceLocation
- the label locationtargetLocation
- 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 referenceidentifier
- 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.
-
getCollections
Map<String,ValidationTarget> getCollections()
-
setCollections
void setCollections(Map<String,ValidationTarget> collections)
-
getBundles
Map<String,ValidationTarget> getBundles()
-
setBundles
void setBundles(Map<String,ValidationTarget> bundles)
-
getTargets
Map<String,ValidationTarget> getTargets()
-
setTargets
void setTargets(Map<String,ValidationTarget> targets)
-
-