Package org.hcjf.io.net.http.pipeline
Class HttpPipelineResponse
- java.lang.Object
-
- org.hcjf.io.net.http.HttpPackage
-
- org.hcjf.io.net.http.HttpResponse
-
- org.hcjf.io.net.http.pipeline.HttpPipelineResponse
-
- Direct Known Subclasses:
ChunkedHttpPipelineResponse,MultipartHttpPipelineResponse
public abstract class HttpPipelineResponse extends HttpResponse
This class provides a way to create a pipeline between the http connection and the specific data source.- Author:
- javaito.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classHttpPipelineResponse.StreamingPackageThis class encapsulate the byte and custom properties send.-
Nested classes/interfaces inherited from class org.hcjf.io.net.http.HttpPackage
HttpPackage.ChunkedDecoderLayer, HttpPackage.HttpProtocol, HttpPackage.TransferDecodingLayerInterface
-
-
Field Summary
-
Fields inherited from class org.hcjf.io.net.http.HttpPackage
HTTP_CONTEXT_SEPARATOR, HTTP_FIELD_ASSIGNATION, HTTP_FIELD_SEPARATOR, HTTP_FIELD_START, LINE_FIELD_SEPARATOR, STRING_LINE_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description HttpPipelineResponse(int mainBufferSize, int bufferSize)
-
Method Summary
Modifier and Type Method Description java.nio.ByteBuffergetMainBuffer()Return the buffer, this method must be call before the read method.intgetReadCounter()Returns the counter of the read operations over pipeline.booleanisFirstRead()Verify if the first read over the pipeline.voidonEnd()This method is called after the last read over the pipeline.voidonStart()This method is called before the fir read over the pipeline.intread()This method reads the bytes of the application side of the pipeline and wrap this bytes depends of the result encoding.protected abstract intreadPipeline(HttpPipelineResponse.StreamingPackage streamingPackage)This method must implements the way to read the information from the application source.protected intwrap(java.nio.ByteBuffer result, HttpPipelineResponse.StreamingPackage streamingPackage, int size)This method wrap the byte with the encoding protocol.-
Methods inherited from class org.hcjf.io.net.http.HttpResponse
getProtocolHeader, getReasonPhrase, getResponseCode, processBody, processFirstLine, setReasonPhrase, setResponseCode, toString
-
Methods inherited from class org.hcjf.io.net.http.HttpPackage
addCookie, addData, addHeader, bodyDone, containsCookie, containsHeader, getBody, getCookie, getCookies, getHeader, getHeaders, getHttpVersion, getProtocol, isComplete, setBody, setHttpVersion, setProtocol, trimBody
-
-
-
-
Method Detail
-
isFirstRead
public final boolean isFirstRead()
Verify if the first read over the pipeline.- Returns:
- Returns true if the first read operation and false in the otherwise.
-
getReadCounter
public final int getReadCounter()
Returns the counter of the read operations over pipeline.- Returns:
- Counter of the read operations.
-
read
public final int read()
This method reads the bytes of the application side of the pipeline and wrap this bytes depends of the result encoding.- Returns:
- Buffer with all the read bytes if the buffer size is equals to -1 then this pipeline is done.
-
getMainBuffer
public final java.nio.ByteBuffer getMainBuffer()
Return the buffer, this method must be call before the read method.- Returns:
- Main buffer with all the read bytes.
-
wrap
protected int wrap(java.nio.ByteBuffer result, HttpPipelineResponse.StreamingPackage streamingPackage, int size)This method wrap the byte with the encoding protocol.- Parameters:
result- In this instance of the byte buffer, this method must put the byte to wrap the source data and the source data.streamingPackage- All the bytes read from the application source.size- Size of the buffer used to read the application source.- Returns:
- Byte array wrapped.
-
onStart
public void onStart()
This method is called before the fir read over the pipeline.
-
onEnd
public void onEnd()
This method is called after the last read over the pipeline.
-
readPipeline
protected abstract int readPipeline(HttpPipelineResponse.StreamingPackage streamingPackage)
This method must implements the way to read the information from the application source.- Parameters:
streamingPackage- Buffer to put all the read bytes.- Returns:
- Number of bytes read.
-
-