SunSPOT API V3.0


com.sun.spot.io.j2me.radiostream
Class RadioOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.sun.spot.io.j2me.radiostream.RadioOutputStream
All Implemented Interfaces:
IRadioControl

public class RadioOutputStream
extends OutputStream
implements IRadioControl

Helper class for "radiostream:" connections. This class provides an OutputStream to stream data to another Spot. You should NOT normally instantiate this class directly, but rather via the GCF framework: see the first reference below for more details.

See Also:
RadiostreamConnection

Constructor Summary
RadioOutputStream(IRadiostreamProtocolManager dispatcher, ConnectionID cid, RadioPolicy initialPolicy, IRadioPolicyManager radioPolicyManager)
          Construct a RadioOutputStream
 
Method Summary
 void close()
          Closes this output stream and releases any system resources associated with this stream.
 void flush()
          Flushes this output stream and forces any buffered output bytes to be written out.
 int getFlushThreshold()
          Get the flush threshold for this stream.
 byte getLocalPort()
          Answer the port number for this connection
 void setFlushThreshold(int ft)
          Set the flush threshold for this stream.
 void setRadioPolicy(RadioPolicy selection)
          Set the radio policy for this connection
 void write(int arg0)
          Writes the specified byte to this output stream.
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RadioOutputStream

public RadioOutputStream(IRadiostreamProtocolManager dispatcher,
                         ConnectionID cid,
                         RadioPolicy initialPolicy,
                         IRadioPolicyManager radioPolicyManager)
Construct a RadioOutputStream

Parameters:
dispatcher - the PortBasedProtocolManager that will dispatch packets
cid - the ConnectionID object to be used
radioPolicyManager -
initialPolicy -
Method Detail

write

public void write(int arg0)
           throws NoAckException,
                  ChannelBusyException,
                  NoRouteException,
                  NoMeshLayerAckException
Description copied from class: OutputStream
Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Subclasses of OutputStream must provide an implementation for this method.

Specified by:
write in class OutputStream
Parameters:
arg0 - the byte.
Throws:
NoAckException
ChannelBusyException
NoRouteException
NoMeshLayerAckException

flush

public void flush()
           throws NoAckException,
                  ChannelBusyException,
                  NoRouteException,
                  NoMeshLayerAckException
Description copied from class: OutputStream
Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

The flush method of OutputStream does nothing.

Overrides:
flush in class OutputStream
Throws:
NoAckException
ChannelBusyException
NoRouteException
NoMeshLayerAckException

close

public void close()
           throws IOException
Description copied from class: OutputStream
Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

The close method of OutputStream does nothing.

Overrides:
close in class OutputStream
Throws:
IOException - if an I/O error occurs.

getFlushThreshold

public int getFlushThreshold()
Get the flush threshold for this stream. Data written to the stream is only sent to the remote Spot when the flush threshold is reached, or when the current radio packet is full.

Returns:
number of bytes written to receiver before a radio packet is sent to the remote spot.

setFlushThreshold

public void setFlushThreshold(int ft)
Set the flush threshold for this stream. Data written to the stream is only sent to the remote Spot when the flush threshold is reached. This method should only be called before writing any data to the stream.

Parameters:
ft - - number of bytes to write to receiver before a radio packet is sent to the remote spot - should be in the range 1 to (RadioPacket.getMaxMacPayloadSize() - IRadiostreamProtocolManager.DATA_OFFSET)

setRadioPolicy

public void setRadioPolicy(RadioPolicy selection)
Description copied from interface: IRadioControl
Set the radio policy for this connection

Specified by:
setRadioPolicy in interface IRadioControl
Parameters:
selection - the policy required

getLocalPort

public byte getLocalPort()
Description copied from interface: IRadioControl
Answer the port number for this connection

Specified by:
getLocalPort in interface IRadioControl
Returns:
the port number

SunSPOT API V3.0


Copyright © 2006, 2007 Sun Microsystems, Inc. All Rights Reserved.