Package jakarta.ws.rs.core
Class Link
java.lang.Object
jakarta.ws.rs.core.Link
 Class representing hypermedia links. A hypermedia link may include additional parameters beyond its underlying URI.
 Parameters such as rel or type provide additional meta-data. Links in responses can be
 followed by creating an Invocation.Builder or a
 WebTarget.
 
 The methods toString() and valueOf(java.lang.String) can be used to serialize and de-serialize a link into a link
 header (RFC 5988).
 
- Since:
- 2.0
- Author:
- Marek Potociar, Santiago Pericas-Geertsen
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceBuilder class for hypermedia links.static classDeprecated.static classDeprecated.
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic Link.BuilderCreate a new builder instance initialized from another link.static Link.BuilderfromMethod(Class<?> resource, String method) Convenience method to build a link from a resource.static Link.BuilderConvenience method to build a link from a path.static Link.BuilderfromResource(Class<?> resource) Convenience method to build a link from a resource.static Link.BuilderCreate a new builder instance initialized from an existing URI represented as a string.static Link.BuilderCreate a new builder instance initialized from an existing URI.static Link.BuilderfromUriBuilder(UriBuilder uriBuilder) Create a new builder instance initialized from a URI builder.Returns an immutable map that includes all the link parameters defined on this link.abstract StringgetRel()Returns the value associated with the linkrelparam, ornullif this param is not specified.getRels()Returns the value associated with the linkrelparam as a list of strings or the empty list ifrelis not defined.abstract StringgetTitle()Returns the value associated with the linktitleparam, ornullif this param is not specified.abstract StringgetType()Returns the value associated with the linktypeparam, ornullif this param is not specified.abstract URIgetUri()Returns the underlying URI associated with this link.abstract UriBuilderConvenience method that returns aUriBuilderinitialized with this link's underlying URI.abstract StringtoString()Returns a string representation as a link header (RFC 5988).static LinkSimple parser to convert link header string representations into a link.
- 
Field Details- 
TITLETitle link param from RFC 5988.- See Also:
 
- 
RELRel link param from RFC 5988.- See Also:
 
- 
TYPEType link param from RFC 5988.- See Also:
 
 
- 
- 
Constructor Details- 
Linkpublic Link()
 
- 
- 
Method Details- 
getUriReturns the underlying URI associated with this link.- Returns:
- underlying URI.
 
- 
getUriBuilderConvenience method that returns aUriBuilderinitialized with this link's underlying URI.- Returns:
- UriBuilder initialized using underlying URI.
 
- 
getRelReturns the value associated with the linkrelparam, ornullif this param is not specified.- Returns:
- relation types as string or null.
 
- 
getRelsReturns the value associated with the linkrelparam as a list of strings or the empty list ifrelis not defined.- Returns:
- relation types as list of strings or empty list.
 
- 
getTitleReturns the value associated with the linktitleparam, ornullif this param is not specified.- Returns:
- value of title parameter or null.
 
- 
getTypeReturns the value associated with the linktypeparam, ornullif this param is not specified.- Returns:
- value of type parameter or null.
 
- 
getParamsReturns an immutable map that includes all the link parameters defined on this link. If defined, this map will include entries forrel,titleandtype.- Returns:
- immutable map of link parameters.
 
- 
toStringReturns a string representation as a link header (RFC 5988). All link params are serialized as link-param="value" where value is a quoted-string. For example, <http://foo.bar/employee/john>; title="employee"; rel="manager friend"
- 
valueOfSimple parser to convert link header string representations into a link.link ::= '<' uri 'gt;' (';' link-param)* link-param ::= name '=' quoted-stringSee RFC 5988 for more information.- Parameters:
- value- String representation.
- Returns:
- newly parsed link.
- Throws:
- IllegalArgumentException- if a syntax error is found.
- See Also:
 
- 
fromUriCreate a new builder instance initialized from an existing URI.- Parameters:
- uri- a URI that will be used to initialize the builder.
- Returns:
- a new builder.
- Throws:
- IllegalArgumentException- if uri is- null.
 
- 
fromUriCreate a new builder instance initialized from an existing URI represented as a string.- Parameters:
- uri- a URI that will be used to initialize the builder.
- Returns:
- a new builder.
- Throws:
- IllegalArgumentException- if uri is- null.
 
- 
fromUriBuilderCreate a new builder instance initialized from a URI builder.- Parameters:
- uriBuilder- instance of URI builder.
- Returns:
- a new builder.
 
- 
fromLinkCreate a new builder instance initialized from another link.- Parameters:
- link- other link used for initialization.
- Returns:
- a new builder.
 
- 
fromPathConvenience method to build a link from a path. Equivalent tofromUriBuilder(UriBuilder.fromPath(path)).- Parameters:
- path- a URI path that will be used to initialize the Link, may contain URI template parameters.
- Returns:
- a new Link.Builder.
- Throws:
- IllegalArgumentException- if path is- null.
 
- 
fromResourceConvenience method to build a link from a resource. Equivalent toLink.fromUriBuilder({@link UriBuilder#fromResource UriBuilder.fromResource(resource)}). Note that the link URI passed to theLink.Builderinstance returned by this method is relative. Should the link be built as absolute, abase URIhas to be specified in the builder prior to building the new link instance. For example, on a server side aUriInfo.getBaseUri()may be typically used to define the base URI of a link created using this method.- Parameters:
- resource- a root resource whose- Pathvalue will be used to initialize the builder.
- Returns:
- a new link builderinstance.
- Throws:
- IllegalArgumentException- if resource is not annotated with- Pathor resource is- null.
- See Also:
 
- 
fromMethodConvenience method to build a link from a resource. Equivalent toLink.fromUriBuilder({@link UriBuilder#fromMethod(Class, String) UriBuilder.fromMethod(resource, method)}). Note that the link URI passed to theLink.Builderinstance returned by this method is relative. Should the link be built as absolute, abase URIhas to be specified in the builder prior to building the new link instance. For example, on a server side aUriInfo.getBaseUri()may be typically used to define the base URI of a link created using this method.- Parameters:
- resource- the resource containing the method.
- method- the name of the method whose- Pathvalue will be used to obtain the path to append.
- Returns:
- the updated Link.Builder.
- Throws:
- IllegalArgumentException- if resource or method is- null, or there is more than or less than one variant of the method annotated with- Path.
- See Also:
 
 
-