Package gov.nasa.pds.tools.dict
Class Dictionary
- java.lang.Object
-
- gov.nasa.pds.tools.dict.Dictionary
-
- All Implemented Interfaces:
Serializable
public class Dictionary extends Object implements Serializable
This class represents a PDS data dictionary.- Version:
- $Revision$
- Author:
- pramirez, jagander
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Pattern
VERSION_REGEX
-
Constructor Summary
Constructors Constructor Description Dictionary()
Dictionary(File dictionaryFile)
Dictionary(URI dictionaryURI)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDefinition(Definition definition)
Adds a definition to this dictionary.void
addDefinitions(Collection<Definition> defs)
Adds a list of definitions to this dictionary.void
addProblem(LabelParserException exception)
void
addProblems(List<LabelParserException> exceptions)
void
clearProblems()
boolean
containsDefinition(DictIdentifier identifier)
Tests to see whether or not a definition existsboolean
containsElementDefinition(DictIdentifier identifier)
Tests to see whether or not an element is definedboolean
containsElementDefinition(String objectContext, DictIdentifier identifier)
boolean
containsGroupDefinition(DictIdentifier identifier)
Tests to see whether or not a group is definedboolean
containsObjectDefinition(DictIdentifier identifier)
Tests to see whether or not an object is definedGroupDefinition
findGroupClassDefinition(DictIdentifier identifier)
Retrieves the class definition for a group with the given identifier.ObjectDefinition
findObjectClassDefinition(DictIdentifier identifier)
Retrieves the class definition for an object with the given identifier.Definition
getDefinition(DictIdentifier identifier)
Retrieves the definition from the dictionary or null if not foundprotected Map<DictIdentifier,Definition>
getDefinitions()
Retrieves the map of definitionsFile
getDictionaryFile()
URI
getDictionaryURI()
ElementDefinition
getElementDefinition(DictIdentifier identifier)
Retrieves the element definition from the dictionary or null if not found.ElementDefinition
getElementDefinition(String objectContext, DictIdentifier identifier)
GroupDefinition
getGroupDefinition(DictIdentifier identifier)
Retrieves the group definition from the dictionary or null if not foundString
getInformation()
Return the dictionary's descriptive information.List<SimpleDictionaryChange>
getMergeChanges()
ObjectDefinition
getObjectDefinition(DictIdentifier identifier)
Retrieves the object definition from the dictionary or null if not foundList<LabelParserException>
getProblems()
String
getSourceString()
Map<String,String>
getUnits()
String
getVersion()
void
merge(Dictionary dictionary)
Merges the definitions in the dictionariesvoid
setInformation(String information)
Sets the description information for a dictionary.void
setUnits(Map<String,String> units)
-
-
-
Field Detail
-
VERSION_REGEX
public static final Pattern VERSION_REGEX
-
-
Method Detail
-
getDictionaryURI
public URI getDictionaryURI()
-
getDictionaryFile
public File getDictionaryFile()
-
getSourceString
public String getSourceString()
-
getVersion
public String getVersion()
-
merge
public void merge(Dictionary dictionary)
Merges the definitions in the dictionaries- Parameters:
dictionary
- to be merged into this dictionary. dictionary merged in will override values in this dictionary if scalars or be added if lists
-
containsDefinition
public boolean containsDefinition(DictIdentifier identifier)
Tests to see whether or not a definition exists- Parameters:
identifier
- of the definition- Returns:
- flag indicating existence
-
containsObjectDefinition
public boolean containsObjectDefinition(DictIdentifier identifier)
Tests to see whether or not an object is defined- Parameters:
identifier
- of the object- Returns:
- flag indicating existence
-
containsGroupDefinition
public boolean containsGroupDefinition(DictIdentifier identifier)
Tests to see whether or not a group is defined- Parameters:
identifier
- of the the group- Returns:
- flag indicating existence
-
containsElementDefinition
public boolean containsElementDefinition(DictIdentifier identifier)
Tests to see whether or not an element is defined- Parameters:
identifier
- of the element- Returns:
- flag indicating existence
-
containsElementDefinition
public boolean containsElementDefinition(String objectContext, DictIdentifier identifier)
-
getDefinition
public Definition getDefinition(DictIdentifier identifier)
Retrieves the definition from the dictionary or null if not found- Parameters:
identifier
- of the definition- Returns:
- the definition
-
getObjectDefinition
public ObjectDefinition getObjectDefinition(DictIdentifier identifier)
Retrieves the object definition from the dictionary or null if not found- Parameters:
identifier
- of the definition- Returns:
- the object definition
-
getGroupDefinition
public GroupDefinition getGroupDefinition(DictIdentifier identifier)
Retrieves the group definition from the dictionary or null if not found- Parameters:
identifier
- of the definition- Returns:
- the group definition
-
getElementDefinition
public ElementDefinition getElementDefinition(DictIdentifier identifier)
Retrieves the element definition from the dictionary or null if not found.- Parameters:
identifier
- of the definition- Returns:
- the element definition
-
getElementDefinition
public ElementDefinition getElementDefinition(String objectContext, DictIdentifier identifier)
-
addDefinition
public void addDefinition(Definition definition)
Adds a definition to this dictionary.- Parameters:
definition
- to be added to the dictionary
-
setInformation
public void setInformation(String information)
Sets the description information for a dictionary. This is often captured informally in comments at the top of a dictionary file.- Parameters:
information
-
-
getInformation
public String getInformation()
Return the dictionary's descriptive information.- Returns:
- the information
-
addDefinitions
public void addDefinitions(Collection<Definition> defs)
Adds a list of definitions to this dictionary. The flag indicates whether the definitions should be overwritten.- Parameters:
defs
- to be added to the dictionary
-
findObjectClassDefinition
public ObjectDefinition findObjectClassDefinition(DictIdentifier identifier)
Retrieves the class definition for an object with the given identifier. This method will search the dictionary for an ObjectDefinition whose identifier is the greatest length and matches the end of the given identifier- Parameters:
identifier
- to lookup up class of- Returns:
ObjectDefinition
of class that will constrain object with given identifier. Returns null if not found.
-
getDefinitions
protected Map<DictIdentifier,Definition> getDefinitions()
Retrieves the map of definitions- Returns:
- the map of definitions.
-
findGroupClassDefinition
public GroupDefinition findGroupClassDefinition(DictIdentifier identifier)
Retrieves the class definition for a group with the given identifier. This method will search the dictionary for a GroupDefinition whose identifier is the greatest length and matches the end of the given identifier- Parameters:
identifier
- to lookup up class of- Returns:
GroupDefinition
of class that will constrain object with given identifier. Returns null if not found.
-
getMergeChanges
public List<SimpleDictionaryChange> getMergeChanges()
-
addProblem
public void addProblem(LabelParserException exception)
-
addProblems
public void addProblems(List<LabelParserException> exceptions)
-
getProblems
public List<LabelParserException> getProblems()
-
clearProblems
public void clearProblems()
-
-