lbownik commented on code in PR #6466:
URL: https://github.com/apache/netbeans/pull/6466#discussion_r1329061928


##########
java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java:
##########
@@ -949,6 +949,34 @@ static Pair<String,List<URL>> parseModulePatches(@NonNull 
final Iterator<? exten
         return null;
     }
 
+    public static URI getZipPathURI(URI zipURI, String resourceName) {
+        try {
+            //Optimistic try and see
+            return new URI ("jar:"+zipURI.toString()+"!/"+resourceName); 
//NOI18N
+        } catch (URISyntaxException e) {
+            //Need to encode the resName part (slower)
+            final StringBuilder sb = new StringBuilder ();
+            final String[] elements = resourceName.split("/");           
//NOI18N
+            try {
+                for (int i = 0; i< elements.length; i++) {

Review Comment:
   how about for-each loop?



##########
java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java:
##########
@@ -949,6 +949,34 @@ static Pair<String,List<URL>> parseModulePatches(@NonNull 
final Iterator<? exten
         return null;
     }
 
+    public static URI getZipPathURI(URI zipURI, String resourceName) {
+        try {
+            //Optimistic try and see
+            return new URI ("jar:"+zipURI.toString()+"!/"+resourceName); 
//NOI18N
+        } catch (URISyntaxException e) {
+            //Need to encode the resName part (slower)
+            final StringBuilder sb = new StringBuilder ();

Review Comment:
   how about?
   
    final StringBuilder sb = new StringBuilder 
(100).append("jar:").append(zipURI).append("!/");
   
   and then just 
   
   return new URI(sb.toString);



##########
java/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java:
##########
@@ -949,6 +949,34 @@ static Pair<String,List<URL>> parseModulePatches(@NonNull 
final Iterator<? exten
         return null;
     }
 
+    public static URI getZipPathURI(URI zipURI, String resourceName) {
+        try {
+            //Optimistic try and see
+            return new URI ("jar:"+zipURI.toString()+"!/"+resourceName); 
//NOI18N
+        } catch (URISyntaxException e) {
+            //Need to encode the resName part (slower)
+            final StringBuilder sb = new StringBuilder ();
+            final String[] elements = resourceName.split("/");           
//NOI18N
+            try {
+                for (int i = 0; i< elements.length; i++) {
+                    String element = elements[i];
+                    element = URLEncoder.encode(element, "UTF-8");       
//NOI18N
+                    element = element.replace("+", "%20");               
//NOI18N
+                    sb.append(element);
+                    if (i< elements.length - 1) {
+                        sb.append(NBFS_SEPARATOR_CHAR);
+                    }
+                }
+                return new URI("jar:"+zipURI.toString()+"!/"+sb.toString());   
 //NOI18N
+            } catch (final UnsupportedEncodingException e2) {

Review Comment:
   how about ?
   
   } catch (final UnsupportedEncodingException | URISyntaxException e2) {



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to