org.simpleframework.transport
Class TransportSender

java.lang.Object
  extended by org.simpleframework.transport.TransportSender
All Implemented Interfaces:
Sender

public class TransportSender
extends Object
implements Sender

The TransportSender object is used to send bytes to and underlying transport. This is essentially an adapter between an OutputStream and the underlying transport. Each byte array segment written to the underlying transport is wrapped in a bytes buffer so that it can be sent by the transport layer.

Author:
Niall Gallagher
See Also:
Transport

Constructor Summary
TransportSender(Transport transport)
          Constructor for the TransportSender object.
 
Method Summary
 void close()
          This is used to close the sender and the underlying transport.
 void flush()
          This method is used to flush the contents of the buffer to the client.
 void send(byte[] array)
          This method is used to deliver the provided array of bytes to the underlying transport.
 void send(byte[] array, int off, int len)
          This method is used to deliver the provided array of bytes to the underlying transport.
 void send(ByteBuffer buffer)
          This method is used to deliver the provided buffer of bytes to the underlying transport.
 void send(ByteBuffer buffer, int off, int len)
          This method is used to deliver the provided buffer of bytes to the underlying transport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransportSender

public TransportSender(Transport transport)
Constructor for the TransportSender object. This is used to create an adapter for the transport such that a byte array can be used to write bytes to the array.

Parameters:
transport - the underlying transport to send bytes to
Method Detail

send

public void send(byte[] array)
          throws IOException
This method is used to deliver the provided array of bytes to the underlying transport. Depending on the connection type the array may be encoded for SSL transport or send directly. Any implementation may choose to buffer the bytes for performance.

Specified by:
send in interface Sender
Parameters:
array - this is the array of bytes to send to the client
Throws:
IOException

send

public void send(byte[] array,
                 int off,
                 int len)
          throws IOException
This method is used to deliver the provided array of bytes to the underlying transport. Depending on the connection type the array may be encoded for SSL transport or send directly. Any implementation may choose to buffer the bytes for performance.

Specified by:
send in interface Sender
Parameters:
array - this is the array of bytes to send to the client
off - this is the offset within the array to send from
len - this is the number of bytes that are to be sent
Throws:
IOException

send

public void send(ByteBuffer buffer)
          throws IOException
This method is used to deliver the provided buffer of bytes to the underlying transport. Depending on the connection type the array may be encoded for SSL transport or send directly. Any implementation may choose to buffer the bytes for performance.

Specified by:
send in interface Sender
Parameters:
buffer - this is the buffer of bytes to send to the client
Throws:
IOException

send

public void send(ByteBuffer buffer,
                 int off,
                 int len)
          throws IOException
This method is used to deliver the provided buffer of bytes to the underlying transport. Depending on the connection type the array may be encoded for SSL transport or send directly. Any implementation may choose to buffer the bytes for performance.

Specified by:
send in interface Sender
Parameters:
buffer - this is the buffer of bytes to send to the client
off - this is the offset within the buffer to send from
len - this is the number of bytes that are to be sent
Throws:
IOException

flush

public void flush()
           throws IOException
This method is used to flush the contents of the buffer to the client. This method will block until such time as all of the data has been sent to the client. If at any point there is an error sending the content an exception is thrown.

Specified by:
flush in interface Sender
Throws:
IOException

close

public void close()
           throws IOException
This is used to close the sender and the underlying transport. If a close is performed on the sender then no more bytes can be read from or written to the transport and the client will received a connection close on their side.

Specified by:
close in interface Sender
Throws:
IOException


Copyright © 2013. All Rights Reserved.