Return a URLName representing this folder. The returned URLName does not include the password used to access the store. @return the URLName representing this folder @exception MessagingException for failures @see URLName @since JavaMail 1.1
()
| 167 | * @since JavaMail 1.1 |
| 168 | */ |
| 169 | public URLName getURLName() throws MessagingException { |
| 170 | URLName storeURL = getStore().getURLName(); |
| 171 | String fullname = getFullName(); |
| 172 | StringBuilder encodedName = new StringBuilder(); |
| 173 | |
| 174 | if (fullname != null) { |
| 175 | /* |
| 176 | // We need to encode each of the folder's names. |
| 177 | char separator = getSeparator(); |
| 178 | StringTokenizer tok = new StringTokenizer( |
| 179 | fullname, new Character(separator).toString(), true); |
| 180 | |
| 181 | while (tok.hasMoreTokens()) { |
| 182 | String s = tok.nextToken(); |
| 183 | if (s.charAt(0) == separator) |
| 184 | encodedName.append(separator); |
| 185 | else |
| 186 | // XXX - should encode, but since there's no decoder... |
| 187 | //encodedName.append(java.net.URLEncoder.encode(s)); |
| 188 | encodedName.append(s); |
| 189 | } |
| 190 | */ |
| 191 | // append the whole thing, until we can encode |
| 192 | encodedName.append(fullname); |
| 193 | } |
| 194 | |
| 195 | /* |
| 196 | * Sure would be convenient if URLName had a |
| 197 | * constructor that took a base URLName. |
| 198 | */ |
| 199 | return new URLName(storeURL.getProtocol(), storeURL.getHost(), |
| 200 | storeURL.getPort(), encodedName.toString(), |
| 201 | storeURL.getUsername(), |
| 202 | null /* no password */); |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Returns the Store that owns this Folder object. |
no test coverage detected