/** place object details in queue */ void storeObjectOffset( final int current_number, final int current_offset, final int current_generation, final boolean isEntryCompressed, final boolean isBumData) { /** check it does not already exist */ int existing_generation = 0; int offsetNumber = 0; if (current_number < generation.getCapacity()) { existing_generation = generation.elementAt(current_number); offsetNumber = this.elementAt(current_number); } // write out if not a newer copy (ignore items from Prev tables if newer) // if bum data accept if higher position a swe are trawling file manually anf higher figure // probably newer if (existing_generation < current_generation || offsetNumber == 0 || isBumData && (current_offset > this.elementAt(current_number))) { this.setElementAt(current_offset, current_number); generation.setElementAt(current_generation, current_number); isCompressed.setElementAt(isEntryCompressed, current_number); } else { // LogWriter.writeLog("Object "+current_number + ", generation "+ // current_generation + " already exists as"+ // existing_generation); } }
/** precalculate sizes for each object */ public int[] calculateObjectLength(final int eof) { if (refTableInvalid) { return null; } // add eol to refs as catchall xref.addElement(eof); final int[] xrefs = xref.get(); // get order list of refs final int xrefCount = xrefs.length; int[] xrefID = new int[xrefCount]; for (int i = 0; i < xrefCount; i++) { xrefID[i] = i; } xrefID = Sorts.quicksort(xrefs, xrefID); // get ordered list of objects in offset order final int objectCount = this.getCapacity(); int[] id = new int[objectCount]; final int[] offsets = new int[objectCount]; // read from local copies and pop lookup table final int[] off = this.get(); final boolean[] isComp = isCompressed.get(); for (int i = 0; i < objectCount; i++) { if (!isComp[i]) { offsets[i] = off[i]; id[i] = i; } } id = Sorts.quicksort(offsets, id); int i = 0; // ignore empty values while (true) { if (offsets[id[i]] != 0) { break; } i++; } /** loop to calc all object lengths */ int start = offsets[id[i]], end; // find next xref int j = 0; while (xrefs[xrefID[j]] < start + 1) { j++; } final int[] ObjLengthTable = new int[objectCount]; while (i < objectCount - 1) { end = offsets[id[i + 1]]; int objLength = end - start - 1; // adjust for any xref if (xrefs[xrefID[j]] < end) { objLength = xrefs[xrefID[j]] - start - 1; while (xrefs[xrefID[j]] < end + 1) { j++; } } ObjLengthTable[id[i]] = objLength; // System.out.println(id[i]+" "+objLength+" "+start+" "+end); start = end; while (xrefs[xrefID[j]] < start + 1) { j++; } i++; } // special case - last object ObjLengthTable[id[i]] = xrefs[xrefID[j]] - start - 1; // System.out.println("*"+id[i]+" "+start+" "+xref+" "+eof); return ObjLengthTable; }
/** general routine to turn reference into id with object name */ public final boolean isCompressed(final int ref) { return isCompressed.elementAt(ref); }