-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description Link.Builder
baseUri(String uri)
Set the base URI as a string for resolution of relative URIs.Link.Builder
baseUri(URI uri)
Set the base URI for resolution of relative URIs.Link
build(Object... values)
Finish building this link using the supplied values as URI parameters.Link
buildRelativized(URI uri, Object... values)
Finish building this link using the supplied values as URI parameters and relativize the result with respect to the supplied URI.Link.Builder
link(Link link)
Initialize builder using another link.Link.Builder
link(String link)
Initialize builder using another link represented as a string.Link.Builder
param(String name, String value)
Set an arbitrary parameter on this link.Link.Builder
rel(String rel)
Convenience method to set a link relation.Link.Builder
title(String title)
Convenience method to set atitle
on this link.Link.Builder
type(String type)
Convenience method to set atype
on this link.Link.Builder
uri(String uri)
Set underlying string representing URI template for the link being constructed.Link.Builder
uri(URI uri)
Set underlying URI template for the link being constructed.Link.Builder
uriBuilder(UriBuilder uriBuilder)
Set underlying URI builder representing the URI template for the link being constructed.
-
-
-
Method Detail
-
link
Link.Builder link(Link link)
Initialize builder using another link. Sets underlying URI and copies all parameters.- Parameters:
link
- other link from which to initialize.- Returns:
- the updated builder.
-
link
Link.Builder link(String link)
Initialize builder using another link represented as a string. Uses simple parser to convert string representation into a link.link ::= '<' uri '>' (';' link-param)* link-param ::= name '=' quoted-string
See RFC 5988 for more information.- Parameters:
link
- other link in string representation.- Returns:
- the updated builder.
- Throws:
IllegalArgumentException
- if string representation of URI is invalid.
-
uri
Link.Builder uri(URI uri)
Set underlying URI template for the link being constructed.- Parameters:
uri
- underlying URI for link- Returns:
- the updated builder.
-
uri
Link.Builder uri(String uri)
Set underlying string representing URI template for the link being constructed.- Parameters:
uri
- underlying URI for link.- Returns:
- the updated builder.
- Throws:
IllegalArgumentException
- if string representation of URI is invalid.
-
baseUri
Link.Builder baseUri(URI uri)
Set the base URI for resolution of relative URIs. If the underlying URI is already absolute, the base URI is ignored.- Parameters:
uri
- base URI for relative links.- Returns:
- the updated builder.
- See Also:
Link.fromPath(java.lang.String)
,Link.fromResource(java.lang.Class)
,Link.fromMethod(java.lang.Class, java.lang.String)
-
baseUri
Link.Builder baseUri(String uri)
Set the base URI as a string for resolution of relative URIs. If the underlying URI is already absolute, the base URI is ignored.- Parameters:
uri
- base URI for relative links.- Returns:
- the updated builder.
- Throws:
IllegalArgumentException
- if string representation of URI is invalid.- See Also:
Link.fromPath(java.lang.String)
,Link.fromResource(java.lang.Class)
,Link.fromMethod(java.lang.Class, java.lang.String)
-
uriBuilder
Link.Builder uriBuilder(UriBuilder uriBuilder)
Set underlying URI builder representing the URI template for the link being constructed.- Parameters:
uriBuilder
- underlying URI builder.- Returns:
- the updated builder.
-
rel
Link.Builder rel(String rel)
Convenience method to set a link relation. More than onerel
value can be specified by using one or more whitespace characters as delimiters according to RFC 5988. The effect of calling this method is cumulative; relations are appended using a single space character as separator.- Parameters:
rel
- relation name.- Returns:
- the updated builder.
- Throws:
IllegalArgumentException
- if the name isnull
.
-
title
Link.Builder title(String title)
Convenience method to set atitle
on this link.- Parameters:
title
- title parameter of this link.- Returns:
- the updated builder.
- Throws:
IllegalArgumentException
- if the title isnull
.
-
type
Link.Builder type(String type)
Convenience method to set atype
on this link.- Parameters:
type
- type parameter of this link.- Returns:
- the updated builder.
- Throws:
IllegalArgumentException
- if the type isnull
.
-
param
Link.Builder param(String name, String value)
Set an arbitrary parameter on this link. Note that link parameters are those defined in RFC 5988 and should not be confused with URI parameters which can be specified when callingbuild(Object...)
.- Parameters:
name
- the name of the parameter.value
- the value set for the parameter.- Returns:
- the updated builder.
- Throws:
IllegalArgumentException
- if either the name or value arenull
.
-
build
Link build(Object... values)
Finish building this link using the supplied values as URI parameters. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.- Parameters:
values
- parameters used to build underlying URI.- Returns:
- newly built link.
- Throws:
IllegalArgumentException
- if there are any URI template parameters without a supplied value, or if a value isnull
.UriBuilderException
- if a URI cannot be constructed based on the current state of the underlying URI builder.
-
buildRelativized
Link buildRelativized(URI uri, Object... values)
Finish building this link using the supplied values as URI parameters and relativize the result with respect to the supplied URI. If the underlying link is already relative or if it is absolute but does not share a prefix with the supplied URI, this method is equivalent to callingbuild(java.lang.Object[])
. Note that a base URI can be set on a relative link usingbaseUri(java.net.URI)
. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.- Parameters:
uri
- URI used for relativization.values
- parameters used to build underlying URI.- Returns:
- newly built link.
- Throws:
IllegalArgumentException
- if there are any URI template parameters without a supplied value, or if a value isnull
.UriBuilderException
- if a URI cannot be constructed based on the current state of the underlying URI builder.- See Also:
baseUri(java.lang.String)
,baseUri(java.net.URI)
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
21/08/2025 15:08:11 Cette version de la page est en cache (à la date du 21/08/2025 15:08:11) afin d'accélérer le traitement.Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.
Document créé le 11/06/2005, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/ws/rs/core/Link.Builder.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.