/** Encode a URI path. * @param path The path the encode * @param buf StringBuilder to encode path into (or null) * @return The StringBuilder or null if no substitutions required. */ public static StringBuilder encodePath(StringBuilder buf, String path) { return encodePath(buf,path,0); }
/** Encode a URI path. * This is the same encoding offered by URLEncoder, except that * the '/' character is not encoded. * @param path The path the encode * @return The encoded path */ public static String encodePath(String path) { if (path==null || path.length()==0) return path; StringBuilder buf = encodePath(null,path,0); return buf==null?path:buf.toString(); }
/** * @param uri A URI to add the path to * @param path A decoded path element * @return URI with path added. */ public static URI addPath(URI uri, String path) { String base = uri.toASCIIString(); StringBuilder buf = new StringBuilder(base.length()+path.length()*3); buf.append(base); if (buf.charAt(base.length()-1)!='/') buf.append('/'); int offset=path.charAt(0)=='/'?1:0; encodePath(buf,path,offset); return URI.create(buf.toString()); }
/** * Returns the resource contained inside the current resource with the * given name */ @Override public Resource addPath(String path) throws IOException,MalformedURLException { if (path==null) return null; path = URIUtil.canonicalPath(path); return newResource(URIUtil.addEncodedPaths(_url.toExternalForm(),URIUtil.encodePath(path)), _useCaches); }
public FileResource(File base, String childPath) { String encoded = URIUtil.encodePath(childPath); _file = new File(base, childPath); // The encoded path should be a suffix of the resource (give or take a directory / ) URI uri; try { if (base.isDirectory()) { // treat all paths being added as relative uri=new URI(URIUtil.addEncodedPaths(base.toURI().toASCIIString(),encoded)); } else { uri=new URI(base.toURI().toASCIIString()+encoded); } } catch (final URISyntaxException e) { throw new InvalidPathException(base.toString() + childPath, e.getMessage()) { { initCause(e); } }; } _uri=uri; _alias=checkFileAlias(_uri,_file); }
return new URI("file://"+URIUtil.encodePath(alias.getPath()));
String file_url="file:"+URIUtil.encodePath(url.toString().substring(5)); URI uri = new URI(file_url); if (uri.getAuthority()==null)
String path=URIUtil.addEncodedPaths(encodedBase,URIUtil.encodePath(ls[i]));
String path=URIUtil.addPaths(encodedBase,URIUtil.encodePath(ls[i]));
/** Encode according to this resource type. * The default implementation calls URI.encodePath(uri) * @param uri * @return String encoded for this resource type. */ public String encode(String uri) { return URIUtil.encodePath(uri); }
/** Encode according to this resource type. * The default implementation calls URI.encodePath(uri) * @param uri * @return String encoded for this resource type. */ public String encode(String uri) { return URIUtil.encodePath(uri); }
/** Encode according to this resource type. * The default implementation calls URI.encodePath(uri) * @param uri * @return String encoded for this resource type. */ public String encode(String uri) { return URIUtil.encodePath(uri); }
/** Encode according to this resource type. * The default implementation calls URI.encodePath(uri) * @param uri * @return String encoded for this resource type. */ public String encode(String uri) { return URIUtil.encodePath(uri); }
/** Encode according to this resource type. * The default implementation calls URI.encodePath(uri) * @param uri * @return String encoded for this resource type. */ public String encode(String uri) { return URIUtil.encodePath(uri); }
/** Encode according to this resource type. * The default implementation calls URI.encodePath(uri) * @param uri * @return String encoded for this resource type. */ public String encode(String uri) { return URIUtil.encodePath(uri); }
/** Encode a URI path. * @param path The path the encode * @param buf StringBuilder to encode path into (or null) * @return The StringBuilder or null if no substitutions required. */ public static StringBuilder encodePath(StringBuilder buf, String path) { return encodePath(buf,path,0); }
/** Encode a URI path. * This is the same encoding offered by URLEncoder, except that * the '/' character is not encoded. * @param path The path the encode * @return The encoded path */ public static String encodePath(String path) { if (path==null || path.length()==0) return path; StringBuilder buf = encodePath(null,path); return buf==null?path:buf.toString(); }
/** Encode a URI path. * This is the same encoding offered by URLEncoder, except that * the '/' character is not encoded. * @param path The path the encode * @return The encoded path */ public static String encodePath(String path) { if (path==null || path.length()==0) return path; StringBuilder buf = encodePath(null,path); return buf==null?path:buf.toString(); }
/** Encode a URI path. * This is the same encoding offered by URLEncoder, except that * the '/' character is not encoded. * @param path The path the encode * @return The encoded path */ public static String encodePath(String path) { if (path==null || path.length()==0) return path; StringBuilder buf = encodePath(null,path); return buf==null?path:buf.toString(); }
/** Encode a URI path. * This is the same encoding offered by URLEncoder, except that * the '/' character is not encoded. * @param path The path the encode * @return The encoded path */ public static String encodePath(String path) { if (path==null || path.length()==0) return path; StringBuilder buf = encodePath(null,path,0); return buf==null?path:buf.toString(); }