@ProviderType public interface SlingUri extends RequestPathInfo
Represents an immutable URI in the same way as java.net.URI but is extended with Sling-specific URI parts (e.g. selectors). A SlingUri
usually points to a resource but alternatively, can also contain an opaque URI like mailto: or javascript:. Use
adjust(Consumer) or SlingUriBuilder to create new or modified Sling URIs.
Opposed to URI, the regular getters of SlingUri will not return decoded values, rather the values for user info, path,
query and fragment are returned exactly as set before.
| Modifier and Type | Method and Description |
|---|---|
default @NotNull SlingUri |
adjust(@NotNull java.util.function.Consumer<SlingUriBuilder> builderConsumer)
Shortcut to adjust Sling URIs, e.g.
|
@Nullable java.lang.String |
getExtension()
Returns the extension.
|
@Nullable java.lang.String |
getFragment()
Returns the fragment.
|
@Nullable java.lang.String |
getHost()
Returns the host.
|
@Nullable java.lang.String |
getPath()
Returns the joint path of resource path, selectors, extension and suffix.
|
@NotNull java.util.Map<java.lang.String,java.lang.String> |
getPathParameters()
Returns the path parameters.
|
int |
getPort()
Returns the port.
|
@Nullable java.lang.String |
getQuery()
Returns the query.
|
@Nullable java.lang.String |
getResourcePath()
Returns the resource path.
|
@Nullable java.lang.String |
getScheme()
Returns the scheme.
|
@Nullable java.lang.String |
getSchemeSpecificPart()
Returns the scheme-specific part of the URI, compare with Javadoc of
URI. |
@NotNull java.lang.String[] |
getSelectors()
Returns the selectors array.
|
@Nullable java.lang.String |
getSelectorString()
Returns the selector string.
|
@Nullable java.lang.String |
getSuffix()
Returns the suffix part of the URI
|
@Nullable Resource |
getSuffixResource()
Returns the corresponding suffix resource or null if
no resource resolver is available (depends on the create method used in SlingUriBuilder)
the URI does not contain a suffix
if the suffix resource could not be found
|
@Nullable java.lang.String |
getUserInfo()
Returns the user info.
|
boolean |
isAbsolute()
Returns true the URI is an absolute URI.
|
boolean |
isAbsolutePath()
Returns true if the URI has an absolute path starting with a slash ('/').
|
boolean |
isOpaque()
Returns true for opaque URIs like e.g.
|
boolean |
isPath()
Returns true the URI is either a relative or absolute path (this is the case if scheme and host is empty and the URI path is set)
|
boolean |
isRelativePath()
Returns true if the URI is a relative path (no scheme and path does not start with '/').
|
@NotNull java.lang.String |
toString()
Returns the URI as String.
|
@NotNull java.net.URI |
toUri()
Returns the
URI. |
@NotNull @NotNull java.net.URI toUri()
URI.@NotNull @NotNull java.lang.String toString()
toString in class java.lang.Object@Nullable @Nullable java.lang.String getScheme()
@Nullable @Nullable java.lang.String getUserInfo()
@Nullable @Nullable java.lang.String getHost()
int getPort()
@Nullable @Nullable java.lang.String getResourcePath()
getResourcePath in interface RequestPathInfo@Nullable @Nullable java.lang.String getSelectorString()
getSelectorString in interface RequestPathInfoRequestPathInfo)RequestPathInfo.getSelectors()@NotNull @NotNull java.lang.String[] getSelectors()
getSelectors in interface RequestPathInfoRequestPathInfo.getSelectorString()@Nullable @Nullable java.lang.String getExtension()
getExtension in interface RequestPathInfo@NotNull @NotNull java.util.Map<java.lang.String,java.lang.String> getPathParameters()
@Nullable @Nullable java.lang.String getSuffix()
getSuffix in interface RequestPathInfo@Nullable @Nullable java.lang.String getPath()
@Nullable @Nullable java.lang.String getQuery()
@Nullable @Nullable java.lang.String getFragment()
@Nullable @Nullable java.lang.String getSchemeSpecificPart()
URI.@Nullable @Nullable Resource getSuffixResource()
getSuffixResource in interface RequestPathInfoboolean isPath()
boolean isAbsolutePath()
boolean isRelativePath()
boolean isAbsolute()
boolean isOpaque()
@NotNull default @NotNull SlingUri adjust(@NotNull @NotNull java.util.function.Consumer<SlingUriBuilder> builderConsumer)
slingUri = slingUri.adjust(b -> b.setExtension("html")); .builderConsumer - the consumer (e.g. b -> b.setExtension("html"))Copyright © 2022 The Apache Software Foundation. All rights reserved.