Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/URLFileName.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/URLFileName.java?rev=804548&r1=804547&r2=804548&view=diff ============================================================================== --- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/URLFileName.java (original) +++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/URLFileName.java Sun Aug 16 02:12:32 2009 @@ -22,8 +22,13 @@ import org.apache.commons.vfs.FileSystemException; import org.apache.commons.vfs.FileType; +/** + * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a> + */ public class URLFileName extends GenericFileName { + private static final int BUFFSZ = 250; + private final String queryString; public URLFileName(final String scheme, @@ -41,7 +46,7 @@ } /** - * get the query string + * Get the query string. * * @return the query string part of the filename */ @@ -51,13 +56,13 @@ } /** - * get the path and query string e.g. /path/servlet?param1=true + * Get the path and query string e.g. /path/servlet?param1=true. * * @return the path and its query string */ public String getPathQuery() { - StringBuffer sb = new StringBuffer(250); + StringBuffer sb = new StringBuffer(BUFFSZ); sb.append(getPath()); sb.append("?"); sb.append(getQueryString()); @@ -66,9 +71,12 @@ } /** - * get the path encoded suitable for url like filesystem e.g. (http, webdav) + * Get the path encoded suitable for url like filesystem e.g. (http, webdav). * * @param charset the charset used for the path encoding + * @return The encoded path. + * @throws URIException If an error occurs encoding the URI. + * @throws FileSystemException If some other error occurs. */ public String getPathQueryEncoded(String charset) throws URIException, FileSystemException { @@ -84,7 +92,7 @@ } } - StringBuffer sb = new StringBuffer(250); + StringBuffer sb = new StringBuffer(BUFFSZ); if (charset != null) { sb.append(URIUtil.encodePath(getPathDecoded(), charset)); @@ -98,6 +106,12 @@ return sb.toString(); } + /** + * Create a FileName. + * @param absPath The absolute path. + * @param type The FileType. + * @return The FileName + */ public FileName createName(final String absPath, FileType type) { return new URLFileName(getScheme(), @@ -112,7 +126,7 @@ } /** - * append query string to the uri + * Append query string to the uri. * * @return the uri */ @@ -120,7 +134,7 @@ { if (getQueryString() != null) { - StringBuffer sb = new StringBuffer(250); + StringBuffer sb = new StringBuffer(BUFFSZ); sb.append(super.createURI()); sb.append("?"); sb.append(getQueryString()); @@ -131,9 +145,16 @@ return super.createURI(); } + /** + * Encode a URI. + * @param charset The character set. + * @return The encoded URI + * @throws FileSystemException if some other exception occurs. + * @throws URIException if an exception occurs encoding the URI. + */ public String getURIEncoded(String charset) throws FileSystemException, URIException { - StringBuffer sb = new StringBuffer(80); + StringBuffer sb = new StringBuffer(BUFFSZ); appendRootUri(sb, true); sb.append(getPathQueryEncoded(charset)); return sb.toString();
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/URLFileNameParser.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/URLFileNameParser.java?rev=804548&r1=804547&r2=804548&view=diff ============================================================================== --- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/URLFileNameParser.java (original) +++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/URLFileNameParser.java Sun Aug 16 02:12:32 2009 @@ -39,7 +39,8 @@ return super.encodeCharacter(ch) || ch == '?'; } - public FileName parseUri(final VfsComponentContext context, FileName base, final String filename) throws FileSystemException + public FileName parseUri(final VfsComponentContext context, FileName base, final String filename) + throws FileSystemException { // FTP URI are generic URI (as per RFC 2396) final StringBuffer name = new StringBuffer(); @@ -57,12 +58,12 @@ final String path = name.toString(); return new URLFileName( - auth.scheme, - auth.hostName, - auth.port, + auth.getScheme(), + auth.getHostName(), + auth.getPort(), getDefaultPort(), - auth.userName, - auth.password, + auth.getUserName(), + auth.getPassword(), path, fileType, queryString);
