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
All Methods Instance Methods Concrete 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
public ValidationTarget getRoot()
Description copied from interface:TargetRegistrar
Gets the root location.- Specified by:
getRoot
in interfaceTargetRegistrar
- Returns:
- the root location
-
addTarget
public void addTarget(String parentLocation, TargetType type, String location)
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
public Collection<ValidationTarget> getChildTargets(ValidationTarget parent)
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
public boolean hasTarget(String targetLocation)
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
public int getTargetCount(TargetType type)
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
public void setTargetIsLabel(String location, boolean isLabel)
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
public void setTargetIdentifier(String location, Identifier identifier)
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
public void addTargetReference(String referenceLocation, String targetLocation)
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
public boolean isTargetReferenced(String location)
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
public void addIdentifierReference(String referenceLocation, Identifier identifier)
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
public boolean isIdentifierReferenced(Identifier identifier, boolean orNearNeighbor)
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
public String getTargetForIdentifier(Identifier identifier, boolean orNearNeighbor)
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
public Map<Identifier,String> 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
public Collection<String> 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
public Collection<Identifier> getReferencedIdentifiers()
Description copied from interface:TargetRegistrar
Gets a collection of referenced identifiers.- Specified by:
getReferencedIdentifiers
in interfaceTargetRegistrar
- Returns:
- a collection of referenced identifiers.
-
getUnreferencedIdentifiers
public Collection<Identifier> 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
public Collection<IdentifierReference> 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
public String getIdentifierReferenceLocation(Identifier id, boolean orNearNeighbor)
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.
-
getCollections
public Map<String,ValidationTarget> getCollections()
- Specified by:
getCollections
in interfaceTargetRegistrar
-
setCollections
public void setCollections(Map<String,ValidationTarget> collections)
- Specified by:
setCollections
in interfaceTargetRegistrar
-
getBundles
public Map<String,ValidationTarget> getBundles()
- Specified by:
getBundles
in interfaceTargetRegistrar
-
setBundles
public void setBundles(Map<String,ValidationTarget> bundles)
- Specified by:
setBundles
in interfaceTargetRegistrar
-
getTargets
public Map<String,ValidationTarget> getTargets()
- Specified by:
getTargets
in interfaceTargetRegistrar
-
setTargets
public void setTargets(Map<String,ValidationTarget> targets)
- Specified by:
setTargets
in interfaceTargetRegistrar
-
-