public class Mech2Result extends Object
It contains HttpRequest object and HttpResponse object.
| 修飾子とタイプ | メソッドと説明 |
|---|---|
org.apache.http.entity.ContentType |
getContentType()
Get ContentType object from the response.
|
org.apache.http.HttpRequest |
getRequest()
Get HttpRequest object.
|
org.apache.http.HttpResponse |
getResponse()
Get HttpResponse object.
|
byte[] |
getResponseBodyAsByteArray()
Get the HTTP response as byte array.
|
String |
getResponseBodyAsString()
Get the HTTP response as String.
|
int |
getStatusCode()
Shorthand for
mech.getResponse().getStatusLine().getStatusCode() |
boolean |
isJSONResponse()
Returns true if Content-Type of response is "application/json".
|
boolean |
isSuccess()
Returns true if the HttResponse has 2xx status code.
|
Mech2Result |
orDie()
throw exception if the response doesn't have 2xx response.
|
<T> T |
parseJSON(Class<T> valueType)
Parse JSON from content-body using jackson.
|
<T> T |
parseJSON(com.fasterxml.jackson.core.type.TypeReference<T> valueType)
Parse JSON from content-body using jackson.
|
<T> Mech2JSONResult<T> |
toJSONResult(Class<T> valueType)
Convert the result to Mech2JSONResult object.
|
<T> Mech2JSONResult<T> |
toJSONResult(com.fasterxml.jackson.core.type.TypeReference<T> klass)
Convert the result to Mech2JSONResult object.
|
public org.apache.http.HttpRequest getRequest()
public org.apache.http.HttpResponse getResponse()
public boolean isSuccess()
public boolean isJSONResponse()
public <T> Mech2JSONResult<T> toJSONResult(Class<T> valueType)
valueType - type of JSON valuepublic <T> Mech2JSONResult<T> toJSONResult(com.fasterxml.jackson.core.type.TypeReference<T> klass)
klass - type of JSON valuepublic <T> T parseJSON(com.fasterxml.jackson.core.type.TypeReference<T> valueType)
throws IOException
valueType - type of json valueIOExceptionpublic <T> T parseJSON(Class<T> valueType) throws IOException
valueType - type of json valueIOExceptionpublic Mech2Result orDie() throws Mech2FailException
public String getResponseBodyAsString() throws org.apache.http.ParseException, IOException
org.apache.http.ParseExceptionIOExceptionpublic byte[] getResponseBodyAsByteArray()
throws IOException
IOExceptionpublic int getStatusCode()
mech.getResponse().getStatusLine().getStatusCode()public org.apache.http.entity.ContentType getContentType()
Copyright © 2015. All rights reserved.