bees.core
Class DataAggregator
java.lang.Object
|
+--bees.core.DataAggregator
- public final class DataAggregator
- extends java.lang.Object
A DataAggregator is used to collect and redistribute byte arrays.
- See Also:
DataRequestCapsule
,
DataResponseCapsule
,
ReliableDataRequestCapsule
Constructor Summary |
DataAggregator(byte[] bytes)
Construct a DataAggregator with the given byte array. |
DataAggregator(int length)
Construct a DataAggregator that will receive a byte array of the given
length. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
DataAggregator
public DataAggregator(byte[] bytes)
- Construct a DataAggregator with the given byte array.
- Parameters:
bytes
- The initial byte array.
DataAggregator
public DataAggregator(int length)
- Construct a DataAggregator that will receive a byte array of the given
length.
- Parameters:
length
- The expected length of the byte array.
getBytes
public byte[] getBytes()
- Returns:
- The byte array used to collect data.
getLength
public int getLength()
- Returns:
- The expected length of the byte array.
setCurrentWindow
public void setCurrentWindow(int cw)
- Parameters:
cw
- The current window into the byte array.
getCurrentWindow
public int getCurrentWindow()
- Returns:
- The current window into the byte array.
setWindowChunks
public void setWindowChunks(long windowChunks)
- Parameters:
windowChunks
- The state of the current window.
getWindowChunks
public long getWindowChunks()
- Returns:
- The state of the current window.
fromWindow
public boolean fromWindow(byte[] buffer,
int fromWindow,
long fromChunks)
- Fill in the enclosed byte array with the contents of the given window.
- Parameters:
buffer
- The buffer holding the window data.fromWindow
- The window where the data was collected from.fromChunks
- The set of chunks the data in "buffer" represents.- Returns:
- True if byte array is now complete.
isComplete
public boolean isComplete()
- Returns:
- True if the byte array is now completed.
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
- See Also:
Object.toString()
limitWindow
public static long limitWindow(long windowChunks,
int windowLength,
int maxSize)
- Limit the byte size of a set of chunks.
- Parameters:
windowChunks
- The desired set of chunks to be transmitted.windowLength
- ...maxSize
- The maximum number of bytes that can be transmitted.- Returns:
- The subset of "windowChunks" that doesn't violate the maximum
size value.
fillWindow
public static byte[] fillWindow(byte[] bytes,
int currentWindow,
long windowChunks)
- Produce a byte array that holds the bytes selected by the given values.
- Parameters:
bytes
- The source bytes.currentWindow
- The window within "bytes" from which data is to
be pulled.windowChunks
- The set of chunks to be placed in the returned
array.- Returns:
- A new byte array containing the selected chunks from "bytes".
This documentation is Copyright (C) 2002 The University of Utah. All Rights Reserved. See the individual source files for distribution terms.
Documentation, software, and mailing lists for Bees v0.5.0 can be found at the Janos Project: http://www.cs.utah.edu/flux/janos/