Class NamespaceRegistryModel


  • public final class NamespaceRegistryModel
    extends Object
    A model of the namespace registry, containing the mappings from prefixes to namespace URIs and vice versa.

    The model is created from the namespace registry stored in the repository. It can be used to check the consistency of the registry, repair it if possible, and apply the changes back to the repository.

    • Method Detail

      • setMappings

        public NamespaceRegistryModel setMappings​(@NotNull
                                                  @NotNull Map<String,​String> additionalPrefixToUrisMappings)
        Creates a new NamespaceRegistryModel with the given mappings. Used by {@see NamespaceRegistryCommand} to repair a namespace registry that cannot be fixed automatically because mapping information is missing.
        Parameters:
        additionalPrefixToUrisMappings - a map from prefixes to namespace URIs
        Returns:
        a new NamespaceRegistryModel
      • tryRegistryRepair

        public NamespaceRegistryModel tryRegistryRepair()
        Tries to repair the namespace registry model by fixing the mappings from prefixes to namespace URIs and vice versa. If the model is not fixable, it returns the original model.
        Returns:
        a new NamespaceRegistryModel with fixed mappings or the original model if it cannot be fixed
      • isConsistent

        public boolean isConsistent()
      • isFixable

        public boolean isFixable()
      • getDanglingPrefixes

        public Set<String> getDanglingPrefixes()
        Prefixes that are registered, but not mapped to or from a namespace uri. This kind of inconsistency cannot be fixed automatically, because the namespace uri corresponding to the prefix is unknown. Apply the setMappings(Map) method to create a new model with the missing mappings.
      • getDanglingEncodedNamespaceUris

        public Set<String> getDanglingEncodedNamespaceUris()
        Namespace uris that are registered, but not mapped to or from a prefix. This kind of inconsistency cannot be fixed automatically, because the prefix corresponding to the namespace uri is unknown. Apply the setMappings(Map) method to create a new model with the missing mappings.
      • getRepairedMappings

        public Map<String,​String> getRepairedMappings()
        Broken mappings completed with the missing prefix or namespace uri.
      • dump

        public void dump()
                  throws IOException
        Write a human-readable analysis of the namespace registry model to System.out.
        Throws:
        IOException
      • dump

        public void dump​(OutputStream out)
                  throws IOException
        Write a human-readable analysis of the namespace registry model to the given OutputStream.
        Parameters:
        out - the output stream to write to
        Throws:
        IOException - if an error occurs while writing to the output stream