1 package attrib4j.cfparse;
2
3 import java.io.ByteArrayInputStream;
4 import java.io.DataInputStream;
5 import java.io.DataOutputStream;
6 import java.io.IOException;
7 import java.io.ObjectInputStream;
8
9 import com.ibm.toad.cfparse.ConstantPool;
10 import com.ibm.toad.cfparse.attributes.AttrInfo;
11
12 public class CFCustomAttrInfo extends AttrInfo {
13 private byte[] data;
14
15 public CFCustomAttrInfo(ConstantPool cp, int idxName, int depth) {
16 super(cp, idxName, depth);
17 }
18
19 public void setSerializedData(byte[] serData) {
20 data = serData;
21 }
22 public byte[] getSerializedData() {
23 return data;
24 }
25
26 public void read(DataInputStream in) throws IOException {
27 int length = in.readInt();
28 data = new byte[length];
29 in.read(data);
30 }
31
32 public void write(DataOutputStream out) throws IOException {
33 out.writeShort(d_idxName);
34
35 if (data != null) {
36 out.writeInt(data.length);
37 out.write(data, 0, data.length);
38 } else {
39 out.writeInt(0);
40 }
41 }
42
43 public String toString() {
44 try {
45 return new ObjectInputStream(new ByteArrayInputStream(data))
46 .readObject()
47 .toString();
48 } catch (Exception x) {
49 x.printStackTrace();
50 return x.toString();
51 }
52 }
53 }
This page was automatically generated by Maven