Package gov.nasa.pds.tools.validate
Class InMemoryRegistrar
java.lang.Object
gov.nasa.pds.tools.validate.InMemoryRegistrar
- All Implemented Interfaces:
TargetRegistrar
public class InMemoryRegistrar extends Object implements TargetRegistrar
-
Constructor Summary
Constructors Constructor Description InMemoryRegistrar()
-
Method Summary
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.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.String
getIdentifierReferenceLocation(Identifier id)
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)
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.boolean
hasTarget(String targetLocation)
Tests whether a target exists for a location.boolean
isIdentifierReferenced(Identifier identifier)
Tests whether an identifier was referenced.boolean
isTargetReferenced(String location)
Tests whether a target was referenced.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.
-
Constructor Details
-
InMemoryRegistrar
public InMemoryRegistrar()
-
-
Method Details
-
getRoot
Description copied from interface:TargetRegistrar
Gets the root location.- Specified by:
getRoot
in interfaceTargetRegistrar
- Returns:
- the root location
-
addTarget
Description copied from interface:TargetRegistrar
Indicates that a target was discovered in the subtree being validated.- Specified by:
addTarget
in interfaceTargetRegistrar
- Parameters:
parentLocation
- the parent target location, or null, if this is the root targettype
- the target typelocation
- the target location
-
getChildTargets
Description copied from interface:TargetRegistrar
Gets the locations of children of a given target.- Specified by:
getChildTargets
in interfaceTargetRegistrar
- Parameters:
parent
- the parent target- Returns:
- a collection of child targets
-
hasTarget
Description copied from interface:TargetRegistrar
Tests whether a target exists for a location.- Specified by:
hasTarget
in interfaceTargetRegistrar
- Parameters:
targetLocation
- the target location- Returns:
- true, if a target has been added for that location, false otherwise
-
getTargetCount
Description copied from interface:TargetRegistrar
Gets the number of targets encountered so far for a target type.- Specified by:
getTargetCount
in interfaceTargetRegistrar
- Parameters:
type
- the target type- Returns:
- the target count for the given type
-
setTargetIsLabel
Description copied from interface:TargetRegistrar
Indicates whether a target is a label.- Specified by:
setTargetIsLabel
in interfaceTargetRegistrar
- Parameters:
location
- the target locationisLabel
- true, if the target is a label
-
getLabelCount
public int getLabelCount()Description copied from interface:TargetRegistrar
Gets the number of labels encountered so far.- Specified by:
getLabelCount
in interfaceTargetRegistrar
- Returns:
- the label count
-
setTargetIdentifier
Description copied from interface:TargetRegistrar
Sets an identifier for uniquely identifying the target.- Specified by:
setTargetIdentifier
in interfaceTargetRegistrar
- Parameters:
location
- the target locationidentifier
- the target identifier
-
addTargetReference
Description copied from interface:TargetRegistrar
Adds a reference from a label to a target.- Specified by:
addTargetReference
in interfaceTargetRegistrar
- Parameters:
referenceLocation
- the label locationtargetLocation
- the target location referred to in the label
-
isTargetReferenced
Description copied from interface:TargetRegistrar
Tests whether a target was referenced.- Specified by:
isTargetReferenced
in interfaceTargetRegistrar
- Parameters:
location
- the target location- Returns:
- true, if the target was referenced
-
addIdentifierReference
Description copied from interface:TargetRegistrar
Adds a reference to a target identifier.- Specified by:
addIdentifierReference
in interfaceTargetRegistrar
- Parameters:
referenceLocation
- the location of the referenceidentifier
- the target identifier being referenced
-
isIdentifierReferenced
Description copied from interface:TargetRegistrar
Tests whether an identifier was referenced.- Specified by:
isIdentifierReferenced
in interfaceTargetRegistrar
- Parameters:
identifier
- the identifier- Returns:
- true, if the identifier was referenced
-
getTargetForIdentifier
Description copied from interface:TargetRegistrar
Gets the location where an identifier was defined.- Specified by:
getTargetForIdentifier
in interfaceTargetRegistrar
- Parameters:
identifier
- the identifier- Returns:
- the location where it was defined, or null if not defined
-
getIdentifierDefinitions
Description copied from interface:TargetRegistrar
Gets a mapping of identifiers to their locations.- Specified by:
getIdentifierDefinitions
in interfaceTargetRegistrar
- Returns:
- a mapping of identifiers to the location where it was defined.
-
getUnreferencedTargets
Description copied from interface:TargetRegistrar
Gets a collection of target locations that are never referenced.- Specified by:
getUnreferencedTargets
in interfaceTargetRegistrar
- Returns:
- a collection of unreferenced targets
-
getReferencedIdentifiers
Description copied from interface:TargetRegistrar
Gets a collection of referenced identifiers.- Specified by:
getReferencedIdentifiers
in interfaceTargetRegistrar
- Returns:
- a collection of referenced identifiers.
-
getUnreferencedIdentifiers
Description copied from interface:TargetRegistrar
Gets a collection of identifiers that are defined but never referenced.- Specified by:
getUnreferencedIdentifiers
in interfaceTargetRegistrar
- Returns:
- a collection of unreferenced identifiers
-
getDanglingReferences
Description copied from interface:TargetRegistrar
Gets a collection of identifiers that are referenced but not defined.- Specified by:
getDanglingReferences
in interfaceTargetRegistrar
- Returns:
- a collection of dangling identifier references
-
getIdentifierReferenceLocation
Description copied from interface:TargetRegistrar
Gets the location of where the given identifier is referenced.- Specified by:
getIdentifierReferenceLocation
in interfaceTargetRegistrar
- Parameters:
id
- The identifier to find.- Returns:
- The location where the given identifier is referenced.
-