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.httpclient.URIException;
20 import org.apache.commons.httpclient.util.URIUtil;
21 import org.apache.commons.vfs2.FileName;
22 import org.apache.commons.vfs2.FileSystemException;
23 import org.apache.commons.vfs2.FileType;
24
25
26
27
28
29 @Deprecated
30 public class URLFileName extends GenericFileName {
31
32 private static final int BUFFER_SIZE = 250;
33
34 private final String queryString;
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 public URLFileName(final String scheme, final String hostName, final int port, final int defaultPort,
50 final String userName, final String password, final String path, final FileType type,
51 final String queryString) {
52 super(scheme, hostName, port, defaultPort, userName, password, path, type);
53 this.queryString = queryString;
54 }
55
56
57
58
59
60
61
62
63 @Override
64 public FileName createName(final String absPath, final FileType type) {
65 return new URLFileName(getScheme(), getHostName(), getPort(), getDefaultPort(), getUserName(), getPassword(),
66 absPath, type, getQueryString());
67 }
68
69
70
71
72
73
74 @Override
75 protected String createURI() {
76 if (getQueryString() != null) {
77 final StringBuilder sb = new StringBuilder(BUFFER_SIZE);
78 sb.append(super.createURI());
79 sb.append("?");
80 sb.append(getQueryString());
81
82 return sb.toString();
83 }
84
85 return super.createURI();
86 }
87
88
89
90
91
92
93 public String getPathQuery() {
94 final StringBuilder sb = new StringBuilder(BUFFER_SIZE);
95 sb.append(getPath());
96 sb.append("?");
97 sb.append(getQueryString());
98
99 return sb.toString();
100 }
101
102
103
104
105
106
107
108
109
110 public String getPathQueryEncoded(final String charset) throws URIException, FileSystemException {
111 if (getQueryString() == null) {
112 if (charset != null) {
113 return URIUtil.encodePath(getPathDecoded(), charset);
114 }
115 return URIUtil.encodePath(getPathDecoded());
116 }
117
118 final StringBuilder sb = new StringBuilder(BUFFER_SIZE);
119 if (charset != null) {
120 sb.append(URIUtil.encodePath(getPathDecoded(), charset));
121 } else {
122 sb.append(URIUtil.encodePath(getPathDecoded()));
123 }
124 sb.append("?");
125 sb.append(getQueryString());
126 return sb.toString();
127 }
128
129
130
131
132
133
134 public String getQueryString() {
135 return queryString;
136 }
137
138
139
140
141
142
143
144
145
146 public String getURIEncoded(final String charset) throws FileSystemException, URIException {
147 final StringBuilder sb = new StringBuilder(BUFFER_SIZE);
148 appendRootUri(sb, true);
149 sb.append(getPathQueryEncoded(charset));
150 return sb.toString();
151 }
152 }