gov.nasa.gsfc.drl.rtstps.core.fs
Class Buffer

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.core.fs.Buffer

final class Buffer
extends java.lang.Object

This class holds a byte array with a currency indicator that marks a bit and byte location within the buffer.


Field Summary
(package private)  byte[] data
           
private  int dataLength
           
(package private)  Location index
           
private  int remainingBytes
           
 
Constructor Summary
Buffer()
          Create an empty Buffer.
Buffer(int length)
          Create a buffer of the specified length.
 
Method Summary
(package private)  void advance(int bytes)
          Advance the current location.
(package private)  int append(Buffer buffer)
          Append another buffer to this one.
(package private)  void empty()
          Clear the buffer.
(package private)  int getLength()
          Get the buffer length.
(package private)  int getRemainingBytes()
          Get the number of bytes that are remaining.
 void setData(byte[] data, int length)
          Change the buffer's array and length.
(package private)  void setLocation(int byteOffset)
          Set the current buffer location to the byte offset.
(package private)  void setLocation(Location loc)
          Set the buffer's current location.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

byte[] data

index

Location index

dataLength

private int dataLength

remainingBytes

private int remainingBytes
Constructor Detail

Buffer

Buffer()
Create an empty Buffer. You must use setData() to initialize.


Buffer

Buffer(int length)
Create a buffer of the specified length.

Method Detail

setData

public void setData(byte[] data,
                    int length)
Change the buffer's array and length. The length must be less than or equal to data.length.


getLength

final int getLength()
Get the buffer length.


getRemainingBytes

final int getRemainingBytes()
Get the number of bytes that are remaining.


empty

final void empty()
Clear the buffer.


append

int append(Buffer buffer)
Append another buffer to this one. Beginning at the other buffer's start index, enough bytes are appended to fill this buffer completely. If the other buffer is too short, then this methods appends all of its bytes. The currency indices of both buffers are updated.

Returns:
the number of bytes copied

advance

final void advance(int bytes)
Advance the current location. The bit offset is unaffected.


setLocation

final void setLocation(Location loc)
Set the buffer's current location.

Parameters:
loc - A new location. loc is not saved; its contents are copied.

setLocation

final void setLocation(int byteOffset)
Set the current buffer location to the byte offset. The bit offset is unaffected.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object