gov.nasa.gsfc.drl.rtstps.clients.spooler
Class Block

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.clients.spooler.Block

final class Block
extends java.lang.Object

This class contains a block of data. It's the way SocketReader sends data to SocketWriter.


Field Summary
private static int blockSize
           
private  byte[] data
           
private  boolean empty
           
private  int length
           
private  boolean toggle
           
 
Constructor Summary
Block()
          Construct a block of the specified block size.
 
Method Summary
(package private) static int getBlockSize()
          Get the block size in bytes.
(package private)  byte[] getData()
          Get the data within this block.
(package private)  boolean isEmpty()
          Is this block empty?
(package private)  boolean isToggled()
          Is the toggle flag on or off?
(package private)  void markUsed(boolean toggle, int length)
          Mark this block as used.
(package private) static void setBlockSize(int size)
          Set the block size.
(package private)  void setEmpty(boolean e)
          Mark this block as empty.
(package private)  boolean write(java.io.OutputStream os)
          Write this block's data to the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

blockSize

private static int blockSize

data

private byte[] data

length

private int length

empty

private boolean empty

toggle

private boolean toggle
Constructor Detail

Block

Block()
Construct a block of the specified block size.

Method Detail

getBlockSize

static int getBlockSize()
Get the block size in bytes.


setBlockSize

static void setBlockSize(int size)
Set the block size. Use this once only before configuration.


getData

final byte[] getData()
Get the data within this block.


setEmpty

final void setEmpty(boolean e)
Mark this block as empty.


isEmpty

final boolean isEmpty()
Is this block empty?


markUsed

void markUsed(boolean toggle,
              int length)
Mark this block as used.

Parameters:
toggle - Set the toggle flag, which has special meaning. SocketReader uses it to tell SocketWriter to switch to either the pipe or the file spool to get its next block.
length - The true block length, which may be shorter than the maximum block length.

isToggled

final boolean isToggled()
Is the toggle flag on or off?


write

boolean write(java.io.OutputStream os)
Write this block's data to the output stream.

Returns:
true if successful and false otherwise.