jericho 01/03/13 00:30:49
Modified: src/webdav/client/src/org/apache/webdav/util
WebdavResource.java GenericURI.java
Log:
- Add the method to be set for the URL encoding flag.
- Minor layout changed.
Revision Changes Path
1.16 +25 -3
jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java
Index: WebdavResource.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- WebdavResource.java 2001/03/13 08:13:14 1.15
+++ WebdavResource.java 2001/03/13 08:30:44 1.16
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.15 2001/03/13 08:13:14 jericho Exp $
- * $Revision: 1.15 $
- * $Date: 2001/03/13 08:13:14 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.16 2001/03/13 08:30:44 jericho Exp $
+ * $Revision: 1.16 $
+ * $Date: 2001/03/13 08:30:44 $
*
* ====================================================================
*
@@ -463,6 +463,28 @@
httpUrl.setUserInfo(userName, password);
setAllProp(httpUrl);
+ }
+
+
+ /**
+ * Set the URL encoding flag for this http URL.
+ *
+ * @param encodeURLs true if it is encoded.
+ * @exception MalformedURLException
+ * @exception IOException
+ */
+ public void setEncodeURLs(boolean encodeURLs)
+ throws MalformedURLException, IOException {
+
+ WebdavClient client = WebdavSession.getSessionInstance(httpUrl);
+
+ State state = client.getState();
+ if (state != null) {
+ state.setEncodeURLs(encodeURLs);
+ }
+ client.setState(state);
+
+ WebdavSession.setSession(httpUrl, client);
}
1.8 +185 -185
jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java
Index: GenericURI.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- GenericURI.java 2001/03/13 08:13:16 1.7
+++ GenericURI.java 2001/03/13 08:30:45 1.8
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v
1.7 2001/03/13 08:13:16 jericho Exp $
- * $Revision: 1.7 $
- * $Date: 2001/03/13 08:13:16 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v
1.8 2001/03/13 08:30:45 jericho Exp $
+ * $Revision: 1.8 $
+ * $Date: 2001/03/13 08:30:45 $
*
* ====================================================================
*
@@ -163,7 +163,7 @@
*/
protected void setDefaultScheme(String scheme) {
- defaultScheme = scheme.toLowerCase();
+ defaultScheme = scheme.toLowerCase();
}
@@ -206,14 +206,14 @@
public String getScheme()
throws MalformedURLException {
- return getScheme(uri);
+ return getScheme(uri);
}
/**
* Get the scheme of the given URI string.
*
- * @param uri the URI string to get the scheme.
+ * @param uri the URI string to get the scheme.
* @return the scheme of the given URI.
* @exception MalformedURLException no scheme.
*/
@@ -228,8 +228,8 @@
/**
* Get the scheme of the given URI string.
*
- * @param uri the URI string to get the scheme.
- * @param defaultScheme the scheme to set.
+ * @param uri the URI string to get the scheme.
+ * @param defaultScheme the scheme to set.
* @return the scheme of the given URI.
* @exception MalformedURLException no scheme.
*/
@@ -248,28 +248,28 @@
}
- /*
- * Get the authority part for this generic URI.
- *
- * @return the authority part of this generic URI.
- * @exception MalformedURLException
- */
- public String getAuthority()
- throws MalformedURLException {
+ /**
+ * Get the authority part for this generic URI.
+ *
+ * @return the authority part of this generic URI.
+ * @exception MalformedURLException
+ */
+ public String getAuthority()
+ throws MalformedURLException {
return getAuthority(uri);
- }
+ }
- /*
- * Get the authority part of the given URI string.
- *
- * @param uri the URI string to get the authority part.
- * @return the authority part of the given URI.
- * @exception MalformedURLException
- */
- public static String getAuthority(String uri)
- throws MalformedURLException {
+ /**
+ * Get the authority part of the given URI string.
+ *
+ * @param uri the URI string to get the authority part.
+ * @return the authority part of the given URI.
+ * @exception MalformedURLException
+ */
+ public static String getAuthority(String uri)
+ throws MalformedURLException {
int at = uri.indexOf("://");
if (at > 0) {
@@ -282,32 +282,32 @@
return uri.substring(from);
} else
throw new MalformedURLException("No scheme: " + uri);
- }
+ }
- /*
- * Get the userinfo part for this generic URI.
- *
- * @return the userifno of this generic URI.
- * @exception MalformedURLException
- */
- public String getUserInfo()
- throws MalformedURLException {
-
- return getUserInfo(uri);
- }
-
-
- /*
- * Get the userinfo part of the given URI string.
- *
- * @param uri the URI string to get the userinfo part.
- * @return the userifno of the given URI.
- * @exception MalformedURLException
- */
- public static String getUserInfo(String uri)
- throws MalformedURLException {
+ /**
+ * Get the userinfo part for this generic URI.
+ *
+ * @return the userifno of this generic URI.
+ * @exception MalformedURLException
+ */
+ public String getUserInfo()
+ throws MalformedURLException {
+
+ return getUserInfo(uri);
+ }
+
+ /**
+ * Get the userinfo part of the given URI string.
+ *
+ * @param uri the URI string to get the userinfo part.
+ * @return the userifno of the given URI.
+ * @exception MalformedURLException
+ */
+ public static String getUserInfo(String uri)
+ throws MalformedURLException {
+
String authority = getAuthority(uri);
int to = authority.indexOf("@");
@@ -315,50 +315,50 @@
return authority.substring(0, to);
else
return null;
- }
+ }
- /*
- * Set the username and password for this URI.
- *
- * @param the username of URI
- * @param the password of URI
- * @exception MalformedURLException
- */
- public void setUserInfo(String userName, String password)
- throws MalformedURLException {
+ /**
+ * Set the username and password for this URI.
+ *
+ * @param the username of URI
+ * @param the password of URI
+ * @exception MalformedURLException
+ */
+ public void setUserInfo(String userName, String password)
+ throws MalformedURLException {
if (userName == null || password == null)
throw new MalformedURLException("No credentials set");
uri = getScheme() + "://" + userName + ":" + password +
"@" + getHostPort() + getPath();
- }
+ }
- /*
- * Get the username on the userinfo for this generic URI.
- *
- * @return the username of URI
- * @exception MalformedURLException
- * @see #getUserName(java.lang.String)
- */
- public String getUserName()
- throws MalformedURLException {
+ /**
+ * Get the username on the userinfo for this generic URI.
+ *
+ * @return the username of URI
+ * @exception MalformedURLException
+ * @see #getUserName(java.lang.String)
+ */
+ public String getUserName()
+ throws MalformedURLException {
return getUserName(uri);
- }
+ }
- /*
- * Get the username on the userinfo of the given URI string.
- *
- * @param uri the URI string to get the username.
- * @return the username of URI
- * @exception MalformedURLException
- */
- public static String getUserName(String uri)
- throws MalformedURLException {
+ /**
+ * Get the username on the userinfo of the given URI string.
+ *
+ * @param uri the URI string to get the username.
+ * @return the username of URI
+ * @exception MalformedURLException
+ */
+ public static String getUserName(String uri)
+ throws MalformedURLException {
try {
String userInfo = getUserInfo(uri);
@@ -372,31 +372,31 @@
// No userinfo
return null;
}
- }
+ }
- /*
- * Get the password on the userinfo for this URI string.
- *
- * @return the password of URI
- * @exception MalformedURLException
- */
- public String getPassword()
- throws MalformedURLException {
+ /**
+ * Get the password on the userinfo for this URI string.
+ *
+ * @return the password of URI
+ * @exception MalformedURLException
+ */
+ public String getPassword()
+ throws MalformedURLException {
return getPassword(uri);
- }
+ }
- /*
- * Get the password on the userinfo of the given URI string.
- *
- * @param uri the URI string to get the password.
- * @return the password of URI
- * @exception MalformedURLException
- */
- public static String getPassword(String uri)
- throws MalformedURLException {
+ /**
+ * Get the password on the userinfo of the given URI string.
+ *
+ * @param uri the URI string to get the password.
+ * @return the password of URI
+ * @exception MalformedURLException
+ */
+ public static String getPassword(String uri)
+ throws MalformedURLException {
try {
String userInfo = getUserInfo(uri);
@@ -410,31 +410,31 @@
// No userinfo
return null;
}
- }
+ }
- /*
- * Get the hostport part for this generic URI.
- *
- * @return the hostport string of the URI
- * @exception MalformedURLException
- */
- public String getHostPort()
- throws MalformedURLException {
+ /**
+ * Get the hostport part for this generic URI.
+ *
+ * @return the hostport string of the URI
+ * @exception MalformedURLException
+ */
+ public String getHostPort()
+ throws MalformedURLException {
return getHostPort(uri);
}
- /*
- * Get the hostport part of the given URI string.
- *
- * @param uri the URI string to get the hostport part.
- * @return the hostport of URI
- * @exception MalformedURLException
- */
- public static String getHostPort(String uri)
- throws MalformedURLException {
+ /**
+ * Get the hostport part of the given URI string.
+ *
+ * @param uri the URI string to get the hostport part.
+ * @return the hostport of URI
+ * @exception MalformedURLException
+ */
+ public static String getHostPort(String uri)
+ throws MalformedURLException {
String authority = getAuthority(uri);
@@ -443,14 +443,14 @@
return authority.substring(at + 1);
else
return authority;
- }
+ }
/**
* Get the hostname for this generic URI.
*
* @return The hostname string
- * @exception MalformedURLException
+ * @exception MalformedURLException
*/
public String getHost()
throws MalformedURLException {
@@ -462,19 +462,19 @@
/**
* Get the hostname of the given URI string.
*
- * @param uri the URI string to get the hostname.
+ * @param uri the URI string to get the hostname.
* @return The hostname string
- * @exception MalformedURLException
+ * @exception MalformedURLException
*/
public static String getHost(String uri)
throws MalformedURLException {
- String hostPort = getHostPort(uri);
- int to = hostPort.indexOf(":");
- if (to > 0)
- return hostPort.substring(0, to);
- else
- return hostPort;
+ String hostPort = getHostPort(uri);
+ int to = hostPort.indexOf(":");
+ if (to > 0)
+ return hostPort.substring(0, to);
+ else
+ return hostPort;
}
@@ -482,47 +482,47 @@
* Get the port number for this generic URI.
*
* @return The port number
- * @exception MalformedURLException
+ * @exception MalformedURLException
*/
public int getPort()
throws MalformedURLException {
- return getPort(uri);
+ return getPort(uri);
}
/**
* Get the port number for this generic URI.
*
- * @param uri the URI string to get the port number.
+ * @param uri the URI string to get the port number.
* @return The port number
- * @exception MalformedURLException
+ * @exception MalformedURLException
*/
public static int getPort(String uri)
throws MalformedURLException {
- return getPort(uri, defaultPort);
+ return getPort(uri, defaultPort);
}
/**
* Get the port number of the given URI string.
*
- * @param uri the URI string to get the port number.
- * @param defaultPort the default port for the given URI.
+ * @param uri the URI string to get the port number.
+ * @param defaultPort the default port for the given URI.
* @return The port number
- * @exception MalformedURLException
+ * @exception MalformedURLException
*/
public static int getPort(String uri, int defaultPort)
throws MalformedURLException {
- String hostPort = getHostPort(uri);
- int at = hostPort.indexOf(":");
- if (at > 0) {
- String port = hostPort.substring(at + 1);
- try {
- // Support the form like http://thinkfree.com:/~jericho
- return port.equals("") ? defaultPort : Integer.parseInt(port);
+ String hostPort = getHostPort(uri);
+ int at = hostPort.indexOf(":");
+ if (at > 0) {
+ String port = hostPort.substring(at + 1);
+ try {
+ // Support the form like http://thinkfree.com:/~jericho
+ return port.equals("") ? defaultPort : Integer.parseInt(port);
} catch (NumberFormatException nfe) {
// The wrong port or unset number returns -1.
return -1;
@@ -537,11 +537,11 @@
}
- /*
+ /**
* Get the net_path of the given URI string.
* The net_path consists of the net_loc and abs_path.
*
- * @return the nel_path.
+ * @return the nel_path.
*/
public String getNetPath() {
@@ -549,12 +549,12 @@
}
- /*
+ /**
* Get the net_path of the given URI string.
* The net_path consists of the net_loc and abs_path.
*
* @param uri the specified URI string.
- * @return the net_path.
+ * @return the net_path.
*/
public static String getNetPath(String uri) {
@@ -572,12 +572,12 @@
}
- /*
+ /**
* Get the abs_path for this generic URI.
* The abs_path includes the query.
* This method ignores the scheme and authority part of the URI path.
*
- * @return the abs_path.
+ * @return the abs_path.
*/
public String getAbsPath() {
@@ -585,13 +585,13 @@
}
- /*
+ /**
* Get the abs_path of the given URI string.
* The abs_path includes the query.
* This method ignores the scheme and authority part of the URI path.
*
* @param uri the specified URI string.
- * @return the abs_path.
+ * @return the abs_path.
*/
public static String getAbsPath(String uri) {
@@ -611,11 +611,11 @@
}
- /*
+ /**
* Set the path for this generic URI.
*
- * @return the path.
- * @exception MalformedURLException
+ * @return the path.
+ * @exception MalformedURLException
*/
public void setPath(String path)
throws MalformedURLException {
@@ -626,11 +626,11 @@
}
- /*
+ /**
* Get the path for this generic URI.
* This method ignores the scheme and authority part of the URI path.
*
- * @return the path.
+ * @return the path.
*/
public String getPath() {
@@ -638,12 +638,12 @@
}
- /*
+ /**
* Get the path of the given URI string.
* This method ignores the scheme and authority part of the URI path.
*
* @param uri the specified URI string.
- * @return the path.
+ * @return the path.
*/
public static String getPath(String uri) {
@@ -665,7 +665,7 @@
}
- /*
+ /**
* Get the parent path for this generic URI.
* This method ignores the forward part of the URI path.
*
@@ -677,7 +677,7 @@
}
- /*
+ /**
* Get the parent path of the given already-normalized path.
* This method ignores the forward part of the URI path.
*
@@ -705,7 +705,7 @@
}
- /*
+ /**
* Get the resource or collection name for this generic URI.
* When you get a collection, the collection name ends with the slash.
*
@@ -717,7 +717,7 @@
}
- /*
+ /**
* Get the resource or collection name of the already-normalized path.
* When you get a collection, the collection name ends with the slash.
*
@@ -739,12 +739,12 @@
}
- /*
+ /**
* Get the query for this generic URI.
* This method ignores the scheme and authority part for this generic URI.
*
- * @return the query string.
- * @exception MalformedURLException
+ * @return the query string.
+ * @exception MalformedURLException
*/
public String getQuery()
throws MalformedURLException {
@@ -753,14 +753,14 @@
}
- /*
+ /**
* Get the query of the given URI string.
* This method ignores the scheme and authority part of the given URI.
*
* @param uri the specified URI string.
* It could be the generic URI and relative URI.
- * @return the query string.
- * @exception MalformedURLException
+ * @return the query string.
+ * @exception MalformedURLException
*/
public static String getQuery(String uri)
throws MalformedURLException {
@@ -791,12 +791,12 @@
}
- /*
+ /**
* Get the fragment for this generic URI.
* This method ignores the scheme and authority part of the given URI.
*
- * @return the fragment string.
- * @exception MalformedURLException
+ * @return the fragment string.
+ * @exception MalformedURLException
*/
public String getFragment()
throws MalformedURLException {
@@ -804,14 +804,14 @@
return getFragment(uri);
}
- /*
+ /**
* Get the fragment of the given URI string.
* This method ignores the scheme and authority part of the given URI.
*
* @param uri the specified URI string.
* It could be the generic URI and relative URI.
- * @return the fragment string.
- * @exception MalformedURLException
+ * @return the fragment string.
+ * @exception MalformedURLException
*/
public static String getFragment(String uri)
throws MalformedURLException {
@@ -842,7 +842,7 @@
* To support <code>java.net.URL</code> of JDK 1.1.x.
*
* @return <code>java.net.URL</code>
- * @exception MalformedURLException
+ * @exception MalformedURLException
*/
public URL toURL()
throws MalformedURLException {
@@ -854,7 +854,7 @@
// ------------------------------------------ Methods for basic function
- /*
+ /**
* Test a object if this is equal with another.
*
* @param obj A object to compare.
@@ -862,28 +862,28 @@
*/
public boolean equals(Object obj) {
- if ((obj != null) && (obj instanceof GenericURI)) {
+ if ((obj != null) && (obj instanceof GenericURI)) {
- try {
- GenericURI uri = (GenericURI) obj;
+ try {
+ GenericURI uri = (GenericURI) obj;
- if (getScheme().equalsIgnoreCase(uri.getScheme()) &&
- getUserInfo().equals(uri.getUserInfo()) &&
- getHost().equalsIgnoreCase(uri.getHost()) &&
- getPort() == uri.getPort() &&
- getPath().equals(uri.getPath()))
+ if (getScheme().equalsIgnoreCase(uri.getScheme()) &&
+ getUserInfo().equals(uri.getUserInfo()) &&
+ getHost().equalsIgnoreCase(uri.getHost()) &&
+ getPort() == uri.getPort() &&
+ getPath().equals(uri.getPath()))
return true;
} catch(MalformedURLException ignored) {
}
- }
+ }
- return false;
+ return false;
}
- /*
+ /**
* Get a URI string.
*
* @return A URI string.