Skip to content

Commit

Permalink
Merge pull request #4400 from matthias-ronge/patch-43
Browse files Browse the repository at this point in the history
Improve Javadoc
  • Loading branch information
Kathrin-Huber authored May 20, 2021
2 parents 5b3a60e + 01edd81 commit 4d359f0
Showing 1 changed file with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@
import org.kitodo.config.KitodoConfig;

/**
* Class for performing mapping and unmapping of URIs.
* Contains functions to turn a relative URI into an absolute one and vice
* versa.
*
* <p>
* The name of this class can be misleading: the mapper contains no mapping and
* no entry is added to or removed from a mapping.
*/
class FileMapper {

/**
* Map relative URI to absolute kitodo data directory URI.
* Maps a relative URI an absolute URI below the Kitodo data directory.
*
* @param uri
* relative path
Expand All @@ -44,6 +49,23 @@ URI unmapUriFromKitodoDataDirectoryUri(URI uri) {
return unmapDirectory(uri, KitodoConfig.getKitodoDataDirectory());
}

/**
* Creates a URI relative to {@code directory} if {@code directory} appears
* in the URI string; otherwise the URI is returned unchanged. The relative
* URI is generated by trimming the URI string to the part after
* {@code directory}.
*
* <p>
* The name of this method is misleading: there is no mapping stored
* anywhere, and URI is not unregistered from a mapping. Usually such a
* function is called relativize.
*
* @param uri
* absolute path
* @param directory
* Kitodo data directory
* @return relative URI path
*/
private URI unmapDirectory(URI uri, String directory) {
String path = uri.toString();
directory = encodeDirectory(directory);
Expand Down

0 comments on commit 4d359f0

Please sign in to comment.