-
Notifications
You must be signed in to change notification settings - Fork 0
/
YacRequest.java
72 lines (61 loc) · 1.33 KB
/
YacRequest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* YacRequest:
* structured request from YacPac client to Yac server.
* Includes the operation, and if applicable, the data payload.
*
*/
import java.io.*;
public class YacRequest implements Serializable
{
private YacOp op;
private String filename;
private String owner;
private byte[] data;
private int size;
public YacRequest(YacOp op, String arg)
{
this.op = op;
this.filename = arg;
this.owner = YacPacOwner.OWNER;
this.size = 0;
this.data = null;
if (this.filename != null && this.op == YacOp.PUT)
{
try
{
File inFile = new File(this.filename);
FileInputStream fileInput = new FileInputStream(inFile);
int byteLength = (int) inFile.length();
this.size = byteLength;
data = new byte[byteLength];
fileInput.read(data,0,byteLength);
}
catch (Exception e)
{
System.err.println(e);
System.exit(1);
} // trycatch for reading in file data
}
} // Constructor
// just some getters
public YacOp getOp()
{
return this.op;
}
public String getOwner()
{
return this.owner;
}
public String getFileName()
{
return this.filename;
}
public byte[] getData()
{
return this.data;
}
public int getSize()
{
return this.size;
}
} // YacRequest