Java Code Examples for org.eclipse.jetty.util.URIUtil#canonicalPath()
The following examples show how to use
org.eclipse.jetty.util.URIUtil#canonicalPath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: URLResource.java From IoTgo_Android_App with MIT License | 5 votes |
/** * 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.addPaths(_url.toExternalForm(),path)); }
Example 2
Source File: URLResource.java From IoTgo_Android_App with MIT License | 5 votes |
/** * 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.addPaths(_url.toExternalForm(),path)); }
Example 3
Source File: Resource.java From IoTgo_Android_App with MIT License | 4 votes |
/** Get the resource list as a HTML directory listing. * @param base The base URL * @param parent True if the parent directory should be included * @return String of HTML */ public String getListHTML(String base,boolean parent) throws IOException { base=URIUtil.canonicalPath(base); if (base==null || !isDirectory()) return null; String[] ls = list(); if (ls==null) return null; Arrays.sort(ls); String decodedBase = URIUtil.decodePath(base); String title = "Directory: "+deTag(decodedBase); StringBuilder buf=new StringBuilder(4096); buf.append("<HTML><HEAD>"); buf.append("<LINK HREF=\"").append("jetty-dir.css").append("\" REL=\"stylesheet\" TYPE=\"text/css\"/><TITLE>"); buf.append(title); buf.append("</TITLE></HEAD><BODY>\n<H1>"); buf.append(title); buf.append("</H1>\n<TABLE BORDER=0>\n"); if (parent) { buf.append("<TR><TD><A HREF=\""); buf.append(URIUtil.addPaths(base,"../")); buf.append("\">Parent Directory</A></TD><TD></TD><TD></TD></TR>\n"); } String encodedBase = hrefEncodeURI(base); DateFormat dfmt=DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); for (int i=0 ; i< ls.length ; i++) { Resource item = addPath(ls[i]); buf.append("\n<TR><TD><A HREF=\""); String path=URIUtil.addPaths(encodedBase,URIUtil.encodePath(ls[i])); buf.append(path); if (item.isDirectory() && !path.endsWith("/")) buf.append(URIUtil.SLASH); // URIUtil.encodePath(buf,path); buf.append("\">"); buf.append(deTag(ls[i])); buf.append(" "); buf.append("</A></TD><TD ALIGN=right>"); buf.append(item.length()); buf.append(" bytes </TD><TD>"); buf.append(dfmt.format(new Date(item.lastModified()))); buf.append("</TD></TR>"); } buf.append("</TABLE>\n"); buf.append("</BODY></HTML>\n"); return buf.toString(); }
Example 4
Source File: Resource.java From IoTgo_Android_App with MIT License | 4 votes |
/** Get the resource list as a HTML directory listing. * @param base The base URL * @param parent True if the parent directory should be included * @return String of HTML */ public String getListHTML(String base,boolean parent) throws IOException { base=URIUtil.canonicalPath(base); if (base==null || !isDirectory()) return null; String[] ls = list(); if (ls==null) return null; Arrays.sort(ls); String decodedBase = URIUtil.decodePath(base); String title = "Directory: "+deTag(decodedBase); StringBuilder buf=new StringBuilder(4096); buf.append("<HTML><HEAD>"); buf.append("<LINK HREF=\"").append("jetty-dir.css").append("\" REL=\"stylesheet\" TYPE=\"text/css\"/><TITLE>"); buf.append(title); buf.append("</TITLE></HEAD><BODY>\n<H1>"); buf.append(title); buf.append("</H1>\n<TABLE BORDER=0>\n"); if (parent) { buf.append("<TR><TD><A HREF=\""); buf.append(URIUtil.addPaths(base,"../")); buf.append("\">Parent Directory</A></TD><TD></TD><TD></TD></TR>\n"); } String encodedBase = hrefEncodeURI(base); DateFormat dfmt=DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); for (int i=0 ; i< ls.length ; i++) { Resource item = addPath(ls[i]); buf.append("\n<TR><TD><A HREF=\""); String path=URIUtil.addPaths(encodedBase,URIUtil.encodePath(ls[i])); buf.append(path); if (item.isDirectory() && !path.endsWith("/")) buf.append(URIUtil.SLASH); // URIUtil.encodePath(buf,path); buf.append("\">"); buf.append(deTag(ls[i])); buf.append(" "); buf.append("</A></TD><TD ALIGN=right>"); buf.append(item.length()); buf.append(" bytes </TD><TD>"); buf.append(dfmt.format(new Date(item.lastModified()))); buf.append("</TD></TR>"); } buf.append("</TABLE>\n"); buf.append("</BODY></HTML>\n"); return buf.toString(); }