Package com.jcabi.http.response
Class WebLinkingResponse
- java.lang.Object
-
- com.jcabi.http.response.WebLinkingResponse
-
- All Implemented Interfaces:
Response
@Immutable public final class WebLinkingResponse extends Object
Web Linking response.This response decorator is able to understand and parse
LinkHTTP header according to RFC 5988 "Web Linking", for example:String name = new JdkRequest("http://my.example.com") .fetch() .as(WebLinkingResponse.class) .follow("next") .fetch();The class is immutable and thread-safe.
- Since:
- 0.9
- See Also:
- RFC 5988 "Web Linking"
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceWebLinkingResponse.LinkSingle link.
-
Constructor Summary
Constructors Constructor Description WebLinkingResponse(Response resp)Public ctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends Response>
Tas(Class<T> type)Convert it to another type, by encapsulation.Requestback()Get back to the request it's related to.byte[]binary()Raw body as a an array of bytes.Stringbody()Get body as a string, assuming it'sUTF-8(if there is something else that can't be translated into a UTF-8 string a runtime exception will be thrown).Requestfollow(String rel)Follow link by REL.Map<String,List<String>>headers()Get a collection of all headers.Map<String,WebLinkingResponse.Link>links()Get all links provided.Stringreason()Get status line reason phrase.intstatus()Get status of the response as a positive integer number.StringtoString()
-
-
-
Constructor Detail
-
WebLinkingResponse
public WebLinkingResponse(Response resp)
Public ctor.- Parameters:
resp- Response
-
-
Method Detail
-
follow
public Request follow(String rel) throws IOException
Follow link by REL.- Parameters:
rel- Relation name- Returns:
- The same object
- Throws:
IOException- If fails
-
links
public Map<String,WebLinkingResponse.Link> links() throws IOException
Get all links provided.- Returns:
- List of all links found
- Throws:
IOException- If fails
-
back
public final Request back()
Description copied from interface:ResponseGet back to the request it's related to.
-
status
public final int status()
Description copied from interface:ResponseGet status of the response as a positive integer number.
-
reason
public final String reason()
Description copied from interface:ResponseGet status line reason phrase.
-
headers
public final Map<String,List<String>> headers()
Description copied from interface:ResponseGet a collection of all headers.
-
body
public String body()
Description copied from interface:ResponseGet body as a string, assuming it'sUTF-8(if there is something else that can't be translated into a UTF-8 string a runtime exception will be thrown).DISCLAIMER: The only encoding supported here is UTF-8. If the body of response contains any chars that can't be used and should be replaced with a "replacement character", a
RuntimeExceptionwill be thrown. If you need to use some other encodings, useResponse.binary()instead.
-
binary
public final byte[] binary()
Description copied from interface:ResponseRaw body as a an array of bytes.
-
-