Package io.inversion
Class Response
- java.lang.Object
-
- io.inversion.Response
-
- All Implemented Interfaces:
io.inversion.json.JSFind
public class Response extends java.lang.Object implements io.inversion.json.JSFindThis 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
Fields Modifier and Type Field Description protected Chainchainprotected java.util.List<Change>changesprotected java.lang.StringBuilderdebugprotected longendAtprotected java.lang.Throwableerrorprotected java.lang.StringfileNameprotected io.inversion.utils.ListMap<java.lang.String,java.lang.String>headersprotected io.inversion.json.JSNodejsonprotected Requestrequestprotected longstartAtprotected intstatusCodeprotected java.lang.StringstatusMesgprotected io.inversion.utils.StreamBufferstreamprotected java.lang.Stringtextprotected java.lang.Stringurl
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResponseassertDebug(java.lang.String lineMatch, java.lang.String... matches)ResponseassertOk(java.lang.String... messages)ResponseassertStatus(int... statusCodes)ResponseassertStatus(java.lang.String message, int... statusCodes)voidclearHeaders()io.inversion.json.JSListdata()Responsedebug(java.lang.String format, java.lang.Object... args)Responsedump()io.inversion.utils.StreamBuffergetBody()io.inversion.utils.StreamBuffergetBody(boolean explain)ChaingetChain()java.util.List<Change>getChanges()longgetContentLength()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 ContentRangeSizejava.lang.StringgetContentType()java.lang.StringgetDebug()longgetEndAt()EnginegetEngine()java.lang.ThrowablegetError()java.lang.StringgetFirst()io.inversion.json.JSMapgetFirstRecordAsMap()intgetFoundRows()java.lang.StringgetHeader(java.lang.String key)io.inversion.utils.ListMap<java.lang.String,java.lang.String>getHeaders()io.inversion.json.JSNodegetJson()java.lang.StringgetLast()java.lang.StringgetLastKey()java.lang.StringgetLink(java.lang.String name)io.inversion.json.JSNodegetMeta()java.lang.StringgetNext()OpgetOp()intgetPageCount()intgetPageNum()intgetPageSize()java.lang.StringgetPrev()java.lang.StringgetRedirect()RequestgetRequest()java.lang.StringgetSelf()longgetStartAt()java.lang.StringgetStatus()intgetStatusCode()java.lang.StringgetStatusMesg()java.lang.StringgetText()java.lang.StringgetUrl()booleanhasStatus(int... statusCodes)booleanisSuccess()voidrethrow()voidrethrow(int statusCode)voidrethrow(int statusCode, java.lang.String... messages)voidrethrow(java.lang.String... messages)java.lang.StringtoString()protected voidupdatePageCount()ResponsewithBody(io.inversion.utils.StreamBuffer stream)ResponsewithBody(io.inversion.utils.StreamBuffer stream, java.lang.String fileName)ResponsewithChain(Chain chain)ResponsewithChange(java.lang.String method, java.lang.String collectionKey, java.lang.Object resourceKey)ResponsewithChange(java.lang.String method, java.lang.String collectionKey, java.lang.String... resourceKeys)ResponsewithChanges(java.util.Collection<Change> changes)ResponsewithContentType(java.lang.String contentType)ResponsewithEndAt(long endAt)ResponsewithError(java.lang.Throwable ex)ResponsewithFileName(java.lang.String fileName)ResponsewithFirst(java.lang.String url)ResponsewithFoundRows(int foundRows)voidwithHeader(java.lang.String key, java.lang.String value)voidwithHeaders(io.inversion.utils.ListMap headers)ResponsewithJson(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.ResponsewithJson(java.lang.String json)ResponsewithLast(java.lang.String url)ResponsewithLastKey(java.lang.String lastKey)ResponsewithLink(java.lang.String name, java.lang.String url)ResponsewithMeta(java.lang.String key, java.lang.Object value)ResponsewithNext(java.lang.String url)ResponsewithPageCount(int pageCount)ResponsewithPageNum(int pageNum)ResponsewithPageSize(int pageSize)ResponsewithPrev(java.lang.String url)ResponsewithRecord(java.lang.Object record)ResponsewithRecords(java.util.List records)ResponsewithRedirect(java.lang.String redirect)ResponsewithRequest(Request request)ResponsewithSelf(java.lang.String url)ResponsewithStartAt(long startAt)ResponsewithStatus(java.lang.String status)ResponsewithStatusCode(int statusCode)ResponsewithStatusMesg(java.lang.String statusMesg)ResponsewithText(java.lang.String text)ResponsewithUrl(java.lang.String url)
-
-
-
Field Detail
-
chain
protected Chain chain
-
request
protected Request request
-
statusCode
protected int statusCode
-
statusMesg
protected java.lang.String statusMesg
-
url
protected java.lang.String url
-
fileName
protected java.lang.String fileName
-
headers
protected final io.inversion.utils.ListMap<java.lang.String,java.lang.String> headers
-
json
protected io.inversion.json.JSNode json
-
text
protected java.lang.String text
-
stream
protected io.inversion.utils.StreamBuffer stream
-
error
protected java.lang.Throwable error
-
debug
protected final java.lang.StringBuilder debug
-
changes
protected final java.util.List<Change> changes
-
startAt
protected long startAt
-
endAt
protected long endAt
-
-
Method Detail
-
withJson
public Response 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.- Parameters:
json- the json to set- Returns:
- this
-
withJson
public Response withJson(java.lang.String json)
-
withText
public Response withText(java.lang.String text)
-
withBody
public Response withBody(io.inversion.utils.StreamBuffer stream, java.lang.String fileName)
-
withBody
public Response withBody(io.inversion.utils.StreamBuffer stream)
-
getJson
public io.inversion.json.JSNode getJson()
- Specified by:
getJsonin interfaceio.inversion.json.JSFind
-
getText
public java.lang.String getText()
-
getBody
public io.inversion.utils.StreamBuffer getBody()
-
getBody
public io.inversion.utils.StreamBuffer getBody(boolean explain)
-
debug
public Response debug(java.lang.String format, java.lang.Object... args)
-
getDebug
public java.lang.String getDebug()
-
dump
public Response dump()
-
getStartAt
public long getStartAt()
-
withStartAt
public Response withStartAt(long startAt)
-
getEndAt
public long getEndAt()
-
withEndAt
public Response withEndAt(long endAt)
-
withUrl
public Response withUrl(java.lang.String url)
-
withFileName
public Response withFileName(java.lang.String fileName)
-
getUrl
public java.lang.String getUrl()
-
getRequest
public Request getRequest()
-
getOp
public Op getOp()
-
getChain
public Chain getChain()
-
getEngine
public Engine getEngine()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
withError
public Response withError(java.lang.Throwable ex)
-
getError
public java.lang.Throwable getError()
-
withMeta
public Response withMeta(java.lang.String key, java.lang.Object value)
-
getMeta
public io.inversion.json.JSNode getMeta()
-
withFoundRows
public Response withFoundRows(int foundRows)
-
getFoundRows
public int getFoundRows()
-
withLastKey
public Response withLastKey(java.lang.String lastKey)
-
getLastKey
public java.lang.String getLastKey()
-
withPageSize
public Response withPageSize(int pageSize)
-
getPageSize
public int getPageSize()
-
withPageNum
public Response withPageNum(int pageNum)
-
getPageNum
public int getPageNum()
-
withPageCount
public Response withPageCount(int pageCount)
-
getPageCount
public int getPageCount()
-
updatePageCount
protected void updatePageCount()
-
withLink
public Response withLink(java.lang.String name, java.lang.String url)
-
getLink
public java.lang.String getLink(java.lang.String name)
-
getSelf
public java.lang.String getSelf()
-
withSelf
public Response withSelf(java.lang.String url)
-
getNext
public java.lang.String getNext()
-
withNext
public Response withNext(java.lang.String url)
-
getPrev
public java.lang.String getPrev()
-
withPrev
public Response withPrev(java.lang.String url)
-
getFirst
public java.lang.String getFirst()
-
withFirst
public Response withFirst(java.lang.String url)
-
getLast
public java.lang.String getLast()
-
withLast
public Response withLast(java.lang.String url)
-
data
public io.inversion.json.JSList data()
-
getFirstRecordAsMap
public io.inversion.json.JSMap getFirstRecordAsMap()
-
withRecord
public Response withRecord(java.lang.Object record)
-
withRecords
public Response withRecords(java.util.List records)
-
isSuccess
public boolean isSuccess()
-
withStatus
public Response withStatus(java.lang.String status)
- Parameters:
status- - one of the SC constants ex "200 OK"- Returns:
- this
-
hasStatus
public boolean hasStatus(int... statusCodes)
-
getStatus
public java.lang.String getStatus()
-
withStatusCode
public Response withStatusCode(int statusCode)
-
getStatusCode
public int getStatusCode()
- Returns:
- the statusCode
-
getStatusMesg
public java.lang.String getStatusMesg()
- Returns:
- the statusMesg
-
withStatusMesg
public Response withStatusMesg(java.lang.String statusMesg)
-
getHeaders
public io.inversion.utils.ListMap<java.lang.String,java.lang.String> getHeaders()
- Returns:
- the headers
-
withHeaders
public void withHeaders(io.inversion.utils.ListMap headers)
-
getHeader
public java.lang.String getHeader(java.lang.String key)
-
withHeader
public void withHeader(java.lang.String key, java.lang.String value)
-
clearHeaders
public void clearHeaders()
-
getRedirect
public java.lang.String getRedirect()
-
withRedirect
public Response withRedirect(java.lang.String redirect)
-
withContentType
public Response withContentType(java.lang.String contentType)
-
getContentType
public java.lang.String 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
public java.util.List<Change> getChanges()
-
withChange
public Response withChange(java.lang.String method, java.lang.String collectionKey, java.lang.Object resourceKey)
-
withChange
public Response withChange(java.lang.String method, java.lang.String collectionKey, java.lang.String... resourceKeys)
-
assertOk
public Response assertOk(java.lang.String... messages)
-
rethrow
public void rethrow()
-
rethrow
public void rethrow(int statusCode)
-
rethrow
public void rethrow(java.lang.String... messages)
-
rethrow
public void rethrow(int statusCode, java.lang.String... messages)
-
assertStatus
public Response assertStatus(int... statusCodes)
-
assertStatus
public Response assertStatus(java.lang.String message, int... statusCodes)
-
assertDebug
public Response assertDebug(java.lang.String lineMatch, java.lang.String... matches)
-
-