1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.vfs2.provider;
18
19 import org.apache.commons.vfs2.FileName;
20 import org.apache.commons.vfs2.FileSystemException;
21 import org.apache.commons.vfs2.FileType;
22
23
24
25
26
27
28
29 public class GenericURLFileNameParser extends HostFileNameParser {
30
31
32
33
34
35
36 public GenericURLFileNameParser(final int defaultPort) {
37 super(defaultPort);
38 }
39
40 @Override
41 public boolean encodeCharacter(final char ch) {
42 return super.encodeCharacter(ch) || ch == '?';
43 }
44
45 @Override
46 public FileName parseUri(final VfsComponentContext context, final FileName base, final String fileName)
47 throws FileSystemException {
48
49 final StringBuilder name = new StringBuilder();
50
51
52 final Authority auth = extractToPath(context, fileName, name);
53
54
55 final String queryString = UriParser.extractQueryString(name);
56
57
58 UriParser.canonicalizePath(name, 0, name.length(), this);
59 UriParser.fixSeparators(name);
60 final FileType fileType = UriParser.normalisePath(name);
61 final String path = name.toString();
62
63 return new GenericURLFileName(auth.getScheme(), auth.getHostName(), auth.getPort(), getDefaultPort(),
64 auth.getUserName(), auth.getPassword(), path, fileType, queryString);
65 }
66 }