Index: java/net/URI.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/net/URI.java,v retrieving revision 1.14 diff -u -3 -p -u -r1.14 URI.java --- java/net/URI.java 19 May 2005 21:00:59 -0000 1.14 +++ java/net/URI.java 26 May 2005 20:27:35 -0000 @@ -308,10 +308,46 @@ public final class URI os.writeObject(string); } + /** + *
+ * Returns the string content of the specified group of the supplied + * matcher. The returned value is modified according to the following: + *
+ *null
is returned to indicate an undefined
+ * value. Otherwise, the value is truly the empty string and this is
+ * the returned value.+ * This method is used for matching against all parts of the URI + * that may be either undefined or empty (i.e. all those but the + * scheme-specific part and the path). In each case, the preceding + * group is the content of the original group, along with some + * additional distinguishing feature. For example, the preceding + * group for the query includes the preceding question mark, + * while that of the fragment includes the hash symbol. The presence + * of these features enables disambiguation between the two cases + * of a completely unspecified value and a simple non-existant value. + * The scheme differs in that it will never return an empty string; + * the delimiter follows the scheme rather than preceding it, so + * it becomes part of the following section. The same is true + * of the user information. + *
+ * + * @param match the matcher, which contains the results of the URI + * matched against the URI regular expression. + * @return either the matched content,null
for undefined
+ * values, or an empty string for a URI part with empty content.
+ */
private static String getURIGroup(Matcher match, int group)
{
String matched = match.group(group);
- return matched.length() == 0 ? null : matched;
+ return matched.length() == 0
+ ? ((match.group(group - 1).length() == 0) ? null : "") : matched;
}
/**
@@ -895,8 +931,8 @@ public final class URI
/**
* - * Relativizes the given URI against this URI using the following - * algorithm: + * Relativizes the given URI against this URI. The following + * algorithm is used: *
*