Changeset 6455
- Timestamp:
- 2004-01-12T15:56:41+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/util/URLString.java
r6344 r6455 128 128 129 129 fromdir = from.substring(0, from.lastIndexOf('/')); 130 todir 130 todir = to.substring(0, to.lastIndexOf('/')); 131 131 132 132 if (fromdir.equals(todir)) … … 315 315 316 316 public void tidy() 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 {if (target == null)346 {return null;347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 {if (target.indexOf('#') >= 0)369 370 371 372 373 374 375 376 377 378 379 380 381 {int c;382 383 384 385 {return url;386 387 388 317 { this.url = tidyURL(this.url); 318 } 319 320 public boolean isNull() 321 { if (this.url == null) 322 { return true; 323 } 324 return false; 325 } 326 327 public static boolean isForeign(String home, URL url) 328 { if (url.toString().length() < home.length()) 329 { return true; 330 } 331 332 if (home.equals(url.toString().substring(0, home.length()))) 333 { return false; 334 } 335 return true; 336 } 337 338 /** 339 * Remove any trailing "#localanchor" local reference from a URL string 340 * 341 * @param <code>String</code> the original url 342 * @return <code>String</code> the cleaned url, sans local references 343 */ 344 public static String noRef(String target) 345 { if (target == null) 346 { return null; 347 } 348 if (target.indexOf('#') >= 0) 349 { if (target.indexOf('#') == 0) 350 { return null; 351 } 352 target = target.substring(0, target.indexOf('#')); 353 } 354 return target; 355 } 356 357 /** 358 * Obtain the trailing local anchor reference from a URL, 359 * if it exists. 360 * e.g. for http://www.test.mdx.ac.uk/example/index.html#credits the 361 * response would be "credits" 362 * 363 * @param <code>String</code> the original url. 364 * @return <code>String</code> the local reference. <code>null</code> is 365 * returned if no local reference exists. 366 */ 367 public static String subRef(String target) 368 { if (target.indexOf('#') >= 0) 369 { return target.substring(target.indexOf('#')+1); 370 } 371 return null; 372 } 373 374 /** 375 * Clean a URL of the form GET parameters. 376 * 377 * @param <code>String</code> the original url, with GET message parameters 378 * @return <code>String</code> the cleaned url. 379 */ 380 public static String noParameters(String url) 381 { int c; 382 383 c = url.indexOf("?"); 384 if (c < 0) 385 { return url; 386 } 387 return url.substring(0, c); 388 } 389 389 390 390 /** … … 610 610 } 611 611 612 613 614 615 616 617 618 612 public static String extension(URL url) 613 { return extension(url.toString()); 614 } 615 616 public String toString() 617 { return this.url; 618 } 619 619 }
Note:
See TracChangeset
for help on using the changeset viewer.