1
|
|
/* Generated by AspectJ version 1.0.5 */
|
2
|
|
package org.apache.cactus.util;
|
3
|
|
import java.net.URL;
|
4
|
|
|
5
|
|
/**
|
6
|
|
* Various utility methods for URL manipulation.
|
7
|
|
*
|
8
|
|
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
9
|
|
*
|
10
|
|
* @version $Id: UrlUtil.java,v 1.1.2.1 2002/08/08 21:50:05 vmassol Exp $
|
11
|
|
*/
|
12
|
|
public class UrlUtil {
|
13
|
|
/**
|
14
|
|
* Returns the path part of the URL. This method is needed for
|
15
|
|
* JDK 1.2 support as <code>URL.getPath()</code> does not exist in
|
16
|
|
* JDK 1.2 (only for JDK 1.3+).
|
17
|
|
*
|
18
|
|
* @param theURL the URL from which to extract the path
|
19
|
|
* @return the path part of the URL
|
20
|
|
*/
|
21
|
128
|
public static String getPath(URL theURL) {
|
22
|
128
|
String file = theURL.getFile();
|
23
|
128
|
String path = null;
|
24
|
128
|
if (file != null) {
|
25
|
128
|
int q = file.lastIndexOf('?');
|
26
|
128
|
if (q != -1) {
|
27
|
128
|
path = file.substring(0, q);
|
28
|
|
} else {
|
29
|
0
|
path = file;
|
30
|
|
}
|
31
|
|
}
|
32
|
128
|
return path;
|
33
|
|
}
|
34
|
|
|
35
|
|
/**
|
36
|
|
* Returns the query string of the URL. This method is needed for
|
37
|
|
* JDK 1.2 support as <code>URL.getQuery()</code> does not exist in
|
38
|
|
* JDK 1.2 (only for JDK 1.3+).
|
39
|
|
*
|
40
|
|
* @param theURL the URL from which to extract the query string
|
41
|
|
* @return the query string portion of the URL
|
42
|
|
*/
|
43
|
128
|
public static String getQuery(URL theURL) {
|
44
|
128
|
String file = theURL.getFile();
|
45
|
128
|
String query = null;
|
46
|
128
|
if (file != null) {
|
47
|
128
|
int q = file.lastIndexOf('?');
|
48
|
128
|
if (q != -1) {
|
49
|
128
|
query = file.substring(q + 1);
|
50
|
|
} else {
|
51
|
0
|
query = "";
|
52
|
|
}
|
53
|
|
}
|
54
|
128
|
return query;
|
55
|
|
}
|
56
|
|
|
57
|
|
/**
|
58
|
|
* Various utility methods for URL manipulation.
|
59
|
|
*
|
60
|
|
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
61
|
|
*
|
62
|
|
* @version $Id: UrlUtil.java,v 1.1.2.1 2002/08/08 21:50:05 vmassol Exp $
|
63
|
|
*/
|
64
|
0
|
public UrlUtil() {
|
65
|
0
|
super();
|
66
|
|
}
|
67
|
|
}
|