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 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.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.StringgetIdentifierReferenceLocation(Identifier id, boolean orNearNeighbor)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, 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.booleanhasTarget(String targetLocation)Tests whether a target exists for a location.booleanisIdentifierReferenced(Identifier identifier, boolean orNearNeighbor)Tests whether an identifier was referenced.booleanisTargetReferenced(String location)Tests whether a target was referenced.voidsetBundles(Map<String,ValidationTarget> bundles)voidsetCollections(Map<String,ValidationTarget> collections)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.voidsetTargets(Map<String,ValidationTarget> targets)
-
-
-
Method Detail
-
getRoot
public ValidationTarget getRoot()
Description copied from interface:TargetRegistrarGets the root location.- Specified by:
getRootin interfaceTargetRegistrar- Returns:
- the root location
-
addTarget
public void addTarget(String parentLocation, TargetType type, String location)
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
public Collection<ValidationTarget> getChildTargets(ValidationTarget parent)
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
public boolean hasTarget(String targetLocation)
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
public int getTargetCount(TargetType type)
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
public void setTargetIsLabel(String location, boolean isLabel)
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
public void setTargetIdentifier(String location, Identifier identifier)
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
public void addTargetReference(String referenceLocation, String targetLocation)
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
public boolean isTargetReferenced(String location)
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
public void addIdentifierReference(String referenceLocation, Identifier identifier)
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
public boolean isIdentifierReferenced(Identifier identifier, boolean orNearNeighbor)
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
public String getTargetForIdentifier(Identifier identifier, boolean orNearNeighbor)
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
public Map<Identifier,String> 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
public Collection<String> 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
public Collection<Identifier> getReferencedIdentifiers()
Description copied from interface:TargetRegistrarGets a collection of referenced identifiers.- Specified by:
getReferencedIdentifiersin interfaceTargetRegistrar- Returns:
- a collection of referenced identifiers.
-
getUnreferencedIdentifiers
public Collection<Identifier> 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
public Collection<IdentifierReference> 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
public String getIdentifierReferenceLocation(Identifier id, boolean orNearNeighbor)
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.
-
getCollections
public Map<String,ValidationTarget> getCollections()
- Specified by:
getCollectionsin interfaceTargetRegistrar
-
setCollections
public void setCollections(Map<String,ValidationTarget> collections)
- Specified by:
setCollectionsin interfaceTargetRegistrar
-
getBundles
public Map<String,ValidationTarget> getBundles()
- Specified by:
getBundlesin interfaceTargetRegistrar
-
setBundles
public void setBundles(Map<String,ValidationTarget> bundles)
- Specified by:
setBundlesin interfaceTargetRegistrar
-
getTargets
public Map<String,ValidationTarget> getTargets()
- Specified by:
getTargetsin interfaceTargetRegistrar
-
setTargets
public void setTargets(Map<String,ValidationTarget> targets)
- Specified by:
setTargetsin interfaceTargetRegistrar
-
-