public class UriResolver extends Object
Combines a UriContext
instance with rules for resolution (UriResolution
and relativity
(UriRelativity
) to define simple resolve(Object)
and append(Appendable, Object)
methods.
Three special protocols are used to represent context-root-relative, servlet-relative, and request-path-relative
URIs:
The following list shows the protocols of URLs that can be resolved with this class:
Constructor and Description |
---|
UriResolver(UriResolution resolution,
UriRelativity relativity,
UriContext uriContext)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Appendable |
append(Appendable a,
Object o)
Same as
resolve(Object) except appends result to the specified appendable. |
String |
relativize(Object relativeTo,
Object uri)
Relativizes a URI.
|
String |
resolve(Object uri)
Converts the specified URI to absolute form based on values in this context.
|
public UriResolver(UriResolution resolution, UriRelativity relativity, UriContext uriContext)
resolution
- Rule on how URIs should be resolved.relativity
- Rule on what relative URIs are relative to.uriContext
- Current URI context (i.e. the current URI 'location').public String resolve(Object uri)
uri
- The URI to convert to absolute form.
Can be any of the following:
URI can be any of the following forms:
public String relativize(Object relativeTo, Object uri)
Similar to URI.relativize(URI)
, except supports special protocols (e.g.
For example, to relativize a URI to its servlet-relative form:
relativeTo
- The URI to relativize against.uri
- The URI to relativize.public Appendable append(Appendable a, Object o)
resolve(Object)
except appends result to the specified appendable.a
- The appendable to append the URL to.o
- The URI to convert to absolute form.Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.