Class GlobalNameMapper

  • All Implemented Interfaces:
    NameMapper
    Direct Known Subclasses:
    LocalNameMapper

    public class GlobalNameMapper
    extends java.lang.Object
    implements NameMapper
    Name mapper with no local prefix remappings. URI to prefix mappings are read from the repository when for transforming expanded JCR names to prefixed Oak names.

    Note that even though this class could be used to verify that all prefixed names have valid prefixes, we explicitly don't do that since this is a fairly performance-sensitive part of the codebase and since normally the NameValidator and other consistency checks already ensure that all names being committed or already in the repository should be valid. A separate consistency check can be used if needed to locate and fix any Oak names with invalid namespace prefixes.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @NotNull java.lang.String getJcrName​(@NotNull java.lang.String oakName)
      Returns the JCR name for the given Oak name.
      protected java.lang.String getNamespacesProperty​(java.lang.String prefix)  
      @NotNull java.lang.String getOakName​(@NotNull java.lang.String jcrName)
      Returns the Oak name for the specified JCR name.
      protected @Nullable java.lang.String getOakNameFromExpanded​(java.lang.String expandedName)  
      @Nullable java.lang.String getOakNameOrNull​(@NotNull java.lang.String jcrName)
      Returns the Oak name for the given JCR name, or null if no such mapping exists because the given JCR name contains an unknown namespace URI or prefix, or is otherwise invalid.
      protected @Nullable java.lang.String getOakPrefixOrNull​(java.lang.String uri)  
      protected @Nullable java.lang.String getOakURIOrNull​(java.lang.String prefix)  
      protected java.lang.Iterable<java.lang.String> getPrefixes()  
      @NotNull java.util.Map<java.lang.String,​java.lang.String> getSessionLocalMappings()
      Returns the local namespace prefix mappings, or an empty map if there aren't any local mappings.
      protected static boolean isExpandedName​(java.lang.String name)  
      protected static boolean isHiddenName​(java.lang.String name)  
      void onSessionRefresh()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GlobalNameMapper

        public GlobalNameMapper​(Root root)
      • GlobalNameMapper

        public GlobalNameMapper​(NodeState root)
      • GlobalNameMapper

        public GlobalNameMapper​(java.util.Map<java.lang.String,​java.lang.String> mappings)
    • Method Detail

      • isHiddenName

        protected static boolean isHiddenName​(java.lang.String name)
      • isExpandedName

        protected static boolean isExpandedName​(java.lang.String name)
      • getJcrName

        @NotNull
        public @NotNull java.lang.String getJcrName​(@NotNull
                                                    @NotNull java.lang.String oakName)
        Description copied from interface: NameMapper
        Returns the JCR name for the given Oak name. The given name is expected to have come from a valid Oak repository that contains only valid names with proper namespace mappings. If that's not the case, either a programming error or a repository corruption has occurred and an appropriate unchecked exception gets thrown.
        Specified by:
        getJcrName in interface NameMapper
        Parameters:
        oakName - Oak name
        Returns:
        JCR name
      • getOakNameOrNull

        @Nullable
        public @Nullable java.lang.String getOakNameOrNull​(@NotNull
                                                           @NotNull java.lang.String jcrName)
        Description copied from interface: NameMapper
        Returns the Oak name for the given JCR name, or null if no such mapping exists because the given JCR name contains an unknown namespace URI or prefix, or is otherwise invalid.
        Specified by:
        getOakNameOrNull in interface NameMapper
        Parameters:
        jcrName - JCR name
        Returns:
        Oak name, or null
      • getOakName

        @NotNull
        public @NotNull java.lang.String getOakName​(@NotNull
                                                    @NotNull java.lang.String jcrName)
                                             throws RepositoryException
        Description copied from interface: NameMapper
        Returns the Oak name for the specified JCR name. In contrast to NameMapper.getOakNameOrNull(String) this method will throw a RepositoryException if the JCR name is invalid and cannot be resolved.
        Specified by:
        getOakName in interface NameMapper
        Parameters:
        jcrName - The JCR name to be converted.
        Returns:
        A valid Oak name.
        Throws:
        RepositoryException - If the JCR name cannot be resolved.
      • getSessionLocalMappings

        @NotNull
        public @NotNull java.util.Map<java.lang.String,​java.lang.String> getSessionLocalMappings()
        Description copied from interface: NameMapper
        Returns the local namespace prefix mappings, or an empty map if there aren't any local mappings.
        Specified by:
        getSessionLocalMappings in interface NameMapper
        Returns:
        local namespace prefix to URI mappings
      • getOakNameFromExpanded

        @Nullable
        protected @Nullable java.lang.String getOakNameFromExpanded​(java.lang.String expandedName)
      • getOakPrefixOrNull

        @Nullable
        protected @Nullable java.lang.String getOakPrefixOrNull​(java.lang.String uri)
      • getOakURIOrNull

        @Nullable
        protected @Nullable java.lang.String getOakURIOrNull​(java.lang.String prefix)
      • getNamespacesProperty

        protected java.lang.String getNamespacesProperty​(java.lang.String prefix)
      • getPrefixes

        protected java.lang.Iterable<java.lang.String> getPrefixes()
      • onSessionRefresh

        public void onSessionRefresh()