Class 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:prefix and shacl:namespace URIs.

    The LinkML meta model is already an example of that mechanism being used: a schema definition can (and most often, will indeed) have a prefixes section holding a list of Prefix instances.

    • Constructor Detail

      • PrefixDeclarationExtractor

        public PrefixDeclarationExtractor()
    • 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 null if 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.