org.apache.qpid.proton.engine.impl.ssl
Class ByteHolder

java.lang.Object
  extended by org.apache.qpid.proton.engine.impl.ssl.ByteHolder

public class ByteHolder
extends Object

I thinly wrap a ByteBuffer to facilitate its usage e.g. in SimpleSslTransportWrapper. At a given moment I am either in a state that is ready to be written to, or read from. To switch between these states, call prepareToRead() or prepareToWrite(), each of which returns the ByteBuffer ready to be used.


Constructor Summary
ByteHolder(int capacity)
          Creates me, initially in a writeable state
 
Method Summary
 int getCapacity()
           
 boolean hasSpace()
           
 ByteBuffer prepareToRead()
           
 ByteBuffer prepareToWrite()
          prepare me to be written to again
 int readInto(byte[] destination, int offset, int numberOfBytesRequested)
          Read my bytes into the supplied destination
 boolean readInto(TransportInput transportInput)
           
 int writeOutputFrom(TransportOutput transportOutput)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteHolder

public ByteHolder(int capacity)
Creates me, initially in a writeable state

Method Detail

hasSpace

public boolean hasSpace()

writeOutputFrom

public int writeOutputFrom(TransportOutput transportOutput)
Returns:
the total number of bytes I now contain

prepareToRead

public ByteBuffer prepareToRead()
Returns:
a ByteBuffer wrapping the stored bytes, intended to be read from

readInto

public int readInto(byte[] destination,
                    int offset,
                    int numberOfBytesRequested)
Read my bytes into the supplied destination

Returns:
the number of byte actually read (might be less than numberOfBytesRequested if I contain fewer bytes than that)

readInto

public boolean readInto(TransportInput transportInput)
Returns:
whether all my bytes were read into the TransportInput (i.e. returns false if transportInput didn't accept all the bytes)

prepareToWrite

public ByteBuffer prepareToWrite()
prepare me to be written to again

Returns:
a ByteBuffer, ready to be written to.

getCapacity

public int getCapacity()


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.