90 * for weakly separated naming systems like COS naming). 91 *<p> 92 * The default implementation uses skips 'prefix', calls 93 * UrlUtil.decode() on it, and returns the result as a single component 94 * CompositeName. 95 * Subclass should override if this is not appropriate. 96 * This method is used only by rename(). 97 * If rename() is supported for a particular URL scheme, 98 * getRootURLContext(), getURLPrefix(), and getURLSuffix() 99 * must be in sync wrt how URLs are parsed and returned. 100 *<p> 101 * For many URL schemes, this method is very similar to URL.getFile(), 102 * except getFile() will return a leading slash in the 103 * 2nd, 3rd, and 4th cases. For schemes like "ldap" and "iiop", 104 * the leading slash must be skipped before the name is an acceptable 105 * format for operation by the Context methods. For schemes that treat the 106 * leading slash as significant (such as "file"), 107 * the subclass must override getURLSuffix() to get the correct behavior. 108 * Remember, the behavior must match getRootURLContext(). 109 * 110 * URL Suffix 111 * foo://host:port <empty string> 112 * foo://host:port/rest/of/name rest/of/name 113 * foo:///rest/of/name rest/of/name 114 * foo:/rest/of/name rest/of/name 115 * foo:rest/of/name rest/of/name 116 */ 117 protected Name getURLSuffix(String prefix, String url) throws NamingException { 118 String suffix = url.substring(prefix.length()); 119 if (suffix.length() == 0) { 120 return new CompositeName(); 121 } 122 123 if (suffix.charAt(0) == '/') { 124 suffix = suffix.substring(1); // skip leading slash 125 } 126 127 try { 128 return new CompositeName().add(UrlUtil.decode(suffix)); 129 } catch (MalformedURLException e) { 130 throw new InvalidNameException(e.getMessage()); 131 } 132 } 133 134 /** 135 * Finds the prefix of a URL. | 90 * for weakly separated naming systems like COS naming). 91 *<p> 92 * The default implementation uses skips 'prefix', calls 93 * UrlUtil.decode() on it, and returns the result as a single component 94 * CompositeName. 95 * Subclass should override if this is not appropriate. 96 * This method is used only by rename(). 97 * If rename() is supported for a particular URL scheme, 98 * getRootURLContext(), getURLPrefix(), and getURLSuffix() 99 * must be in sync wrt how URLs are parsed and returned. 100 *<p> 101 * For many URL schemes, this method is very similar to URL.getFile(), 102 * except getFile() will return a leading slash in the 103 * 2nd, 3rd, and 4th cases. For schemes like "ldap" and "iiop", 104 * the leading slash must be skipped before the name is an acceptable 105 * format for operation by the Context methods. For schemes that treat the 106 * leading slash as significant (such as "file"), 107 * the subclass must override getURLSuffix() to get the correct behavior. 108 * Remember, the behavior must match getRootURLContext(). 109 * 110 * <pre>{@code 111 * URL Suffix 112 * foo://host:port <empty string> 113 * foo://host:port/rest/of/name rest/of/name 114 * foo:///rest/of/name rest/of/name 115 * foo:/rest/of/name rest/of/name 116 * foo:rest/of/name rest/of/name 117 * }</pre> 118 */ 119 protected Name getURLSuffix(String prefix, String url) throws NamingException { 120 String suffix = url.substring(prefix.length()); 121 if (suffix.length() == 0) { 122 return new CompositeName(); 123 } 124 125 if (suffix.charAt(0) == '/') { 126 suffix = suffix.substring(1); // skip leading slash 127 } 128 129 try { 130 return new CompositeName().add(UrlUtil.decode(suffix)); 131 } catch (MalformedURLException e) { 132 throw new InvalidNameException(e.getMessage()); 133 } 134 } 135 136 /** 137 * Finds the prefix of a URL. |