com.vaadin.flow.router.
Class Location
All Implemented Interfaces:
Represents a relative URL made up of path segments and query parameters, but lacking e.g. the hostname that can also be present in URLs.
For related utility methods, see LocationUtil
.
Since:
1.0
Author:
Vaadin Ltd
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new
Location
object for given location string.Location
(String location, QueryParameters queryParameters) Creates a new
Location
object for given location string and query parameters.Creates a new location based on a list of path segments.
Location
(List<String> segments, QueryParameters queryParameters) Creates a new location based on a list of path segments and query parameters.
-
Method Summary
Modifier and TypeMethodDescriptionGets the first segment of this path.
getPath()
Gets the path of this location as a string.
Gets the path string with
QueryParameters
and including the possible fragment if one existed.Gets the request parameters used for current location.
Gets all the path segments of this location.
Creates a new location without the first path segment.
Removes or adds slash to the end of the location path.
-
Constructor Details
-
Location
Creates a new
Location
object for given location string.This string can contain relative path and query parameters, if needed. A possible fragment
#fragment
is also retained.A possible "/" prefix of the location is ignored and a
null
location is interpreted as""
Parameters:
location
- the relative location ornull
which is interpreted as""
]Throws:
InvalidLocationException
- If the given string cannot be used for theLocation
-
Location
Creates a new
Location
object for given location string and query parameters.The location string can not contain query parameters. To pass query parameters, either specify them in
QueryParameters
in this constructor, or useLocation(String)
A possible "/" prefix of the location is ignored and a
null
location is interpreted as""
Parameters:
location
- the relative location ornull
which is interpreted as""
queryParameters
- query parameters information, notnull
Throws:
InvalidLocationException
- If the given string cannot be used for theLocation
-
Location
Creates a new location based on a list of path segments.
Parameters:
segments
- a non-empty list of path segments, notnull
-
Location
Creates a new location based on a list of path segments and query parameters.
Parameters:
segments
- a non-empty list of path segments, notnull
and not emptyqueryParameters
- query parameters information, notnull
-
-
Method Details
-
getSegments
Gets all the path segments of this location.
Returns:
a list of path segments
-
getQueryParameters
Gets the request parameters used for current location.
Returns:
the request parameters
-
getFirstSegment
Gets the first segment of this path.
Returns:
the first path segment, not
null
-
getSubLocation
Creates a new location without the first path segment. The result is empty if this location only consists of one segment.
Returns:
an optional new location, or an empty optional if this location has only one path segment
-
getPath
Gets the path of this location as a string.
Returns:
the location string, not
null
-
getPathWithQueryParameters
Gets the path string with
QueryParameters
and including the possible fragment if one existed.Returns:
path string with parameters
-
toggleTrailingSlash
Removes or adds slash to the end of the location path. Creates new
Location
instance instead of modifying the old one.Returns:
new
Location
instance with updated path
-