static public void saveBlock(int id, xDataInput data, xDataOutput o) { if (data == null) { return; } int blockSize = 4 + data.size(); if (blockSize + o.size() < DATA_MAX) { o.writeInt(blockSize); o.writeInt(id); o.write(data.getBytes(), 0, data.size()); } }
void loadData() { xDataInput di = xFileManager.readFile(Context.FILE_STORE_NAME, false); if (di != null) { clearMemory(); mBufferSize = di.available(); int ver = di.readInt(); if (ver == Context.FILE_VERSION) { mHeaderSize = di.readInt(); mDataOffset = di.readInt(); mShareCnt = di.readInt(); mBuffer = di.getBytes(); } } }
/* * public void setRefPrice(xDataInput di) { * if (true) // invalid method and not used anymore * return; * int floor = di.readInt(); * int cnt = di.readInt(); * if (cnt < 0) { * return; * } * if (cnt > 5000) { * return; * } * * if (floor < 1 || floor > 2) { * return; * } * * stPriceboardState.alloc_buffer(floor, cnt); * * mHasRefvalue = true; * int j = 0; * //==================================================================== * byte[] data = di.getBytes(); * int off = di.getCurrentOffset(); * * for (int i = 0; i < cnt; i++) { * j = 0; * stPriceboardState p = stPriceboardState.seekPriceboard(floor, data, off); * // code * p.setRef(data, off); * off += 8 + 3 * 4; * } * } * */ /* * public void setZeroPriceboard(xDataInput di) * { * String nextfile = di.readUTF(); * //nextfile = "0"; // CHEAT * * String date = di.readUTF(); * mDate = parseDate(date); * * int floor = di.readInt(); * int max = 10; * if (floor < 1 || floor > max) * { * return; * } * * mNextfile[floor - 1] = nextfile; * * //=====================index=================== * stPriceboardStateIndex index = getPriceboardIndexOfMarket(floor); * int oldStatus = index.market_status; * index.current_point = di.readInt()/100.0f; * index.changed_point = di.readInt()/100.0f; * index.changed_percent = di.readInt(); * index.total_volume = di.readInt(); * index.inc_cnt = di.readInt(); * index.ce_cnt = di.readInt(); * index.dec_cnt = di.readInt(); * index.floor_cnt = di.readInt(); * index.ref_num = di.readInt(); * index.totalGTGD = di.readInt() / 10; // dv 1tr * index.market_status = di.readInt(); * index.update_time = date; * index.reference = index.current_point - index.changed_point; * * index.status_changed = oldStatus != index.market_status ? true : false; * //=====================end of index=================== * * int cnt = di.readInt(); * if (cnt < 0 || cnt > 5000) * { * return; * } * * byte[] data = di.getBytes(); * * int j = 0; * for (int i = 0; i < cnt; i++) * { * stPriceboardState p = getPriceboard(floor, data, di.getCurrentOffset()); * * //Utils.trace("=====" + c0 + c1 + c2); * * if (p == null) * { * di.skip(Share.SHARE_CODE_LENGTH + 54); * continue; * } * di.skip(Share.SHARE_CODE_LENGTH); * * p.setZero(di); * } * } */ public void setZeroPriceboard2016(xDataInput di) { String nextfile = di.readUTF(); //nextfile = "0"; // CHEAT String date = di.readUTF(); mDate = parseDate(date); int floor = di.readInt(); int max = 10; if (floor < 1 || floor > max) { return; } mNextfile[floor - 1] = nextfile; //=====================index=================== stPriceboardStateIndex index = getPriceboardIndexOfMarket(floor); int oldStatus = index.market_status; index.current_point = di.readInt() / 100.0f; index.changed_point = di.readInt() / 100.0f; index.changed_percent = di.readInt(); index.total_volume = di.readInt(); index.inc_cnt = di.readInt(); index.ce_cnt = di.readInt(); index.dec_cnt = di.readInt(); index.floor_cnt = di.readInt(); index.ref_num = di.readInt(); index.totalGTGD = di.readInt() / 10; // dv 1tr index.market_status = di.readInt(); index.update_time = date; index.reference = index.current_point - index.changed_point; index.status_changed = oldStatus != index.market_status ? true : false; //=====================end of index=================== int cnt = di.readInt(); if (cnt < 0 || cnt > 5000) { return; } byte[] data = di.getBytes(); int j = 0; for (int i = 0; i < cnt; i++) { //stPriceboardState p = getPriceboard(floor, data, di.getCurrentOffset()); String scode = Utils.bytesNullTerminatedToString(data, di.getCurrentOffset(), 20); stPriceboardState p = getPriceboard(scode); if (p == null) { di.skip(Share.SHARE_CODE_LENGTH + 72); continue; } p.code = scode; //Utils.trace("=====" + c0 + c1 + c2); di.skip(Share.SHARE_CODE_LENGTH); p.setZero(di); } }