ByteChunkpublic class ByteChunk extends Object implements SerializableA Class that represents a Chunk of Bytes. This is designed to be used
to transfer bytes of data between remote entities. There are some properties
of the class that will allow users of this class to take specific
actions. Maximum size of the chunk is 64 KBytes. Needs to be Serializable,
for ByteChunks may transmit over wire.
Chunks are generally parts of file identified by a name. Note that this
class is modeled to be immutable.
|
Fields Summary |
---|
public static final long | serialVersionUID | public static final int | kChunkMaxSize | public static final int | kChunkMinSize | private int | mSize | private boolean | mIsLast | private boolean | mIsFirst | private byte[] | mBytes | private String | mChunkedFileName | private String | mTargetDir | private String | mUniqueId | private long | mTotalFileSize |
Constructors Summary |
---|
public ByteChunk(byte[] byteArray, String forFileName, boolean isFirst, boolean isLast, String uniqueId, long totalFileSize)Creates new ByteChunk with the specified size. The chunk may not be
larger than the size specfied by kChunkMaxSize.
int size =0;
if (byteArray != null) {
size = byteArray.length;
if ( size < kChunkMinSize || size > kChunkMaxSize)
{
throw new IllegalArgumentException(size + "");
}
}
mSize = size;
mIsFirst = isFirst;
mIsLast = isLast;
mBytes = byteArray;
mChunkedFileName = forFileName;
mUniqueId = uniqueId;
mTotalFileSize = totalFileSize;
| public ByteChunk(byte[] byteArray, String forFileName, boolean isFirst, boolean isLast)Creates new ByteChunk with the specified size. The chunk may not be
larger than the size specfied by kChunkMaxSize.
this(byteArray,forFileName,isFirst,isLast,forFileName, -1);
|
Methods Summary |
---|
public byte[] | getBytes()Gets the array of actual bytes.
return mBytes;
| public java.lang.String | getChunkedFileName()Returns the name of the file that was chunked.
return ( mChunkedFileName );
| public java.lang.String | getId()Returns the unique id for this series of chunks.
return mUniqueId;
| public int | getSize()Gets the actual size of the chunk. The chunk will have exactly this many
bytes in the underlying byte array.
return ( mSize );
| public java.lang.String | getTargetDir()Returns the name of the target directory to which this chunk
is copied.
return ( mTargetDir );
| public long | getTotalFileSize()returns the total file size.
return mTotalFileSize;
| public boolean | isFirst()Determines whether this is the last Chunk in a series of Chunk transfer.
return ( mIsFirst );
| public boolean | isLast()Determines whether this is the last Chunk in a series of Chunk transfer.
return ( mIsLast );
| public void | setTargetDir(java.lang.String targetDir)Sets the target dir to which this chunk must be copied.
mTargetDir = targetDir;
|
|