/** * Creates and returns a continue record using the left over bits and * pieces */ private SSTContinueRecord createContinueRecord (string curString, int charsLeft, File outputFile) { // Set up the remainder of the string in the continue record SSTContinueRecord cont = null; while (charsLeft != 0) { cont = new SSTContinueRecord(); if (charsLeft == curString.Length || curString.Length == 0) { charsLeft = cont.setFirstString(curString, true); } else { charsLeft = cont.setFirstString (curString.Substring(curString.Length - charsLeft), false); } if (charsLeft != 0) { outputFile.write(cont); cont = new SSTContinueRecord(); } } return(cont); }
/** * Writes out the shared string table * * @param outputFile the binary output file * @exception IOException */ public void write(File outputFile) { // Thanks to Guenther for contributing the ExtSST implementation portion // of this method int charsLeft = 0; string curString = null; SSTRecord sst = new SSTRecord(totalOccurrences, stringList.Count); ExtendedSSTRecord extsst = new ExtendedSSTRecord(stringList.Count); int bucketSize = extsst.getNumberOfStringsPerBucket(); int stringIndex = 0; // CML: this one is nasty.... IEnumerator iterator = stringList.GetEnumerator(); while (iterator.MoveNext() && charsLeft == 0) { curString = (string)iterator.Current; // offset + header bytes int relativePosition = sst.getOffset() + 4; charsLeft = sst.add(curString); if ((stringIndex % bucketSize) == 0) { extsst.addString(outputFile.getPos(), relativePosition); } stringIndex++; } outputFile.write(sst); if (charsLeft != 0 || iterator.MoveNext()) { // Add the remainder of the string to the continue record SSTContinueRecord cont = createContinueRecord(curString, charsLeft, outputFile); // Carry on looping through the array until all the strings are done do { curString = (string)iterator.Current; int relativePosition = cont.getOffset() + 4; charsLeft = cont.add(curString); if ((stringIndex % bucketSize) == 0) { extsst.addString(outputFile.getPos(), relativePosition); } stringIndex++; if (charsLeft != 0) { outputFile.write(cont); cont = createContinueRecord(curString, charsLeft, outputFile); } }while (iterator.MoveNext()); outputFile.write(cont); } outputFile.write(extsst); }
/** * Creates and returns a continue record using the left over bits and * pieces */ private SSTContinueRecord createContinueRecord(string curString, int charsLeft, File outputFile) { // Set up the remainder of the string in the continue record SSTContinueRecord cont = null; while (charsLeft != 0) { cont = new SSTContinueRecord(); if (charsLeft == curString.Length || curString.Length == 0) { charsLeft = cont.setFirstString(curString, true); } else { charsLeft = cont.setFirstString (curString.Substring(curString.Length - charsLeft), false); } if (charsLeft != 0) { outputFile.write(cont); cont = new SSTContinueRecord(); } } return cont; }