You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by je...@apache.org on 2001/03/20 13:52:01 UTC
cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/util GenericURI.java
jericho 01/03/20 04:52:00
Modified: src/webdav/client/src/org/apache/webdav/util GenericURI.java
Log:
- Make the setUserInfo method flexible for setting null arguments.
- Add getHttpURL, getHttpURLExceptForPassword, getHttpURLExceptForUserInfo methods.
Revision Changes Path
1.9 +51 -11 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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- GenericURI.java 2001/03/13 08:30:45 1.8
+++ GenericURI.java 2001/03/20 12:51:57 1.9
@@ -1,7 +1,7 @@
/*
- * $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 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v 1.9 2001/03/20 12:51:57 jericho Exp $
+ * $Revision: 1.9 $
+ * $Date: 2001/03/20 12:51:57 $
*
* ====================================================================
*
@@ -328,13 +328,12 @@
public void setUserInfo(String userName, String password)
throws MalformedURLException {
- if (userName == null || password == null)
- throw new MalformedURLException("No credentials set");
+ uri = getScheme() + "://" +
+ ((userName != null) ?
+ userName + ((password != null) ? ":" + password : "") + "@" : "")
+ + getHostPort() + getAbsPath();
+ }
- uri = getScheme() + "://" + userName + ":" + password +
- "@" + getHostPort() + getPath();
- }
-
/**
* Get the username on the userinfo for this generic URI.
@@ -839,6 +838,47 @@
/**
+ * Get an HttpURL instance.
+ *
+ * @return The http URL.
+ */
+ public HttpURL getHttpURL() {
+
+ return new HttpURL(uri);
+ }
+
+
+ /**
+ * Get an HttpURL instance except for password.
+ *
+ * @return The http URL except for password.
+ */
+ public HttpURL getHttpURLExceptForPassword()
+ throws MalformedURLException {
+
+ HttpURL httpUrl = getHttpURL();
+ httpUrl.setUserInfo(httpUrl.getUserName(), null);
+
+ return httpUrl;
+ }
+
+
+ /**
+ * Get an HttpURL instance except for userinfo.
+ *
+ * @return The http URL except for password.
+ */
+ public HttpURL getHttpURLExceptForUserInfo()
+ throws MalformedURLException {
+
+ HttpURL httpUrl = getHttpURL();
+ httpUrl.setUserInfo(null, null);
+
+ return httpUrl;
+ }
+
+
+ /**
* To support <code>java.net.URL</code> of JDK 1.1.x.
*
* @return <code>java.net.URL</code>
@@ -847,8 +887,8 @@
public URL toURL()
throws MalformedURLException {
- return new URL(getScheme() + "://" + getHostPort() + getPath());
- }
+ return new URL(getHttpURLExceptForUserInfo().toString());
+ }
// ------------------------------------------ Methods for basic function