~ubuntu-branches/ubuntu/vivid/gluegen2/vivid-proposed

« back to all changes in this revision

Viewing changes to src/java/com/jogamp/common/util/JarUtil.java

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-12-17 09:29:23 UTC
  • mfrom: (9.1.18 sid)
  • Revision ID: package-import@ubuntu.com-20131217092923-19w78uqxd15jic2u
Tags: 2.1.3-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
                final URL _url = resolver.resolve( url );
155
155
                uri = _url.toURI();
156
156
                if(DEBUG) {
157
 
                    System.out.println("getJarURI Resolver: "+url+"\n\t-> "+_url+"\n\t-> "+uri);
 
157
                    System.err.println("getJarURI Resolver: "+url+"\n\t-> "+_url+"\n\t-> "+uri);
158
158
                }
159
159
            } else {
160
160
                uri = url.toURI();
161
161
                if(DEBUG) {
162
 
                    System.out.println("getJarURI Default "+url+"\n\t-> "+uri);
 
162
                    System.err.println("getJarURI Default "+url+"\n\t-> "+uri);
163
163
                }
164
164
            }
165
165
        }
168
168
            throw new IllegalArgumentException("URI is not using scheme "+IOUtil.JAR_SCHEME+": <"+uri+">");
169
169
        }
170
170
        if(DEBUG) {
171
 
            System.out.println("getJarURI res: "+clazzBinName+" -> "+url+" -> "+uri);
 
171
            System.err.println("getJarURI res: "+clazzBinName+" -> "+url+" -> "+uri);
172
172
        }
173
173
        return uri;
174
174
    }
200
200
        //   file:/some/path/gluegen-rt.jar!/com/jogamp/common/util/cache/TempJarCache.class
201
201
        // to
202
202
        //   file:/some/path/gluegen-rt.jar
203
 
        int idx = uriS.lastIndexOf('!');
 
203
        int idx = uriS.lastIndexOf(IOUtil.JAR_SCHEME_SEPARATOR);
204
204
        if (0 <= idx) {
205
205
            uriS = uriS.substring(0, idx); // exclude '!/'
206
206
        } else {
207
 
            throw new IllegalArgumentException("JAR URI does not contain jar uri terminator '!', in <"+classJarURI+">");
 
207
            throw new IllegalArgumentException("URI does not contain jar uri terminator '!', in <"+classJarURI+">");
208
208
        }
209
209
 
210
210
        // from
216
216
            // no abs-path, check for protocol terminator ':'
217
217
            idx = uriS.lastIndexOf(':');
218
218
            if(0 > idx) {
219
 
                throw new IllegalArgumentException("JAR URI does not contain protocol terminator ':', in <"+classJarURI+">");
 
219
                throw new IllegalArgumentException("URI does not contain protocol terminator ':', in <"+classJarURI+">");
220
220
            }
221
221
        }
222
222
        uriS = uriS.substring(idx+1); // just the jar name
225
225
            throw new IllegalArgumentException("No Jar name in <"+classJarURI+">");
226
226
        }
227
227
        if(DEBUG) {
228
 
            System.out.println("getJarName res: "+uriS);
 
228
            System.err.println("getJarName res: "+uriS);
229
229
        }
230
230
        return uriS;
231
231
    }
277
277
        // to
278
278
        //   file:/some/path/gluegen-rt.jar
279
279
        final String uriS0 = classJarURI.getSchemeSpecificPart();
280
 
        int idx = uriS0.lastIndexOf('!');
 
280
        int idx = uriS0.lastIndexOf(IOUtil.JAR_SCHEME_SEPARATOR);
281
281
        final String uriS1;
282
282
        if (0 <= idx) {
283
283
            uriS1 = uriS0.substring(0, idx); // exclude '!/'
287
287
        if(0 >= uriS1.lastIndexOf(".jar")) {
288
288
            throw new IllegalArgumentException("No Jar name in <"+classJarURI+">");
289
289
        }
290
 
        final String uriS2 = IOUtil.encodeToURI(uriS1);
 
290
        final String uriS2 = IOUtil.encodeToURI(uriS1); // 'new URI(String)' will not encode space!
291
291
        if(DEBUG) {
292
 
            System.out.println("getJarSubURI res: "+classJarURI+" -> "+uriS0+" -> "+uriS1+" -> "+uriS2);
 
292
            System.err.println("getJarSubURI res: "+classJarURI+" -> "+uriS0+" -> "+uriS1+" -> "+uriS2);
293
293
        }
294
294
        return new URI(uriS2);
295
295
    }
310
310
        if( !classJarURI.getScheme().equals(IOUtil.JAR_SCHEME) ) {
311
311
            throw new IllegalArgumentException("URI is not a using scheme "+IOUtil.JAR_SCHEME+": <"+classJarURI+">");
312
312
        }
313
 
        String uriS = classJarURI.getSchemeSpecificPart();
 
313
        // final String uriS = classJarURI.toString(); // getSchemeSpecificPart(); ignore fragment !
 
314
        final String uriS = classJarURI.getSchemeSpecificPart();
314
315
 
315
316
        // from
316
317
        //   file:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class
317
318
        // to
318
 
        //   file:/some/path/gluegen-rt.jar
319
 
        int idx = uriS.lastIndexOf('!');
 
319
        //   /com/jogamp/common/GlueGenVersion.class
 
320
        final int idx = uriS.lastIndexOf(IOUtil.JAR_SCHEME_SEPARATOR);
320
321
        if (0 <= idx) {
321
 
            return uriS.substring(idx+1); // right of '!'
 
322
            final String res = uriS.substring(idx+1); // right of '!'
 
323
            if(DEBUG) {
 
324
                System.err.println("getJarEntry res: "+classJarURI+" -> "+uriS+" -> "+idx+" -> "+res);
 
325
            }
 
326
            return res;
322
327
        } else {
323
328
            throw new IllegalArgumentException("JAR URI does not contain jar uri terminator '!', uri <"+classJarURI+">");
324
329
        }
366
371
        }
367
372
        final URI uri = new URI(IOUtil.JAR_SCHEME, getJarSubURI(clazzBinName, cl).toString()+"!/", null);
368
373
        if(DEBUG) {
369
 
            System.out.println("getJarFileURI res: "+uri);
 
374
            System.err.println("getJarFileURI res: "+uri);
370
375
        }
371
376
        return uri;
372
377
    }
450
455
            throw new IllegalArgumentException("null jarFileURI");
451
456
        }
452
457
        if(DEBUG) {
453
 
            System.out.println("getJarFile.0: "+jarFileURI.toString());
 
458
            System.err.println("getJarFile.0: "+jarFileURI.toString());
454
459
        }
455
460
        final URL jarFileURL = IOUtil.toURL(jarFileURI);
456
461
        if(DEBUG) {
457
 
            System.out.println("getJarFile.1: "+jarFileURL.toString());
 
462
            System.err.println("getJarFile.1: "+jarFileURL.toString());
458
463
        }
459
464
        // final URL jarFileURL = jarFileURI.toURL(); // doesn't work due to encoded path even w/ file schema!
460
465
        final URLConnection urlc = jarFileURL.openConnection();
462
467
            JarURLConnection jarConnection = (JarURLConnection)jarFileURL.openConnection();
463
468
            JarFile jarFile = jarConnection.getJarFile();
464
469
            if(DEBUG) {
465
 
                System.out.println("getJarFile res: "+jarFile.getName());
 
470
                System.err.println("getJarFile res: "+jarFile.getName());
466
471
            }
467
472
            return jarFile;
468
473
        }
469
474
        if(DEBUG) {
470
 
            System.out.println("getJarFile res: NULL");
 
475
            System.err.println("getJarFile res: NULL");
471
476
        }
472
477
        return null;
473
478
    }