Class NamespaceRegistryModel


  • public final class NamespaceRegistryModel
    extends java.lang.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 Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void apply​(Root root)
      Applies this namespace registry model to the given repository Root.
      static @Nullable NamespaceRegistryModel create​(@NotNull Root root)
      Creates a new NamespaceRegistryModel from the namespace registry stored in the system tree under the given repository Root.
      void dump()
      Write a human-readable analysis of the namespace registry model to System.out.
      void dump​(java.io.OutputStream out)
      Write a human-readable analysis of the namespace registry model to the given OutputStream.
      void dump​(java.io.Writer out)  
      java.util.Set<java.lang.String> getDanglingEncodedNamespaceUris()
      Namespace uris that are registered, but not mapped to or from a prefix.
      java.util.Set<java.lang.String> getDanglingPrefixes()
      Prefixes that are registered, but not mapped to or from a namespace uri.
      java.util.Map<java.lang.String,​java.lang.String> getRepairedMappings()
      Broken mappings completed with the missing prefix or namespace uri.
      boolean isConsistent()  
      boolean isFixable()  
      NamespaceRegistryModel setMappings​(@NotNull java.util.Map<java.lang.String,​java.lang.String> additionalPrefixToUrisMappings)
      Creates a new NamespaceRegistryModel with the given mappings.
      NamespaceRegistryModel tryRegistryRepair()
      Tries to repair the namespace registry model by fixing the mappings from prefixes to namespace URIs and vice versa.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setMappings

        public NamespaceRegistryModel setMappings​(@NotNull
                                                  @NotNull java.util.Map<java.lang.String,​java.lang.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
      • apply

        public void apply​(Root root)
                   throws javax.jcr.RepositoryException,
                          CommitFailedException
        Applies this namespace registry model to the given repository Root.
        Parameters:
        root - the root of the repository
        Throws:
        javax.jcr.RepositoryException - if an error occurs while applying the changes
        CommitFailedException - if the commit fails
      • isConsistent

        public boolean isConsistent()
      • isFixable

        public boolean isFixable()
      • getDanglingPrefixes

        public java.util.Set<java.lang.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 java.util.Set<java.lang.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 java.util.Map<java.lang.String,​java.lang.String> getRepairedMappings()
        Broken mappings completed with the missing prefix or namespace uri.
      • dump

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

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

        public void dump​(java.io.Writer out)
                  throws java.io.IOException
        Throws:
        java.io.IOException