diff options
author | Sven Gothel <[email protected]> | 2023-05-20 14:31:39 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-05-20 14:31:39 +0200 |
commit | e96f9b0c05b9fd5e47f55c2079271d6969a27a80 (patch) | |
tree | b7e19af5c7dab6cf4ed2ec94f6e99a068c707b58 /src/java/com/jogamp/common | |
parent | 7f8dcc310cfb8b3eb1e026ce9aeb73471e223d8a (diff) |
JarUtil.getRelativeOf(): Make'cutOffInclSubDir' optional, i.e. ignore if null in case no sub-directory is desired
Diffstat (limited to 'src/java/com/jogamp/common')
-rw-r--r-- | src/java/com/jogamp/common/util/JarUtil.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/java/com/jogamp/common/util/JarUtil.java b/src/java/com/jogamp/common/util/JarUtil.java index d621e1c..9dc0fb6 100644 --- a/src/java/com/jogamp/common/util/JarUtil.java +++ b/src/java/com/jogamp/common/util/JarUtil.java @@ -418,14 +418,25 @@ public class JarUtil { * <pre> * class's jar url path + cutOffInclSubDir + relResPath, * </pre> + * or with <code>cutOffInclSubDir</code> being <code>null</code> just + * <pre> + * class's jar url path + relResPath, + * </pre> * Example #1 * <pre> * classFromJavaJar = com.lighting.Test (in: file:/storage/TestLighting.jar) + * cutOffInclSubDir = null + * relResPath = LightAssets.jar + * Result : file:/storage/LightAssets.jar + * </pre> + * Example #2 + * <pre> + * classFromJavaJar = com.lighting.Test (in: file:/storage/TestLighting.jar) * cutOffInclSubDir = lights/ * relResPath = LightAssets.jar * Result : file:/storage/lights/LightAssets.jar * </pre> - * Example #2 + * Example #3 * <pre> * classFromJavaJar = com.lighting.Test (in: file:/storage/lights/TestLighting.jar) * cutOffInclSubDir = lights/ @@ -436,8 +447,9 @@ public class JarUtil { * TODO: Enhance documentation! * * @param classFromJavaJar Used to get the root Uri for the class's Jar Uri. - * @param cutOffInclSubDir The <i>cut off</i> included sub-directory prepending the relative resource path. + * @param cutOffInclSubDir Optional <i>cut off</i> included sub-directory prepending the relative resource path. * If the root Uri includes cutOffInclSubDir, it is no more added to the result. + * Parameter will be ignored if <code>null</code>. * @param relResPath The relative resource path. (Uri encoded) * @return The resulting resource Uri, which is not tested. * @throws IllegalArgumentException @@ -451,7 +463,6 @@ public class JarUtil { System.err.println("JarUtil.getRelativeOf: "+"(classFromJavaJar "+classFromJavaJar+", classJarUri "+classJarUri+ ", cutOffInclSubDir "+cutOffInclSubDir+", relResPath "+relResPath+"): "); } - final Uri jarSubUri = classJarUri.getContainedUri(); if(null == jarSubUri) { throw new IllegalArgumentException("JarSubUri is null of: "+classJarUri); @@ -460,9 +471,8 @@ public class JarUtil { if( DEBUG ) { System.err.println("JarUtil.getRelativeOf: "+"uri "+jarSubUri.toString()+" -> "+jarUriRoot); } - final Uri.Encoded resUri; - if( jarUriRoot.endsWith(cutOffInclSubDir.get()) ) { + if( null == cutOffInclSubDir || jarUriRoot.endsWith(cutOffInclSubDir.get()) ) { resUri = jarUriRoot.concat(relResPath); } else { resUri = jarUriRoot.concat(cutOffInclSubDir).concat(relResPath); @@ -470,7 +480,6 @@ public class JarUtil { if( DEBUG ) { System.err.println("JarUtil.getRelativeOf: "+"... -> "+resUri); } - final Uri resJarUri = JarUtil.getJarFileUri(resUri); if( DEBUG ) { System.err.println("JarUtil.getRelativeOf: "+"fin "+resJarUri); |