Package org.kendar.sync.lib.protocol
Class FileDataMessage
java.lang.Object
org.kendar.sync.lib.protocol.Message
org.kendar.sync.lib.protocol.FileDataMessage
Message containing a chunk of file data.
-
Constructor Summary
ConstructorsConstructorDescriptionFileDataMessage(String relativePath, int blockNumber, int totalBlocks, byte[] data) Creates a new file data message. -
Method Summary
Modifier and TypeMethodDescriptionprotected Messagedeserialize(ByteContainer buffer) intbyte[]getData()Gets the message type for this message.intbooleanChecks if this is the first block of the file.booleanChecks if this is the last block of the file.protected voidserialize(ByteContainer buffer) voidsetBlockNumber(int blockNumber) voidsetData(byte[] data) voidsetRelativePath(String relativePath) voidsetTotalBlocks(int totalBlocks) Methods inherited from class org.kendar.sync.lib.protocol.Message
deserialize, deserialize, getConnectionId, getPacketId, getSessionId, initialize, serialize
-
Constructor Details
-
FileDataMessage
public FileDataMessage() -
FileDataMessage
Creates a new file data message.- Parameters:
relativePath- The relative path of the fileblockNumber- The block number (0-based)totalBlocks- The total number of blocksdata- The file data
-
-
Method Details
-
getMessageType
Description copied from class:MessageGets the message type for this message.- Specified by:
getMessageTypein classMessage- Returns:
- The message type
-
deserialize
- Specified by:
deserializein classMessage
-
serialize
-
getRelativePath
-
setRelativePath
-
getBlockNumber
public int getBlockNumber() -
setBlockNumber
public void setBlockNumber(int blockNumber) -
getTotalBlocks
public int getTotalBlocks() -
setTotalBlocks
public void setTotalBlocks(int totalBlocks) -
getData
public byte[] getData() -
setData
public void setData(byte[] data) -
isFirstBlock
public boolean isFirstBlock()Checks if this is the first block of the file.- Returns:
- True if this is the first block, false otherwise
-
isLastBlock
public boolean isLastBlock()Checks if this is the last block of the file.- Returns:
- True if this is the last block, false otherwise
-