Class PlatformNameFormat


  • public class PlatformNameFormat
    extends java.lang.Object
    Implements a repository to platform name formatter.

    Illegal characters a generally escaped using the url escaping format, i.e. replacing the char by a '%' hex(char) sequence. special treatment is used for the ':' char since it's used quite often as namespace prefix separator. the PREFIX ':' NAME sequence is replaced by '_' PREFIX '_' NAME. item names that would generate the same pattern are escaped with an extra leading '_'.

    Examples:

     +-------------------+----------------------+----+----+
     | repository name   | platform name        | pp | sp |
     +-------------------+----------------------+----+----+
     | test.jpg          | test.jpg             | -1 | -1 |
     | cq:content        | _cq_content          |  2 | -1 |
     | cq:test_image.jpg | _cq_test_image.jpg   |  2 |  7 |
     | test_image.jpg    | test_image.jpg       | -1 |  4 |
     | _testimage.jpg    | _testimage.jpg       | -1 |  0 |
     | _test_image.jpg   | __test_image.jpg     | -1 |  0 |
     +-------------------+----------------------+----+----+
     | cq:test:image.jpg | _cq_test%3aimage.jpg |  2 | -1 |
     | _cq_:test.jpg     | __cq_%3atest.jpg     |  4 |  0 |
     | _cq:test.jpg      | __cq%3atest.jpg      |  3 |  0 |
     | cq_:test.jpg      | cq_%3atest.jpg       |  3 |  2 |
     +-------------------+----------------------+----+----+
     
    note for the 2nd set of examples the cases are very rare and justify the ugly '%' escaping.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getPlatformName​(java.lang.String repositoryName)
      Returns the platform name for a given repository name.
      static java.lang.String getPlatformPath​(java.lang.String repoPath)
      Returns the platform path for the given repository one.
      static java.lang.String getRepositoryName​(java.lang.String platformName)
      Returns the repository name for a given platform name.
      static java.lang.String getRepositoryPath​(java.lang.String path)
      Returns the repository path for the given platform one.
      static java.lang.String getRepositoryPath​(java.lang.String path, boolean respectDotDir)
      Returns the repository path for the given platform one.
      • Methods inherited from class java.lang.Object

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

      • PlatformNameFormat

        public PlatformNameFormat()
    • Method Detail

      • getPlatformName

        public static java.lang.String getPlatformName​(java.lang.String repositoryName)
        Returns the platform name for a given repository name. Unsupported characters are URL escaped (i.e. %xx). Note: Forward slashes '/' are not escaped since they never occur in a jcr name. so this method can also be used to encode paths.
        Parameters:
        repositoryName - the repository name
        Returns:
        the (escaped) platform name.
      • getPlatformPath

        public static java.lang.String getPlatformPath​(java.lang.String repoPath)
        Returns the platform path for the given repository one.
        Parameters:
        repoPath - the repository path
        Returns:
        the platform path
      • getRepositoryName

        public static java.lang.String getRepositoryName​(java.lang.String platformName)
        Returns the repository name for a given platform name.
        Parameters:
        platformName - the platform name
        Returns:
        the (unescaped) repository name.
      • getRepositoryPath

        public static java.lang.String getRepositoryPath​(java.lang.String path)
        Returns the repository path for the given platform one.
        Parameters:
        path - the platform path
        Returns:
        the repository path
      • getRepositoryPath

        public static java.lang.String getRepositoryPath​(java.lang.String path,
                                                         boolean respectDotDir)
        Returns the repository path for the given platform one.
        Parameters:
        path - the platform path
        respectDotDir - if true, all ".dir" are removed.
        Returns:
        the repository path