1 16 package org.apache.commons.vfs.provider; 17 18 import org.apache.commons.vfs.FileName; 19 import org.apache.commons.vfs.FileSystemException; 20 import org.apache.commons.vfs.FileType; 21 22 28 public class URLFileNameParser extends HostFileNameParser 29 { 30 public URLFileNameParser(final int defaultPort) 31 { 32 super(defaultPort); 33 } 34 35 public boolean encodeCharacter(char ch) 36 { 37 return super.encodeCharacter(ch) || ch == '?'; 38 } 39 40 public FileName parseUri(final VfsComponentContext context, FileName base, final String filename) throws FileSystemException 41 { 42 final StringBuffer name = new StringBuffer (); 44 45 final Authority auth = extractToPath(filename, name); 47 48 String queryString = UriParser.extractQueryString(name); 50 51 UriParser.canonicalizePath(name, 0, name.length(), this); 53 UriParser.fixSeparators(name); 54 FileType fileType = UriParser.normalisePath(name); 55 final String path = name.toString(); 56 57 return new URLFileName( 58 auth.scheme, 59 auth.hostName, 60 auth.port, 61 getDefaultPort(), 62 auth.userName, 63 auth.password, 64 path, 65 fileType, 66 queryString); 67 } 68 } 69 | Popular Tags |