Package org.incenp.obofoundry.sssom
Class YAMLConverter
java.lang.Object
org.incenp.obofoundry.sssom.YAMLConverter
A helper class to convert generic YAML dictionaries into SSSOM objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertMapping
(Map<String, Object> rawMap) Converts a generic dictionary (as may have been obtained from a YAML or JSON parser) into aMapping
object.convertMapping
(Map<String, Object> rawMap, Version targetVersion) Converts a generic dictionary (as may have been obtained from a YAML or JSON parser) into aMapping
object.convertMappingSet
(Map<String, Object> rawMap) Converts a generic dictionary (as may have been obtained from a YAML or JSON parser) into aMappingSet
object.Gets the prefix manager used by this object to expand shortened entity references in values.static boolean
Checks that an object is a list containing items of a given type.static boolean
Checks that an object is a dictionary with string keys and values of a given type.void
Finalise the conversion of a set.void
setAssumedVersion
(Version version) Sets the version of the SSSOM specification that a set should be assumed to be compliant with, in the absence of an explicitsssom_version
slot.void
Sets the policy to deal with non-standard metadata in the input file.
-
Constructor Details
-
YAMLConverter
public YAMLConverter()Creates a new YAML converter.
-
-
Method Details
-
setExtraMetadataPolicy
Sets the policy to deal with non-standard metadata in the input file.- Parameters:
policy
- The policy instructing the parser about what to do when encountering non-standard metadata. The default policy isExtraMetadataPolicy.NONE
.
-
setAssumedVersion
Sets the version of the SSSOM specification that a set should be assumed to be compliant with, in the absence of an explicitsssom_version
slot.- Parameters:
version
- The assumed default version.
-
isListOf
Checks that an object is a list containing items of a given type.- Parameters:
value
- The object whose runtime type is to be checked.type
- The expected runtime type of the list's values.- Returns:
true
if the object is aList
whose items are of the expected type, otherwisefalse
.
-
isMapOf
Checks that an object is a dictionary with string keys and values of a given type. -
getPrefixManager
Gets the prefix manager used by this object to expand shortened entity references in values.- Returns:
- The prefix manager.
-
convertMappingSet
Converts a generic dictionary (as may have been obtained from a YAML or JSON parser) into aMappingSet
object.- Parameters:
rawMap
- The dictionary to convert.- Returns:
- The corresponding mapping set object.
- Throws:
SSSOMFormatException
- If the contents of the dictionary does not match the SSSOM format and data model, even after compatibility processing.
-
convertMapping
Converts a generic dictionary (as may have been obtained from a YAML or JSON parser) into aMapping
object.This method assumes the mapping is compliant with the highest supported version of the specification.
- Parameters:
rawMap
- The dictionary to convert.- Returns:
- The corresponding mapping object.
- Throws:
SSSOMFormatException
- If the contents of the dictionary does not match the SSSOM format and data model, even after compatibility processing.
-
convertMapping
public Mapping convertMapping(Map<String, Object> rawMap, Version targetVersion) throws SSSOMFormatExceptionConverts a generic dictionary (as may have been obtained from a YAML or JSON parser) into aMapping
object.- Parameters:
rawMap
- The dictionary to convert.targetVersion
- The version of the SSSOM specification the mapping is compliant with.- Returns:
- The corresponding mapping object.
- Throws:
SSSOMFormatException
- If the contents of the dictionary does not match the SSSOM format and data model, even after compatibility processing.
-
postMappings
Finalise the conversion of a set. This method should be called once all individual mappings have been converted through calls toconvertMapping(Map)
. There is no need to call this method if the mappings were already present in the raw map passed toconvertMappingSet(Map)
.- Parameters:
ms
- The mapping set to finalise.
-