Top Description Fields Constructors Methods
org.eclipse.jetty.server

public Class ResourceListing

extends Object
Class Inheritance
Imports
java.time.Instant, .ZoneId, java.time.format.DateTimeFormatter, .FormatStyle, java.util.ArrayList, .Comparator, .HashSet, .List, java.util.function.Function, .Predicate, java.util.stream.Collectors, org.eclipse.jetty.util.Fields, .StringUtil, .URIUtil, .UrlEncoded, org.eclipse.jetty.util.resource.Resource, .ResourceCollators, .Resources, org.slf4j.Logger, .LoggerFactory

Utility methods to generate a List of paths. TODO: add XML and JSON versions?

Field Summary

Modifier and TypeField and Description
public static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static String
private static <T> Predicate<T>
distinctBy(Function<? super T, Object> keyExtractor)

public static String

Returns:

the XHTML as String
getAsXHTML
(Resource
the resource to build the listing from
resource
,
String
The base URL
base
,
boolean
True if the parent directory should be included
parent
,
String
query params
query
)

Convert the Resource directory into an XHTML directory listing.

private static String

Returns:

the defanged text.
hrefEncodeURI
(String
the raw text to encode.
raw
)

Encode any characters that could break the URI string in an HREF.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
public static final Logger LOG

Constructor Detail

ResourceListingback to summary
public ResourceListing()

Method Detail

deTagback to summary
private static String deTag(String raw)
distinctByback to summary
private static <T> Predicate<T> distinctBy(Function<? super T, Object> keyExtractor)
getAsXHTMLback to summary
public static String getAsXHTML(Resource resource, String base, boolean parent, String query)

Convert the Resource directory into an XHTML directory listing.

Parameters
resource:Resource

the resource to build the listing from

base:String

The base URL

parent:boolean

True if the parent directory should be included

query:String

query params

Returns:String

the XHTML as String

hrefEncodeURIback to summary
private static String hrefEncodeURI(String raw)

Encode any characters that could break the URI string in an HREF.

Such as: <a href="/path/to;<script>Window.alert('XSS'+'%20'+'here');</script>">Link</a>

The above example would parse incorrectly on various browsers as the "<" or '"' characters would end the href attribute value string prematurely.

Parameters
raw:String

the raw text to encode.

Returns:String

the defanged text.