-
Notifications
You must be signed in to change notification settings - Fork 1
/
CompleteBuildS1_src_Records_RecordC.java
47 lines (39 loc) · 1.26 KB
/
CompleteBuildS1_src_Records_RecordC.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
package Records;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
/*
Last Edited by Cameron Kane 5/2/18
*/
/*
This class add cloning capabilities to the Record Object
********DO NOT ALTER WITHOUT TALKING TO CAMERON***********
*/
@SuppressWarnings("serial")
public class RecordC implements Cloneable, Serializable {//Implentation of cloning capabilities
public Record rec = new Record();
public RecordC clone() {
try {
return (RecordC) super.clone();
} catch (CloneNotSupportedException e) {
return null;
}
}
public RecordC deepClone() {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(this);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
return (RecordC) ois.readObject();
} catch (IOException e) {
return null;
} catch (ClassNotFoundException e) {
return null;
}
}
}