Package org.apache.jackrabbit.vault.util
Class PlatformNameFormat
- java.lang.Object
-
- org.apache.jackrabbit.vault.util.PlatformNameFormat
-
public class PlatformNameFormat extends 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.
-
-
Constructor Summary
Constructors Constructor Description PlatformNameFormat()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getPlatformName(String repositoryName)
Returns the platform name for a given repository name.static String
getPlatformPath(String repoPath)
Returns the platform path for the given repository one.static String
getRepositoryName(String platformName)
Returns the repository name for a given platform name.static String
getRepositoryPath(String path)
Returns the repository path for the given platform one.static String
getRepositoryPath(String path, boolean respectDotDir)
Returns the repository path for the given platform one.
-
-
-
Method Detail
-
getPlatformName
public static String getPlatformName(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 String getPlatformPath(String repoPath)
Returns the platform path for the given repository one.- Parameters:
repoPath
- the repository path- Returns:
- the platform path
-
getRepositoryName
public static String getRepositoryName(String platformName)
Returns the repository name for a given platform name.- Parameters:
platformName
- the platform name- Returns:
- the (unescaped) repository name.
-
getRepositoryPath
public static String getRepositoryPath(String path)
Returns the repository path for the given platform one.- Parameters:
path
- the platform path- Returns:
- the repository path
-
-