Package com.helger.photon.app.url
Class LinkHelper
java.lang.Object
com.helger.photon.app.url.LinkHelper
Misc utilities to create link URLs.
- Author:
- Philip Helger
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic com.helger.commons.url.SimpleURLstatic Stringstatic Stringstatic com.helger.commons.url.SimpleURLgetStreamURL(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, String sURL) Get the default URL to stream the passed URL.static StringgetURIWithContext(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, String sHRef) Prefix the passed href with the relative context path in case the passed href has no protocol yet.static StringgetURIWithContext(String sHRef) Prefix the passed href with the relative context path in case the passed href has no protocol yet.
Important: this method does not add the session ID in case cookies are disabled by the client!static StringgetURIWithServerAndContext(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, String sHRef) Prefix the passed href with the absolute server + context path in case the passed href has no protocol yet.static StringgetURIWithServerAndContext(String sHRef) Prefix the passed href with the absolute server + context path in case the passed href has no protocol yet.
Important: this method does not add the session ID in case cookies are disabled by the client!static com.helger.commons.url.SimpleURLgetURLWithContext(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, String sHRef) Prefix the passed href with the relative context path in case the passed href has no protocol yet.static com.helger.commons.url.SimpleURLgetURLWithContext(String sHRef) Prefix the passed href with the relative context path in case the passed href has no protocol yet.
Important: this method does not add the session ID in case cookies are disabled by the client!static com.helger.commons.url.SimpleURLgetURLWithServerAndContext(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, String sHRef) Prefix the passed href with the absolute server + context path in case the passed href has no protocol yet.static com.helger.commons.url.SimpleURLgetURLWithServerAndContext(String sHRef) Prefix the passed href with the absolute server + context path in case the passed href has no protocol yet.
Important: this method does not add the session ID in case cookies are disabled by the client!static booleanhasKnownProtocol(String sURI) Special "has known protocol" version that also supports the pseudo protocol "//" that maps to either "http" or "https" depending on the surrounding setup.static voidsetStreamServletName(String sStreamServletName)
-
Field Details
-
STREAM_SERVLET_NAME_REGEX
- See Also:
-
DEFAULT_STREAM_SERVLET_NAME
The default name of the stream servlet. If this is different in you application you may not use the methods that refer to this path!- See Also:
-
-
Method Details
-
setStreamServletName
-
getStreamServletName
- Returns:
- The name of the stream servlet path. Default is
stream - See Also:
-
getStreamServletPath
- Returns:
- The relative path of the stream servlet. Default is
/stream - See Also:
-
hasKnownProtocol
Special "has known protocol" version that also supports the pseudo protocol "//" that maps to either "http" or "https" depending on the surrounding setup.- Parameters:
sURI- Source URI. MAy benull.- Returns:
trueif the URI has a known protocol or "//".
-
getURIWithContext
Prefix the passed href with the relative context path in case the passed href has no protocol yet.
Important: this method does not add the session ID in case cookies are disabled by the client!- Parameters:
sHRef- The href to be extended. May not benull.- Returns:
- Either the original href if already absolute or
/webapp-context/hrefotherwise. Nevernull.
-
getURIWithContext
@Nonnull public static String getURIWithContext(@Nonnull com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, @Nonnull String sHRef) Prefix the passed href with the relative context path in case the passed href has no protocol yet.- Parameters:
aRequestScope- The request web scope to be used. Required for cookie-less handling. May not benull.sHRef- The href to be extended. May not benull.- Returns:
- Either the original href if already absolute or
/webapp-context/hrefotherwise. Nevernull.
-
getURLWithContext
Prefix the passed href with the relative context path in case the passed href has no protocol yet.
Important: this method does not add the session ID in case cookies are disabled by the client!- Parameters:
sHRef- The href to be extended. May not benull.- Returns:
- Either the original href if already absolute or
/webapp-context/hrefotherwise. Nevernull.
-
getURLWithContext
@Nonnull public static com.helger.commons.url.SimpleURL getURLWithContext(@Nonnull com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, @Nonnull String sHRef) Prefix the passed href with the relative context path in case the passed href has no protocol yet.- Parameters:
aRequestScope- The request web scope to be used. Required for cookie-less handling. May not benull.sHRef- The href to be extended. May not benull.- Returns:
- Either the original href if already absolute or
/webapp-context/hrefotherwise. Nevernull.
-
getURIWithServerAndContext
Prefix the passed href with the absolute server + context path in case the passed href has no protocol yet.
Important: this method does not add the session ID in case cookies are disabled by the client!- Parameters:
sHRef- The href to be extended. May not benull.- Returns:
- Either the original href if already absolute or
http://servername:8123/webapp-context/hrefotherwise. Nevernull.
-
getURIWithServerAndContext
@Nonnull public static String getURIWithServerAndContext(@Nonnull com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, @Nonnull String sHRef) Prefix the passed href with the absolute server + context path in case the passed href has no protocol yet.- Parameters:
aRequestScope- The request web scope to be used. Required for cookie-less handling. May not benull.sHRef- The href to be extended. May not benull.- Returns:
- Either the original href if already absolute or
http://servername:8123/webapp-context/hrefotherwise. Nevernull.
-
getURLWithServerAndContext
@Nonnull public static com.helger.commons.url.SimpleURL getURLWithServerAndContext(@Nonnull String sHRef) Prefix the passed href with the absolute server + context path in case the passed href has no protocol yet.
Important: this method does not add the session ID in case cookies are disabled by the client!- Parameters:
sHRef- The href to be extended.- Returns:
- Either the original href if already absolute or
http://servername:8123/webapp-context/hrefotherwise.
-
getURLWithServerAndContext
@Nonnull public static com.helger.commons.url.SimpleURL getURLWithServerAndContext(@Nonnull com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, @Nonnull String sHRef) Prefix the passed href with the absolute server + context path in case the passed href has no protocol yet.- Parameters:
aRequestScope- The request web scope to be used. Required for cookie-less handling. May not benull.sHRef- The href to be extended.- Returns:
- Either the original href if already absolute or
http://servername:8123/webapp-context/hrefotherwise.
-
getHomeLinkWithoutSession
- Returns:
- A link to the start page without any session ID. Never
null. E.g./or/context. This is useful for logout links.
-
getStreamURL
@Nonnull public static com.helger.commons.url.SimpleURL getStreamURL(@Nonnull com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, @Nonnull @Nonempty String sURL) Get the default URL to stream the passed URL. It is assumed that the servlet is located under the path "/stream". Because of the logic of the stream servlet, no parameter are assumed.- Parameters:
aRequestScope- The request web scope to be used. Required for cookie-less handling. May not benull.sURL- The URL to be streamed. If it does not start with a slash ("/") one is prepended automatically. If the URL already has a protocol, it is returned unchanged. May neither benullnor empty.- Returns:
- The URL incl. the context to be stream. E.g.
/webapp-context/stream/URL.
-