Class YamlMappingLoader
java.lang.Object
org.openehealth.ipf.commons.map.yaml.YamlMappingLoader
- All Implemented Interfaces:
MappingLoader
MappingLoader for *.mapping.yaml files: the same model as the XML format, about
40% fewer keystrokes, and comments that survive - which matters for mapping files that record
the code system each code came from next to it.
Property names are bound strictly, so keysystem for keySystem is an error at
startup with a line and a column rather than a null found in production later. The JSON Schema
shipped at META-INF/ipf/mapping-schema.json covers the same rules for an editor; refer
to it from a mapping file with
# yaml-language-server: $schema=http://openehealth.org/schema/ipf-commons-map.jsonand IntelliJ and VS Code validate while the file is being typed. It is not used at runtime, which is why the loader repeats its constraints in code.
Values are strings. A YAML scalar that parses as a number or a boolean is rejected rather than
coerced: AGN: 1004 is how an entire mapping came to return Integers where every
other one returned Strings, and AGN: "1004" is unambiguous.
- Since:
- 6.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionformat()Short, stable identifier of the format this loader reads, e.g.load(InputStream in, URI source, MappingFunctionRegistry functions) Reads all mappings contained in one source document.booleanWhether this loader claims a source that nobody named a format for.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MappingLoader
load
-
Field Details
-
EXTENSION
-
SHORT_EXTENSION
Also accepted, for people whose editors expect it.- See Also:
-
FORMAT
Format id under which this loader can be selected explicitly.- See Also:
-
-
Constructor Details
-
YamlMappingLoader
public YamlMappingLoader()
-
-
Method Details
-
format
Description copied from interface:MappingLoaderShort, stable identifier of the format this loader reads, e.g.xml,yamlorconceptmap-r4-json. It is what a caller names to select this loader regardless of the source's file extension, and it is compared case-insensitively.Two loaders on one classpath must not share a format id, since the id is what picks one of them; qualify it the way
conceptmap-r4-jsondoes when a format has versions or encodings that a second loader might read.- Specified by:
formatin interfaceMappingLoader- Returns:
- the format id, never
nullor blank
-
supports
Description copied from interface:MappingLoaderWhether this loader claims a source that nobody named a format for. Implementations decide by file extension: a source it cannot recognize from its name alone is not its own, even if it could read the content, because that is what keeps dispatch predictable.- Specified by:
supportsin interfaceMappingLoader- Parameters:
source- location of the mapping source, used for its file extension- Returns:
- whether this loader can read the given source
-
load
public List<Mapping> load(InputStream in, URI source, MappingFunctionRegistry functions) throws IOException Description copied from interface:MappingLoaderReads all mappings contained in one source document.- Specified by:
loadin interfaceMappingLoader- Parameters:
in- the source content; the caller closes the streamsource- location of the source, for diagnosticsfunctions- registry a loader may add functions to, and against which it should validate anyUnmatched.Computedreference it produces- Returns:
- the mappings read, in declaration order
- Throws:
IOException- if the source cannot be read
-