Package org.incenp.linkml.core
Class PrefixDeclarationExtractor
- java.lang.Object
-
- org.incenp.linkml.core.PrefixDeclarationExtractor
-
public class PrefixDeclarationExtractor extends Object
A helper class to extract prefix declarations from a raw object.This class is intended to support the mechanism tentatively outlined in LinkML ticket #1114, where instance data can declare their own prefixes (supplementing or overriding the prefixes emitted by the schema itself) using an ad-hoc data structure that can be recognized by the fact that it contains two slots with the
shacl:prefixandshacl:namespaceURIs.The LinkML meta model is already an example of that mechanism being used: a schema definition can (and most often, will indeed) have a
prefixessection holding a list ofPrefixinstances.
-
-
Constructor Summary
Constructors Constructor Description PrefixDeclarationExtractor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,String>extractPrefixes(Map<String,Object> rawMap, Object dest, ConverterContext ctx)Extracts prefix declarations from the raw representation of a LinkML object.static PrefixDeclarationExtractorgetExtractor(ClassInfo klass)Gets a prefix declaration extractor (if possible) for the specified LinkML class.
-
-
-
Method Detail
-
getExtractor
public static PrefixDeclarationExtractor getExtractor(ClassInfo klass)
Gets a prefix declaration extractor (if possible) for the specified LinkML class.This method will examine the class to check whether it contains a slot intended to hold prefix declarations.
- Parameters:
klass- The object representing the LinkML class to check.- Returns:
- An extractor that can extract prefix declarations from an instance of
the given class, or
nullif the class has no slot for prefix declarations.
-
extractPrefixes
public Map<String,String> extractPrefixes(Map<String,Object> rawMap, Object dest, ConverterContext ctx) throws LinkMLRuntimeException
Extracts prefix declarations from the raw representation of a LinkML object.- Parameters:
rawMap- The raw map representing the LinkML object from which to extract prefix declarations. If it does contain the key expected to hold prefix declarations, it will be removed from the map.dest- The instance of the LinkML object that will hold the extracted prefix declarations.ctx- The global converter context.- Returns:
- A map with the extracted prefix (empty if there are no prefix declarations in the raw map).
- Throws:
LinkMLRuntimeException- If any error occurs when attempting to convert the prefix declarations.
-
-