85 if (idSize == 4) {
86 return ((long)buf.getInt(offset)) & Snapshot.SMALL_ID_MASK;
87 } else {
88 return buf.getLong(offset);
89 }
90 } catch (IOException exp) {
91 System.err.println("lazy read failed at offset " + offset);
92 exp.printStackTrace();
93 return -1;
94 }
95 }
96
97 protected abstract int readValueLength() throws IOException;
98 protected abstract byte[] readValue() throws IOException;
99
100 // make Integer or Long for given object ID
101 protected static Number makeId(long id) {
102 if ((id & ~Snapshot.SMALL_ID_MASK) == 0) {
103 return new Integer((int)id);
104 } else {
105 return new Long(id);
106 }
107 }
108
109 // get ID as long value from Number
110 protected static long getIdValue(Number num) {
111 long id = num.longValue();
112 if (num instanceof Integer) {
113 id &= Snapshot.SMALL_ID_MASK;
114 }
115 return id;
116 }
117
118 // read object ID from given index from given byte array
119 protected final long objectIdAt(int index, byte[] data) {
120 int idSize = getClazz().getIdentifierSize();
121 if (idSize == 4) {
122 return ((long)intAt(index, data)) & Snapshot.SMALL_ID_MASK;
123 } else {
124 return longAt(index, data);
125 }
|
85 if (idSize == 4) {
86 return ((long)buf.getInt(offset)) & Snapshot.SMALL_ID_MASK;
87 } else {
88 return buf.getLong(offset);
89 }
90 } catch (IOException exp) {
91 System.err.println("lazy read failed at offset " + offset);
92 exp.printStackTrace();
93 return -1;
94 }
95 }
96
97 protected abstract int readValueLength() throws IOException;
98 protected abstract byte[] readValue() throws IOException;
99
100 // make Integer or Long for given object ID
101 protected static Number makeId(long id) {
102 if ((id & ~Snapshot.SMALL_ID_MASK) == 0) {
103 return new Integer((int)id);
104 } else {
105 return id;
106 }
107 }
108
109 // get ID as long value from Number
110 protected static long getIdValue(Number num) {
111 long id = num.longValue();
112 if (num instanceof Integer) {
113 id &= Snapshot.SMALL_ID_MASK;
114 }
115 return id;
116 }
117
118 // read object ID from given index from given byte array
119 protected final long objectIdAt(int index, byte[] data) {
120 int idSize = getClazz().getIdentifierSize();
121 if (idSize == 4) {
122 return ((long)intAt(index, data)) & Snapshot.SMALL_ID_MASK;
123 } else {
124 return longAt(index, data);
125 }
|