Package io.inversion
Class Response
java.lang.Object
io.inversion.Response
- All Implemented Interfaces:
io.inversion.json.JSFind
This class serves as holder for the Response returned from a RestClient call AND as the object
used to construct your own response to an Engine request.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Chainprotected final StringBuilderprotected longprotected Throwableprotected Stringprotected io.inversion.json.JSNodeprotected Requestprotected longprotected intprotected Stringprotected io.inversion.utils.StreamBufferprotected Stringprotected String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassertDebug(String lineMatch, String... matches) assertStatus(int... statusCodes) assertStatus(String message, int... statusCodes) voidio.inversion.json.JSListdata()dump()io.inversion.utils.StreamBuffergetBody()io.inversion.utils.StreamBuffergetBody(boolean explain) getChain()longThis is the value returned from the server via the "Content-Length" header NOTE: this will not match file length, for partial downloads, consider also using ContentRangeSizegetDebug()longgetEndAt()getError()getFirst()io.inversion.json.JSMapintio.inversion.json.JSNodegetJson()getLast()io.inversion.json.JSNodegetMeta()getNext()getOp()intintintgetPrev()getSelf()longintgetText()getUrl()booleanhasStatus(int... statusCodes) booleanvoidrethrow()voidrethrow(int statusCode) voidvoidtoString()protected voidwithBody(io.inversion.utils.StreamBuffer stream) withChange(String method, String collectionKey, Object resourceKey) withChange(String method, String collectionKey, String... resourceKeys) withChanges(Collection<Change> changes) withContentType(String contentType) withEndAt(long endAt) withFileName(String fileName) withFoundRows(int foundRows) voidwithHeader(String key, String value) voidwithHeaders(io.inversion.utils.ListMap headers) withJson(io.inversion.json.JSNode json) Sets the root output json document...you should use withData and withMeta instead unless you REALLY want to change to wrapper document structure.withLastKey(String lastKey) withPageCount(int pageCount) withPageNum(int pageNum) withPageSize(int pageSize) withRecord(Object record) withRecords(List records) withRedirect(String redirect) withRequest(Request request) withStartAt(long startAt) withStatus(String status) withStatusCode(int statusCode) withStatusMesg(String statusMesg) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.inversion.json.JSFind
find, findAll, findAll, findAll0, findAll0, findBoolean, findDouble, findInt, findList, findLists, findLong, findMap, findMaps, findNode, findString, streamAll
-
Field Details
-
chain
-
request
-
statusCode
protected int statusCode -
statusMesg
-
url
-
fileName
-
headers
-
json
protected io.inversion.json.JSNode json -
text
-
stream
protected io.inversion.utils.StreamBuffer stream -
error
-
debug
-
changes
-
startAt
protected long startAt -
endAt
protected long endAt
-
-
Constructor Details
-
Response
public Response() -
Response
-
-
Method Details
-
withJson
Sets the root output json document...you should use withData and withMeta instead unless you REALLY want to change to wrapper document structure.- Parameters:
json- the json to set- Returns:
- this
-
withJson
-
withText
-
withBody
-
withBody
-
getJson
public io.inversion.json.JSNode getJson()- Specified by:
getJsonin interfaceio.inversion.json.JSFind
-
getText
-
getBody
public io.inversion.utils.StreamBuffer getBody() -
getBody
public io.inversion.utils.StreamBuffer getBody(boolean explain) -
debug
-
getDebug
-
dump
-
getStartAt
public long getStartAt() -
withStartAt
-
getEndAt
public long getEndAt() -
withEndAt
-
withUrl
-
withFileName
-
getUrl
-
withRequest
-
getRequest
-
getOp
-
getChain
-
withChain
-
getEngine
-
toString
-
withError
-
getError
-
withMeta
-
getMeta
public io.inversion.json.JSNode getMeta() -
withFoundRows
-
getFoundRows
public int getFoundRows() -
withLastKey
-
getLastKey
-
withPageSize
-
getPageSize
public int getPageSize() -
withPageNum
-
getPageNum
public int getPageNum() -
withPageCount
-
getPageCount
public int getPageCount() -
updatePageCount
protected void updatePageCount() -
withLink
-
getLink
-
getSelf
-
withSelf
-
getNext
-
withNext
-
getPrev
-
withPrev
-
getFirst
-
withFirst
-
getLast
-
withLast
-
data
public io.inversion.json.JSList data() -
getFirstRecordAsMap
public io.inversion.json.JSMap getFirstRecordAsMap() -
withRecord
-
withRecords
-
isSuccess
public boolean isSuccess() -
withStatus
- Parameters:
status- - one of the SC constants ex "200 OK"- Returns:
- this
-
hasStatus
public boolean hasStatus(int... statusCodes) -
getStatus
-
withStatusCode
-
getStatusCode
public int getStatusCode()- Returns:
- the statusCode
-
getStatusMesg
- Returns:
- the statusMesg
-
withStatusMesg
-
getHeaders
- Returns:
- the headers
-
withHeaders
public void withHeaders(io.inversion.utils.ListMap headers) -
getHeader
-
withHeader
-
clearHeaders
public void clearHeaders() -
getRedirect
-
withRedirect
-
withContentType
-
getContentType
-
getContentLength
public long getContentLength()This is the value returned from the server via the "Content-Length" header NOTE: this will not match file length, for partial downloads, consider also using ContentRangeSize- Returns:
- the value of the Content-Length header if it exists else 0
-
getChanges
-
withChanges
-
withChange
-
withChange
-
assertOk
-
rethrow
public void rethrow() -
rethrow
public void rethrow(int statusCode) -
rethrow
-
rethrow
-
assertStatus
-
assertStatus
-
assertDebug
-