public class FilePart extends Payload
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
filename |
private static int |
FILENAME_POSITION |
private static int |
FILENAME_SIZE_POSITION |
private long |
offset |
private static int |
OFFSET_POSITION |
private byte[] |
partialContent |
PAYLOAD_SIZE_POSITION, PAYLOAD_START_POSITION, requestResponseCode
Modifier | Constructor and Description |
---|---|
protected |
FilePart(byte[] packet)
Constructor (typically used by client) with Packet received as parameter.
|
|
FilePart(java.lang.String filename,
long offset,
byte[] partialContent)
Constructor (typically used by server) with informations about file part to send as parameters.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getFilename()
filename getter.
|
private int |
getFilenameSize(byte[] packet)
Read filename’s size from Packet.
|
long |
getOffset()
offset getter.
|
byte[] |
getPartialContent()
partialContent getter.
|
private void |
setFilename(byte[] packet)
Write from Packet into filename.
|
private void |
setOffset(byte[] packet)
Write from Packet into offset.
|
private void |
setPartialContent(byte[] packet)
Write from Packet into partialContent.
|
protected byte[] |
toPacket()
Returns a byte[] containing Packet with padding.
|
getPayloadSize, getRequestResponseCode, setPayloadSize
private java.lang.String filename
private long offset
private byte[] partialContent
private static final int OFFSET_POSITION
private static final int FILENAME_SIZE_POSITION
private static final int FILENAME_POSITION
public FilePart(java.lang.String filename, long offset, byte[] partialContent) throws InternalError
filename
- name of the file to sendtotalSize
- total size of the file to sendoffset
- where in the file begins the part we are sendingpartialContent
- content of the file we sendInternalError
protected FilePart(byte[] packet) throws TransmissionError, SizeError, ProtocolError, InternalError
packet
- the full Packet receivedSizeError
InternalError
TransmissionError
ProtocolError
protected byte[] toPacket() throws InternalError
toPacket
in class Payload
InternalError
private void setOffset(byte[] packet) throws SizeError
packet
- received PacketSizeError
private int getFilenameSize(byte[] packet) throws SizeError, ProtocolError
packet
- received PacketProtocolError
SizeError
private void setFilename(byte[] packet) throws ProtocolError, SizeError, InternalError
packet
- received PacketProtocolError
SizeError
InternalError
private void setPartialContent(byte[] packet) throws ProtocolError, SizeError
packet
- received PacketSizeError
ProtocolError
public byte[] getPartialContent()
public java.lang.String getFilename()
public long getOffset()