com.sentilla.platform.cmote
Class ByteSender

java.lang.Object
  extended by com.sentilla.platform.cmote.DispatcherAction
      extended by com.sentilla.platform.cmote.Sender
          extended by com.sentilla.platform.cmote.ByteSender
All Implemented Interfaces:
ByteMessage, ByteSender, Sender, Action

public class ByteSender
extends Sender
implements Action, ByteSender


Field Summary
 
Fields inherited from class com.sentilla.platform.cmote.Sender
address, data, nextData, protocol
 
Fields inherited from class com.sentilla.platform.cmote.DispatcherAction
actionState
 
Constructor Summary
ByteSender(int port)
           
 
Method Summary
 Action block()
          Blocks until an interrupt is received.
 Action block(int timeoutMilli)
          Block for "timeoutMilli" milliseconds.
 Action cancel()
          Cancels the current action (unsupported).
 byte getActionState()
          Returns the current action state.
 int getPort()
          Returns the currently set port.
 long getTimestamp()
          Returns the message timestamp.
 boolean isDone()
          Checks if the current action state is Action.DONE.
 void send(byte[] buf, int offset, int length)
          Transmits length bytes from a byte array, starting at offset.
 void send(ByteBuffer buf)
          Transmits a ByteBuffer.
 void setAddress(Addressable addr)
          Sets the destination address.
 ByteMessage setPort(int port)
          Sets the port for message transmissions.
 ByteSender setSend(byte[] buf, int offset, int length)
          Set the byte array containing the data to transmit.
 ByteSender setSend(ByteBuffer buf)
          Set the ByteBuffer containing data to be transmitted.
 Action submit()
          Submits this for processing, returns true if succeeded.
 
Methods inherited from class com.sentilla.platform.cmote.Sender
send, setDone, setSend, subsubmit
 
Methods inherited from class com.sentilla.platform.cmote.DispatcherAction
subcancel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteSender

public ByteSender(int port)
Method Detail

send

public void send(ByteBuffer buf)
Description copied from interface: ByteSender
Transmits a ByteBuffer.

Specified by:
send in interface ByteSender
Parameters:
buf - the ByteBuffer to send

send

public void send(byte[] buf,
                 int offset,
                 int length)
Description copied from interface: ByteSender
Transmits length bytes from a byte array, starting at offset.

Specified by:
send in interface ByteSender
Parameters:
buf - the byte array containing the data to transmit
offset - the offset of the data in the byte array
length - the length in bytes of the data to transmit

setSend

public ByteSender setSend(ByteBuffer buf)
Description copied from interface: ByteSender
Set the ByteBuffer containing data to be transmitted.

Specified by:
setSend in interface ByteSender
Parameters:
buf - the ByteBuffer containing the data to be transmitted
Returns:
this

setSend

public ByteSender setSend(byte[] buf,
                          int offset,
                          int length)
Description copied from interface: ByteSender
Set the byte array containing the data to transmit.

Specified by:
setSend in interface ByteSender
Parameters:
buf - byte array containing the data to transmit
offset - the offset of the data in the array
length - the length in bytes of data to transmit
Returns:
this

getPort

public int getPort()
Description copied from interface: ByteMessage
Returns the currently set port.

Specified by:
getPort in interface ByteMessage
Returns:
the integer port number

getTimestamp

public long getTimestamp()
Description copied from interface: ByteMessage
Returns the message timestamp.

Specified by:
getTimestamp in interface ByteMessage
Returns:
the long value timestamp

setPort

public ByteMessage setPort(int port)
Description copied from interface: ByteMessage
Sets the port for message transmissions.

Specified by:
setPort in interface ByteMessage
Parameters:
port - the port bytes should be sent to
Returns:
returns this

block

public Action block()
             throws ActionException
Description copied from class: DispatcherAction
Blocks until an interrupt is received.

Specified by:
block in interface Action
Overrides:
block in class DispatcherAction
Returns:
the DispatcherAction object
Throws:
ActionException
See Also:
Action

block

public Action block(int timeoutMilli)
             throws ActionException
Description copied from class: DispatcherAction
Block for "timeoutMilli" milliseconds. Similar to Thread.wait(int), causes the action to wait until either "timeoutMilli" milliseconds has elapsed, or an interrupt is received.

Specified by:
block in interface Action
Overrides:
block in class DispatcherAction
Parameters:
timeoutMilli - number of milliseconds to block
Returns:
the DispatcherAction object
Throws:
ActionException
See Also:
Action

cancel

public Action cancel()
Description copied from class: DispatcherAction
Cancels the current action (unsupported). Currently this is unsupported for any PENDING action. Required by Action interface.

Specified by:
cancel in interface Action
Overrides:
cancel in class DispatcherAction
Returns:
the DispatcherAction object
See Also:
Action

getActionState

public byte getActionState()
Description copied from class: DispatcherAction
Returns the current action state.

Specified by:
getActionState in interface Action
Overrides:
getActionState in class DispatcherAction
Returns:
the current Action state.
See Also:
Action

isDone

public boolean isDone()
               throws ActionException
Description copied from class: DispatcherAction
Checks if the current action state is Action.DONE. Returns true if the action is done.

Specified by:
isDone in interface Action
Overrides:
isDone in class DispatcherAction
Returns:
boolean value of true or false, true=pending, false=error
Throws:
ActionException
See Also:
Action

submit

public Action submit()
Description copied from class: DispatcherAction
Submits this for processing, returns true if succeeded. Used by the Sender and Receiver to implement the system Action interface. Classes deriving from DispatcherAction must implement the subsubmit() method.

Specified by:
submit in interface Action
Overrides:
submit in class DispatcherAction
Returns:
the DispatcherAction object.
See Also:
Action

setAddress

public void setAddress(Addressable addr)
Description copied from class: Sender
Sets the destination address. Any valid object implementing the Addressable interface can be set as the destination address. The protocols extending this class should throw an error if the address object is not supported.

Specified by:
setAddress in interface Sender
Specified by:
setAddress in class Sender
Parameters:
addr - object implementing Addressable interface to be used as address
See Also:
Addressable


Copyright © 2007 Sentilla Corporation. All Rights Reserved.