HashMap<Integer, Storage> caches= new HashMap();
HashMap<Integer, ArrayList<BiffRec>> pivotCacheRecs= new HashMap();
// HashMap<String, ArrayList> caches= new HashMap();
public void init(StorageTable directories, WorkBookHandle wbh) throws StorageNotFoundException {
Storage child= directories.getChild("_SX_DB_CUR");
if (wbh!=null) {
caches= new HashMap();
book= wbh.getWorkBook();
if (wbh.getDebugLevel() > 25) { // KSC: TESTING: make > 25
Logger.logInfo("PivotCache.init");
}
}
while (child!=null) {
if (wbh!=null)
caches.put(Integer.valueOf(child.getName()), child);
ArrayList<BiffRec> curRecs= new ArrayList();
BlockByteReader bytes= child.getBlockReader();
int len= bytes.getLength();
for (int i = 0; i <= len - 4;) {
byte[] headerbytes = bytes.getHeaderBytes(i);
short opcode = ByteTools.readShort(headerbytes[0], headerbytes[1]);
int reclen = ByteTools.readShort(headerbytes[2], headerbytes[3]);
BiffRec rec = XLSRecordFactory.getBiffRecord( opcode );
if (wbh!=null) rec.setDebugLevel(wbh.getDebugLevel()); // KSC: added to propogate debug level
// init the mighty rec
rec.setWorkBook(book);
rec.setByteReader(bytes);
rec.setLength((short) reclen);
rec.setOffset(i);
rec.init();
/*
// KSC: TESTING
try {
System.out.println(rec.getClass().getName().substring(rec.getClass().getName().lastIndexOf(".")+1) + ": " + Arrays.toString(((PivotCacheRecord)rec).getRecord()));
} catch (ClassCastException e) {
System.out.println(rec.getClass().getName().substring(rec.getClass().getName().lastIndexOf(".")+1) + ": " + Arrays.toString(ByteTools.shortToLEBytes(rec.getOpcode())) + Arrays.toString(ByteTools.shortToLEBytes((short)rec.getData().length)) + Arrays.toString(rec.getData()));
}
*/
if (wbh!=null)
curRecs.add(rec);
i+=reclen+4;
}
if (wbh!=null)
pivotCacheRecs.put(Integer.valueOf(child.getName()), curRecs);
child= directories.getNext(child.getName());
}
// KSC: TESTING
// Logger.logInfo("PivotCache.end init");
}