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 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.
-
Constructor Details
-
InMemoryRegistrar
public InMemoryRegistrar()
-
-
Method Details
-
getRoot
Description copied from interface:TargetRegistrarGets the root location.- Specified by:
getRootin interfaceTargetRegistrar- Returns:
- the root location
-
addTarget
Description copied from interface:TargetRegistrarIndicates that a target was discovered in the subtree being validated.- Specified by:
addTargetin 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:TargetRegistrarGets the locations of children of a given target.- Specified by:
getChildTargetsin interfaceTargetRegistrar- Parameters:
parent- the parent target- Returns:
- a collection of child targets
-
hasTarget
Description copied from interface:TargetRegistrarTests whether a target exists for a location.- Specified by:
hasTargetin interfaceTargetRegistrar- Parameters:
targetLocation- the target location- Returns:
- true, if a target has been added for that location, false otherwise
-
getTargetCount
Description copied from interface:TargetRegistrarGets the number of targets encountered so far for a target type.- Specified by:
getTargetCountin interfaceTargetRegistrar- Parameters:
type- the target type- Returns:
- the target count for the given type
-
setTargetIsLabel
Description copied from interface:TargetRegistrarIndicates whether a target is a label.- Specified by:
setTargetIsLabelin interfaceTargetRegistrar- Parameters:
location- the target locationisLabel- true, if the target is a label
-
getLabelCount
public int getLabelCount()Description copied from interface:TargetRegistrarGets the number of labels encountered so far.- Specified by:
getLabelCountin interfaceTargetRegistrar- Returns:
- the label count
-
setTargetIdentifier
Description copied from interface:TargetRegistrarSets an identifier for uniquely identifying the target.- Specified by:
setTargetIdentifierin interfaceTargetRegistrar- Parameters:
location- the target locationidentifier- the target identifier
-
addTargetReference
Description copied from interface:TargetRegistrarAdds a reference from a label to a target.- Specified by:
addTargetReferencein interfaceTargetRegistrar- Parameters:
referenceLocation- the label locationtargetLocation- the target location referred to in the label
-
isTargetReferenced
Description copied from interface:TargetRegistrarTests whether a target was referenced.- Specified by:
isTargetReferencedin interfaceTargetRegistrar- Parameters:
location- the target location- Returns:
- true, if the target was referenced
-
addIdentifierReference
Description copied from interface:TargetRegistrarAdds a reference to a target identifier.- Specified by:
addIdentifierReferencein interfaceTargetRegistrar- Parameters:
referenceLocation- the location of the referenceidentifier- the target identifier being referenced
-
isIdentifierReferenced
Description copied from interface:TargetRegistrarTests whether an identifier was referenced.- Specified by:
isIdentifierReferencedin interfaceTargetRegistrar- Parameters:
identifier- the identifier- Returns:
- true, if the identifier was referenced
-
getTargetForIdentifier
Description copied from interface:TargetRegistrarGets the location where an identifier was defined.- Specified by:
getTargetForIdentifierin interfaceTargetRegistrar- Parameters:
identifier- the identifier- Returns:
- the location where it was defined, or null if not defined
-
getIdentifierDefinitions
Description copied from interface:TargetRegistrarGets a mapping of identifiers to their locations.- Specified by:
getIdentifierDefinitionsin interfaceTargetRegistrar- Returns:
- a mapping of identifiers to the location where it was defined.
-
getUnreferencedTargets
Description copied from interface:TargetRegistrarGets a collection of target locations that are never referenced.- Specified by:
getUnreferencedTargetsin interfaceTargetRegistrar- Returns:
- a collection of unreferenced targets
-
getReferencedIdentifiers
Description copied from interface:TargetRegistrarGets a collection of referenced identifiers.- Specified by:
getReferencedIdentifiersin interfaceTargetRegistrar- Returns:
- a collection of referenced identifiers.
-
getUnreferencedIdentifiers
Description copied from interface:TargetRegistrarGets a collection of identifiers that are defined but never referenced.- Specified by:
getUnreferencedIdentifiersin interfaceTargetRegistrar- Returns:
- a collection of unreferenced identifiers
-
getDanglingReferences
Description copied from interface:TargetRegistrarGets a collection of identifiers that are referenced but not defined.- Specified by:
getDanglingReferencesin interfaceTargetRegistrar- Returns:
- a collection of dangling identifier references
-
getIdentifierReferenceLocation
Description copied from interface:TargetRegistrarGets the location of where the given identifier is referenced.- Specified by:
getIdentifierReferenceLocationin interfaceTargetRegistrar- Parameters:
id- The identifier to find.- Returns:
- The location where the given identifier is referenced.
-