org.jboss.system.server.profileservice.repository.clustered.sync
Class ByteChunk

java.lang.Object
  extended by org.jboss.system.server.profileservice.repository.clustered.sync.ByteChunk
All Implemented Interfaces:
Serializable

public class ByteChunk
extends Object
implements Serializable

Encapsulates the results of an IO read operation for transmission across the cluster.

Version:
$Revision: $
Author:
Brian Stansberry
See Also:
Serialized Form

Constructor Summary
ByteChunk(byte[] bytes, int byteCount)
          Create a new ByteChunk.
 
Method Summary
 int getByteCount()
          Gets the number of valid bytes.
 byte[] getBytes()
          The bytes contained by this chunk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteChunk

public ByteChunk(byte[] bytes,
                 int byteCount)
Create a new ByteChunk.

Parameters:
bytes - source bytes. Note that this array will not necessarily be defensively copied, so callers should not alter it after passing it to this object.
byteCount - number of bytes in bytes that are valid; rest are filler. -1 indicates end of stream.
Method Detail

getByteCount

public int getByteCount()
Gets the number of valid bytes.

Returns:
the number of valid bytes, or -1 to indicate end of stream

getBytes

public byte[] getBytes()
The bytes contained by this chunk. The length of the array could be longer than getByteCount() in which case the excess bytes are filler.

Returns:
the bytes, or null if getByteCount() would return -1. Not that this may be a direct reference to this object's internal byte buffer, so callers should not alter the byte array.


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.