Class PlatformNameFormat
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetPlatformName(String repositoryName) Returns the platform name for a given repository name.static StringgetPlatformPath(String repoPath) Returns the platform path for the given repository one.static StringgetRepositoryName(String platformName) Returns the repository name for a given platform name.static StringgetRepositoryPath(String path) Returns the repository path for the given platform one.static StringgetRepositoryPath(String path, boolean respectDotDir) Returns the repository path for the given platform one.
-
Constructor Details
-
PlatformNameFormat
public PlatformNameFormat()
-
-
Method Details
-
getPlatformName
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
Returns the platform path for the given repository one.- Parameters:
repoPath- the repository path- Returns:
- the platform path
-
getRepositoryName
Returns the repository name for a given platform name.The returned name is validated to still address a single repository path segment: a platform name whose percent-escapes decode to
'/'(e.g.a%2fb) or to a'.'/'..'segment (e.g.%2e%2e) is rejected, because the repository would resolve the decoded result to a different path than every string-level check (workspace filter coverage, subpackage detection, validation) has seen.getPlatformName(String)escapes'/'and'%', so no legitimately exported platform name ever decodes to one of the rejected forms.- Parameters:
platformName- the platform name- Returns:
- the (unescaped) repository name.
- Throws:
IllegalArgumentException- if the decoded name is empty,".",".."or contains a'/'
-
getRepositoryPath
Returns the repository path for the given platform one.- Parameters:
path- the platform path- Returns:
- the repository path
-
getRepositoryPath
Returns the repository path for the given platform one.- Parameters:
path- the platform pathrespectDotDir- iftrue, all ".dir" are removed.- Returns:
- the repository path
-