root / Chunk.java @ 1
History | View | Annotate | Download (1.36 KB)
1 |
/**
|
---|---|
2 |
* Chunk
|
3 |
*/
|
4 |
public class Chunk { |
5 |
private BackupFile file;
|
6 |
private int chunkNo; |
7 |
private int size; |
8 |
private byte[] data; |
9 |
private boolean recentlyRequested; |
10 |
|
11 |
public Chunk(BackupFile file, int chunkNo) { |
12 |
this.file = file;
|
13 |
this.chunkNo = chunkNo;
|
14 |
|
15 |
this.size = 0; |
16 |
this.recentlyRequested = false; |
17 |
} |
18 |
|
19 |
public Chunk(BackupFile file, int chunkNo, byte[] data) { |
20 |
this.file = file;
|
21 |
this.chunkNo = chunkNo;
|
22 |
this.data = data;
|
23 |
|
24 |
this.size = this.data.length; |
25 |
this.recentlyRequested = false; |
26 |
} |
27 |
|
28 |
public boolean getRecentlyRequested() { |
29 |
return this.recentlyRequested; |
30 |
} |
31 |
|
32 |
public void setRecentlyRequested() { |
33 |
this.recentlyRequested = true; |
34 |
} |
35 |
|
36 |
/**
|
37 |
* @return the data
|
38 |
*/
|
39 |
public byte[] getData() { |
40 |
return data;
|
41 |
} |
42 |
|
43 |
/**
|
44 |
* @return the size
|
45 |
*/
|
46 |
public int getSize() { |
47 |
return size;
|
48 |
} |
49 |
|
50 |
/**
|
51 |
* @return the chunkNo
|
52 |
*/
|
53 |
public int getChunkNo() { |
54 |
return chunkNo;
|
55 |
} |
56 |
|
57 |
/**
|
58 |
* @return the file
|
59 |
*/
|
60 |
public BackupFile getFile() {
|
61 |
return file;
|
62 |
} |
63 |
|
64 |
public String getPath() { |
65 |
return this.getDir()+"\\"+this.chunkNo; |
66 |
} |
67 |
|
68 |
public String getDir() { |
69 |
return "Chunks\\"+this.file.getFileId(); |
70 |
} |
71 |
|
72 |
public void setData(byte[] body) { |
73 |
this.data = body;
|
74 |
} |
75 |
} |