Package io.inversion

Class Response

java.lang.Object
io.inversion.Response

public class Response extends Object
  • Field Details

    • startAt

      protected long startAt
    • endAt

      protected long endAt
    • request

      protected Request request
    • headers

      protected final org.apache.commons.collections4.multimap.ArrayListValuedHashMap<String,String> headers
    • changes

      protected final List<Change> changes
    • debug

      protected final StringBuilder debug
    • url

      protected String url
    • chain

      protected Chain chain
    • statusCode

      protected int statusCode
    • statusMesg

      protected String statusMesg
    • redirect

      protected String redirect
    • contentType

      protected String contentType
    • out

      protected StringBuilder out
    • json

      protected JSNode json
    • text

      protected String text
    • fileName

      protected String fileName
    • file

      protected File file
    • error

      protected Throwable error
    • contentRangeUnit

      protected String contentRangeUnit
    • contentRangeStart

      protected long contentRangeStart
    • contentRangeEnd

      protected long contentRangeEnd
    • contentRangeSize

      protected long contentRangeSize
  • Constructor Details

    • Response

      public Response()
    • Response

      public Response(String url)
  • Method Details

    • getStartAt

      public long getStartAt()
    • withStartAt

      public Response withStartAt(long startAt)
    • getEndAt

      public long getEndAt()
    • withEndAt

      public Response withEndAt(long endAt)
    • hasStatus

      public boolean hasStatus(int... statusCodes)
    • withMeta

      public Response withMeta(String key, String value)
    • write

      public void write(StringBuilder buff, Object... msgs)
    • write0

      protected void write0(StringBuilder buff, Object... msgs)
    • withStatus

      public Response withStatus(String status)
      Parameters:
      status - - one of the SC constants ex "200 OK"
      Returns:
      this
    • getStatus

      public String getStatus()
    • withStatusCode

      public Response withStatusCode(int statusCode)
    • withStatusMesg

      public Response withStatusMesg(String statusMesg)
    • getChain

      public Chain getChain()
    • getEngine

      public Engine getEngine()
    • withChain

      public Response withChain(Chain chain)
    • debug

      public Response debug(String format, Object... args)
    • out

      public Response out(Object... msgs)
    • withOutput

      public Response withOutput(String output)
    • getOutput

      public String getOutput()
    • dump

      public Response dump()
    • getDebug

      public String getDebug()
    • getHeader

      public String getHeader(String key)
    • getHeaders

      public org.apache.commons.collections4.multimap.ArrayListValuedHashMap<String,String> getHeaders()
      Returns:
      the headers
    • withHeaders

      public void withHeaders(org.apache.commons.collections4.multimap.ArrayListValuedHashMap headers)
    • withHeader

      public void withHeader(String key, String value)
    • withJson

      public Response withJson(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
    • findString

      public String findString(String path)
    • findInt

      public int findInt(String path)
    • findBoolean

      public boolean findBoolean(String path)
    • findNode

      public JSNode findNode(String path)
    • findArray

      public JSArray findArray(String path)
    • find

      public Object find(String path)
    • validate

      public Request.Validation validate(String jsonPath)
    • validate

      public Request.Validation validate(String jsonPath, String customErrorMessage)
    • data

      public JSArray data()
    • getData

      public JSArray getData()
    • withData

      public Response withData(JSArray data)
    • withRecord

      public Response withRecord(Object record)
    • withRecords

      public Response withRecords(List records)
    • getMeta

      public JSNode getMeta()
    • withMeta

      public Response withMeta(String key, Object value)
    • withFoundRows

      public Response withFoundRows(int foundRows)
    • getFoundRows

      public int getFoundRows()
    • withPageSize

      public Response withPageSize(int pageSize)
    • withPageNum

      public Response withPageNum(int pageNum)
    • withPageCount

      public Response withPageCount(int pageCount)
    • getPageSize

      public int getPageSize()
    • updatePageCount

      protected void updatePageCount()
    • getPageCount

      public int getPageCount()
    • next

      public String next()
    • withNext

      public Response withNext(String nextPageUrl)
    • getStatusMesg

      public String getStatusMesg()
      Returns:
      the statusMesg
    • getStatusCode

      public int getStatusCode()
      Returns:
      the statusCode
    • withText

      public Response withText(String text)
    • getResourceKey

      public String getResourceKey()
    • getRedirect

      public String getRedirect()
    • withRedirect

      public Response withRedirect(String redirect)
    • getContentType

      public String getContentType()
    • withContentType

      public Response withContentType(String contentType)
    • getChanges

      public List<Change> getChanges()
    • withChanges

      public Response withChanges(Collection<Change> changes)
    • withChange

      public Response withChange(String method, String collectionKey, Object resourceKey)
    • withChange

      public Response withChange(String method, String collectionKey, String... resourceKeys)
    • isSuccess

      public boolean isSuccess()
    • getError

      public Throwable getError()
    • getInputStream

      public InputStream getInputStream() throws IOException
      Throws:
      IOException
    • getJson

      public JSNode getJson()
      Returns:
      the json
    • getText

      public String getText()
    • getContent

      public String getContent()
    • getErrorContent

      public String getErrorContent()
    • getFileLength

      public long getFileLength()
    • withFile

      public Response withFile(File file)
    • getFile

      public File getFile()
    • 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
    • getContentRangeUnit

      public String getContentRangeUnit()
      This value come from the "Content-Range" header and is the unit part Content-Range: unit range-start-range-end/size
      Returns:
      the units from the content-range header
    • getContentRangeStart

      public long getContentRangeStart()
      This value come from the "Content-Range" header and is the first part Content-Range: unit range-start-range-end/size
      Returns:
      the start value from the content-range header
    • getContentRangeEnd

      public long getContentRangeEnd()
      This value come from the "Content-Range" header and is the middle part Content-Range: unit range-start-range-end/size
      Returns:
      then end value from the content-range header
    • getContentRangeSize

      public long getContentRangeSize()
      This value come from the "Content-Range" header and is the last part Content-Range: unit range-start-range-end/size
      Returns:
      then size value from the content-range header
    • withUrl

      public Response withUrl(String url)
    • withError

      public Response withError(Throwable ex)
    • getFileName

      public String getFileName()
    • getUrl

      public String getUrl()
    • withRequest

      public Response withRequest(Request request)
    • getRequest

      public Request getRequest()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • finalize

      public void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • assertOk

      public Response assertOk(String... messages)
    • rethrow

      public void rethrow()
    • rethrow

      public void rethrow(int statusCode)
    • rethrow

      public void rethrow(String... messages)
    • rethrow

      public void rethrow(int statusCode, String... messages)
    • assertStatus

      public Response assertStatus(int... statusCodes)
    • assertStatus

      public Response assertStatus(String message, int... statusCodes)
    • assertDebug

      public Response assertDebug(String lineMatch, String... matches)