Class ByteArrayEndPoint

    • Constructor Detail

      • ByteArrayEndPoint

        public ByteArrayEndPoint()
      • ByteArrayEndPoint

        public ByteArrayEndPoint​(byte[] input,
                                 int outputSize)
        Parameters:
        input - the input bytes
        outputSize - the output size
      • ByteArrayEndPoint

        public ByteArrayEndPoint​(String input,
                                 int outputSize)
        Parameters:
        input - the input string (converted to bytes using default encoding charset)
        outputSize - the output size
      • ByteArrayEndPoint

        public ByteArrayEndPoint​(Scheduler scheduler,
                                 long idleTimeoutMs)
      • ByteArrayEndPoint

        public ByteArrayEndPoint​(Scheduler timer,
                                 long idleTimeoutMs,
                                 byte[] input,
                                 int outputSize)
      • ByteArrayEndPoint

        public ByteArrayEndPoint​(Scheduler timer,
                                 long idleTimeoutMs,
                                 String input,
                                 int outputSize)
    • Method Detail

      • execute

        protected void execute​(Runnable task)
      • addInputEOF

        public void addInputEOF()
      • addInput

        public void addInput​(ByteBuffer in)
        Parameters:
        in - The in to set.
      • addInputAndExecute

        public void addInputAndExecute​(ByteBuffer in)
      • addInput

        public void addInput​(String s)
      • addInput

        public void addInput​(String s,
                             Charset charset)
      • getOutput

        public ByteBuffer getOutput()
        Returns:
        Returns the out.
      • getOutputString

        public String getOutputString()
        Returns:
        Returns the out.
      • getOutputString

        public String getOutputString​(Charset charset)
        Parameters:
        charset - the charset to encode the output as
        Returns:
        Returns the out.
      • takeOutput

        public ByteBuffer takeOutput()
        Returns:
        Returns the out.
      • takeOutputString

        public String takeOutputString()
        Returns:
        Returns the out.
      • takeOutputString

        public String takeOutputString​(Charset charset)
        Parameters:
        charset - the charset to encode the output as
        Returns:
        Returns the out.
      • setOutput

        public void setOutput​(ByteBuffer out)
        Parameters:
        out - The out to set.
      • isOpen

        public boolean isOpen()
        Description copied from class: IdleTimeout
        This abstract method should be called to check if idle timeouts should still be checked.
        Specified by:
        isOpen in interface EndPoint
        Specified by:
        isOpen in class IdleTimeout
        Returns:
        True if the entity monitored should still be checked for idle timeouts
      • isInputShutdown

        public boolean isInputShutdown()
        Description copied from interface: EndPoint
        Test if the input is shutdown. The input is shutdown if an EOF has been read while doing a EndPoint.fill(ByteBuffer). Once the input is shutdown, all calls to EndPoint.fill(ByteBuffer) will return -1, until such time as the end point is close, when they will return EofException.
        Returns:
        True if the input is shutdown or the endpoint is closed.
      • isOutputShutdown

        public boolean isOutputShutdown()
        Description copied from interface: EndPoint
        Test if output is shutdown. The output is shutdown by a call to EndPoint.shutdownOutput() or EndPoint.close().
        Returns:
        true if the output is shutdown or the endpoint is closed.
      • shutdownInput

        public void shutdownInput()
      • shutdownOutput

        public void shutdownOutput()
        Description copied from interface: EndPoint
        Shutdown the output.

        This call indicates that no more data will be sent on this endpoint that that the remote end should read an EOF once all previously sent data has been consumed. Shutdown may be done either at the TCP/IP level, as a protocol exchange (Eg TLS close handshake) or both.

        If the endpoint has EndPoint.isInputShutdown() true, then this call has the same effect as EndPoint.close().

      • hasMore

        public boolean hasMore()
        Returns:
        true if there are bytes remaining to be read from the encoded input
      • fill

        public int fill​(ByteBuffer buffer)
                 throws IOException
        Description copied from interface: EndPoint
        Fill the passed buffer with data from this endpoint. The bytes are appended to any data already in the buffer by writing from the buffers limit up to it's capacity. The limit is updated to include the filled bytes.
        Parameters:
        buffer - The buffer to fill. The position and limit are modified during the fill. After the operation, the position is unchanged and the limit is increased to reflect the new data filled.
        Returns:
        an int value indicating the number of bytes filled or -1 if EOF is read or the input is shutdown.
        Throws:
        IOException - if the endpoint is closed.
      • flush

        public boolean flush​(ByteBuffer... buffers)
                      throws IOException
        Description copied from interface: EndPoint
        Flush data from the passed header/buffer to this endpoint. As many bytes as can be consumed are taken from the header/buffer position up until the buffer limit. The header/buffers position is updated to indicate how many bytes have been consumed.
        Parameters:
        buffers - the buffers to flush
        Returns:
        True IFF all the buffers have been consumed and the endpoint has flushed the data to its destination (ie is not buffering any data).
        Throws:
        IOException - If the endpoint is closed or output is shutdown.
      • reset

        public void reset()
      • getTransport

        public Object getTransport()
        Returns:
        The underlying transport object (socket, channel, etc.)
      • isGrowOutput

        public boolean isGrowOutput()
        Returns:
        the growOutput
      • setGrowOutput

        public void setGrowOutput​(boolean growOutput)
        Parameters:
        growOutput - the growOutput to set