forked from msgpack/msgpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImage.java
More file actions
50 lines (43 loc) · 1.04 KB
/
Copy pathImage.java
File metadata and controls
50 lines (43 loc) · 1.04 KB
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
package org.msgpack;
import org.msgpack.*;
import java.io.*;
import java.util.*;
public class Image implements MessagePackable, MessageUnpackable {
public String uri = "";
public String title = "";
public int width = 0;
public int height = 0;
public int size = 0;
public void messagePack(Packer pk) throws IOException {
pk.packArray(5);
pk.pack(uri);
pk.pack(title);
pk.pack(width);
pk.pack(height);
pk.pack(size);
}
public void messageUnpack(Unpacker pac) throws IOException, MessageTypeException {
int length = pac.unpackArray();
if(length != 5) {
throw new MessageTypeException();
}
uri = pac.unpackString();
title = pac.unpackString();
width = pac.unpackInt();
height = pac.unpackInt();
size = pac.unpackInt();
}
public boolean equals(Image obj) {
return uri.equals(obj.uri) &&
title.equals(obj.title) &&
width == obj.width &&
height == obj.height &&
size == obj.size;
}
public boolean equals(Object obj) {
if(obj.getClass() != Image.class) {
return false;
}
return equals((Image)obj);
}
}