cnrg.itx.datax.devices
Class StreamDestination

java.lang.Object
  |
  +--cnrg.itx.datax.devices.StreamDestination

public class StreamDestination
extends java.lang.Object
implements Destination

Class to define a stream of data. Any valid output stream can be represented by this class as a valid Destination object.


Field Summary
private  int bytesRead
          Attribute for storing the number of bytes written to the stream.
private  int iDevice
          Attribute for storing the device ID.
private static int instances
          Attribute for storing the device instance number.
private  java.io.OutputStream outStream
          Private attribute to store the output stream object
private  Stats streamStats
          Attribute for storing the stream destination statistics.
 
Constructor Summary
StreamDestination(java.io.OutputStream outStream)
          Constructor to create a stream destination.
 
Method Summary
 void close()
          Method to close the stream
 PropertiesCollection getProperties()
          Returns a collection of properties supported.
 Stats getStatistics()
          Method to get the statistics of the output stream.
 boolean mute(boolean mute)
          Method to mute the stream.
 void setPeerProperties(PropertiesCollection pc)
          Interface to set the given properties collection into the device.
 void setProperties(PropertiesCollection pc)
          Sets the given properties collection into the device
 void write(byte[] b)
          Method to write data to the stream.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

streamStats

private Stats streamStats
Attribute for storing the stream destination statistics.

outStream

private java.io.OutputStream outStream
Private attribute to store the output stream object

bytesRead

private int bytesRead
Attribute for storing the number of bytes written to the stream.

instances

private static int instances
Attribute for storing the device instance number. This is a static attribute and will be incremented in the constructor. This represents the total number of instances of the stream destinations.

iDevice

private int iDevice
Attribute for storing the device ID. This is the value of the instance at the moment.
Constructor Detail

StreamDestination

public StreamDestination(java.io.OutputStream outStream)
                  throws DataException
Constructor to create a stream destination.
Parameters:
OutputStream - The output stream for this destination
Throws:
DataException - This is thrown in case of IO errors
Method Detail

write

public void write(byte[] b)
           throws DataException
Method to write data to the stream.
Specified by:
write in interface Destination
Parameters:
b - The array of bytes to write to the stream
Throws:
DataException - This is thrown when an IO error occurs

close

public void close()
Method to close the stream
Specified by:
close in interface Destination

mute

public boolean mute(boolean mute)
Method to mute the stream. This method is a no op as there is nothing to mute in an output stream.
Specified by:
mute in interface Destination
Parameters:
mute - The mode of the mute
Returns:
boolean The mute state of the stream

getStatistics

public Stats getStatistics()
Method to get the statistics of the output stream.
Returns:
Stats The statistics of the output stream

getProperties

public PropertiesCollection getProperties()
                                   throws DataException
Returns a collection of properties supported.

setProperties

public void setProperties(PropertiesCollection pc)
                   throws DataException
Sets the given properties collection into the device

setPeerProperties

public void setPeerProperties(PropertiesCollection pc)
                       throws DataException
Interface to set the given properties collection into the device. WOrks under the assumption that this is the properties collection of the peer.