Package org.incenp.obofoundry.sssom
Class SSSOMReader
java.lang.Object
org.incenp.obofoundry.sssom.SSSOMReader
- Direct Known Subclasses:
JSONReader
,RDFReader
,TSVReader
Base class to read a mapping set from any of the supported serialisation
formats.
This class should be derived into specialised classes that implement a precise serialisation format.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Version
protected ExtraMetadataPolicy
protected PropagationPolicy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
fillPrefixMap
(Map<String, String> map) Declares all prefix names in the specified map.abstract MappingSet
read()
Reads a mapping set from the source file.void
setAssumedVersion
(Version version) Sets the version of the SSSOM specification that the reader should assume the set is compliant with, if the set does not have asssom_version
slot.void
Sets the policy to deal with non-standard metadata in the input file.void
setPropagationEnabled
(boolean enabled) Enables or disables the propagation of "propagatable slots".void
setValidation
(ValidationLevel validationType) Controls whether a mapping set should be validated after it has been parsed, and how.void
setValidationEnabled
(boolean enabled) Enables or disables post-parsing validation of mappings.protected void
validate
(MappingSet mappingSet) Validates a mapping set.
-
Field Details
-
extraPolicy
-
propagationPolicy
-
assumedVersion
-
-
Constructor Details
-
SSSOMReader
public SSSOMReader()
-
-
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
.
-
setPropagationEnabled
public void setPropagationEnabled(boolean enabled) Enables or disables the propagation of "propagatable slots".- Parameters:
enabled
-False
to disable propagation; it is enabled by default.
-
setAssumedVersion
Sets the version of the SSSOM specification that the reader should assume the set is compliant with, if the set does not have asssom_version
slot. The default is to assume that the set is compliant with version 1.0, as mandated by the specification.This parameter has no effect if the set does have a
sssom_version
slot: in that case, the set will be expected to be compliant with the version indicated in that slot.- Parameters:
version
- The SSSOM version a set is assumed to be compliant with.
-
setValidationEnabled
public void setValidationEnabled(boolean enabled) Enables or disables post-parsing validation of mappings.- Parameters:
enabled
-False
to disable validation; it is enabled by default.
-
setValidation
Controls whether a mapping set should be validated after it has been parsed, and how.This method provides a finer control than
setValidationEnabled(boolean)
, which simply enables full validation or disables validation entirely.- Parameters:
validationType
- The level of validation to use; set toValidationLevel.DISABLED
to disable validation entirely; the default isValidationLevel.FULL
.
-
fillPrefixMap
Declares all prefix names in the specified map. Prefix names declared here complement the declarations from the file’s own prefix map, allowing the reader to parse a file with an incomplete prefix map.It is up to concrete implementations to actually do something with that map. Some of them may ignore it.
- Parameters:
map
- The prefix map to use.
-
read
Reads a mapping set from the source file.- Returns:
- A complete SSSOM mapping set.
- Throws:
SSSOMFormatException
- If encountering invalid SSSOM data.IOException
- If any kind of non-SSSOM-related I/O error occurs.
-
validate
Validates a mapping set. This method performs all post-parsing checks to ensure the mapping set is valid according to the SSSOM specification.- Parameters:
mappingSet
- The set to validate. It should be called by theread
method in concrete derived classes.- Throws:
SSSOMFormatException
- If the mapping set is invalid.
-