Interface TypeResolver

    • Method Detail

      • resolveType

        Optional<MetadataType> resolveType​(String reference)
                                    throws TypeResolverException
        Returns the MetadataType of the specified type if found. The value of reference must be a conjunction of information where it could have the following pieces
        1. The type loader's ID
        2. The type identifier that might, or might not, contain a selector

        Lets see some examples on the premise that the TypeResolver was instantiated by 3 catalogs:

        1. one from an XML schema named "xml-types", with a targetNamespace="http://uri", and two elements named "User" and "Account"
        2. one from an JSON schema named "json-types", with a definition named "address"
        To use them, the reference must have one of the following values:
        • "xml-types::{http://uri}User": to reference the "User" element of the XML schema
        • "xml-types::{http://uri}Account": to reference the "Account" element of the XML schema
        • "xml-types::{http://uri}Account[]": to reference an array of "Account" element of the XML schema
        • "json-types::#/": to reference the complete JSON schema
        • "json-types::#/address": to reference the "address" type from within the JSON schema
        • "json-types": similarly to "json-types::#/", we will allow that reference to the type loader's ID will map to the root element of the schema (if possible). Useful for samples, and JSON schemas
        • "json-types[]": to reference an array of the type loader's ID will map to the root.

        Besides custom types loaders, the TypeResolver will held the responsibility of providing a fixed set of primitive types, see PrimitiveTypesTypeLoader.PRIMITIVE_TYPES. To reference them, the literal name will be enough:

        and so on..
        Parameters:
        reference - The identifier name of the type
        Returns:
        The type if found
        Throws:
        TypeResolverException - if the reference has a type loader's ID that is absent in the current manager.
      • createFrom

        static TypeResolver createFrom​(URL url,
                                       ClassLoader classLoader)
        Reads the entire file to properly load a TypeResolver
        Parameters:
        url - targeting the catalog's URLs location
        classLoader - context class loader where the catalog is being created
        Returns:
        a TypeResolver
      • createFrom

        static TypeResolver createFrom​(String data,
                                       ClassLoader classLoader)
        Reads the entire content to properly load a TypeResolver
        Parameters:
        data - content of an XML with the catalog's document
        classLoader - context class loader where the catalog is being created
        Returns:
        a TypeResolver