poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r703596 [1/2] - in /poi/trunk/src: java/org/apache/poi/hssf/dev/ java/org/apache/poi/hssf/record/ testcases/org/apache/poi/hssf/eventmodel/ testcases/org/apache/poi/hssf/record/ testcases/org/apache/poi/hssf/record/constant/ testcases/org/a...
Date Fri, 10 Oct 2008 22:59:16 GMT
Author: josh
Date: Fri Oct 10 15:59:14 2008
New Revision: 703596

URL: http://svn.apache.org/viewvc?rev=703596&view=rev
Log:
Made RecordInputStream final (major clean-up in test cases and BiffViewer)

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/dev/BiffViewer.java
    poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java
    poi/trunk/src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAreaFormatRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAreaRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisLineFormatRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisOptionsRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisParentRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisUsedRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBarRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBoundSheetRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCategorySeriesAxisRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestChartRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDatRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDataFormatRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDefaultDataLabelTextPropertiesRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEndSubRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontBasisRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontIndexRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFrameRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLegendRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLineFormatRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLinkedDataRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNameRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNumberFormatIndexRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestObjRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestObjectLinkRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPaneRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPlotAreaRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestPlotGrowthRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestRecordFactory.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSCLRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSSTDeserializer.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesChartGroupIndexRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesIndexRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesLabelsRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesListRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesTextRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSeriesToChartGroupRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSheetPropertiesRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestSupBookRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTableRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTextRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestTickRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestUnitsRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestValueRangeRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestcaseRecordInputStream.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/constant/TestConstantValueParser.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestFuncPtg.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/dev/BiffViewer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/dev/BiffViewer.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/dev/BiffViewer.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/dev/BiffViewer.java Fri Oct 10 15:59:14 2008
@@ -17,17 +17,23 @@
 
 package org.apache.poi.hssf.dev;
 
+import java.io.DataInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.OutputStreamWriter;
 import java.io.PrintStream;
+import java.io.Writer;
 import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.poi.hssf.record.*;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.HexDump;
+import org.apache.poi.util.LittleEndian;
 
 /**
  *  Utillity for reading in BIFF8 records and displaying data from them.
@@ -37,333 +43,488 @@
  *@see        #main
  */
 public final class BiffViewer {
-    private final File _inputFile;
-    private boolean dump;
-    private final PrintStream _ps;
-
-
-    public BiffViewer(File inFile, PrintStream ps) {
-        _inputFile = inFile;
-        _ps = ps;
-    }
-
-
-    /**
-     *  Method run starts up BiffViewer...
-     */
-    public void run() {
-        try {
-            POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(_inputFile));
-            InputStream stream = fs.createDocumentInputStream("Workbook");
-            createRecords(stream, dump, _ps);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-
-    /**
-     *  Create an array of records from an input stream
-     *
-     *@param  in                         the InputStream from which the records
-     *      will be obtained
-     *@param  dump
-     *@return                            an array of Records created from the
-     *      InputStream
-     *@exception  RecordFormatException  on error processing the InputStream
-     */
-    public static Record[] createRecords(InputStream in, boolean dump, PrintStream ps)
-             throws RecordFormatException {
-        ArrayList records = new ArrayList();
-        RecordDetails activeRecord = null;
-
-        BiffviewRecordInputStream recStream = new BiffviewRecordInputStream(in);
-        while (recStream.hasNextRecord()) {
-            recStream.nextRecord();
-            if (recStream.getSid() != 0) {
-                Record record = createRecord (recStream);
-                    if (record.getSid() != ContinueRecord.sid)
-                    {
-                        records.add(record);
-                        if (activeRecord != null)
-                            activeRecord.dump(ps);
-                        int startPos = (int)(recStream.getPos()-recStream.getLength() - 4);
-                        activeRecord = new RecordDetails(recStream.getSid(), recStream.getLength(), startPos, record);
-                    }
-                    if (dump) {
-                        recStream.dumpBytes(ps);
-                    }
-              }
-        }
-        if (activeRecord != null) {
-            activeRecord.dump(ps);
-        }
-        Record[] retval = new Record[records.size()];
-        records.toArray(retval);
-        return retval;
-    }
-
-
-    /**
-     *  Essentially a duplicate of RecordFactory. Kept separate as not to screw
-     *  up non-debug operations.
-     *
-     */
-    private static Record createRecord( RecordInputStream in )
-    {
-        switch ( in.getSid() )
-        {
-            case AreaFormatRecord.sid:     return new AreaFormatRecord(in);
-            case AreaRecord.sid:           return new AreaRecord(in);
-            case AxisLineFormatRecord.sid: return new AxisLineFormatRecord(in);
-            case AxisOptionsRecord.sid:    return new AxisOptionsRecord(in);
-            case AxisParentRecord.sid:     return new AxisParentRecord(in);
-            case AxisRecord.sid:           return new AxisRecord(in);
-            case AxisUsedRecord.sid:       return new AxisUsedRecord(in);
-            case BOFRecord.sid:            return new BOFRecord(in);
-            case BackupRecord.sid:         return new BackupRecord(in);
-            case BarRecord.sid:            return new BarRecord(in);
-            case BeginRecord.sid:          return new BeginRecord(in);
-            case BlankRecord.sid:          return new BlankRecord(in);
-            case BookBoolRecord.sid:       return new BookBoolRecord(in);
-            case BoolErrRecord.sid:        return new BoolErrRecord(in);
-            case BottomMarginRecord.sid:   return new BottomMarginRecord(in);
-            case BoundSheetRecord.sid:     return new BoundSheetRecord(in);
-            case CFHeaderRecord.sid:       return new CFHeaderRecord(in);
-            case CFRuleRecord.sid:         return new CFRuleRecord(in);
-            case CalcCountRecord.sid:      return new CalcCountRecord(in);
-            case CalcModeRecord.sid:       return new CalcModeRecord(in);
-            case CategorySeriesAxisRecord.sid: return new CategorySeriesAxisRecord(in);
-            case ChartFormatRecord.sid:    return new ChartFormatRecord(in);
-            case ChartRecord.sid:          return new ChartRecord(in);
-            case CodepageRecord.sid:       return new CodepageRecord(in);
-            case ColumnInfoRecord.sid:     return new ColumnInfoRecord(in);
-            case ContinueRecord.sid:       return new ContinueRecord(in);
-            case CountryRecord.sid:        return new CountryRecord(in);
-            case DBCellRecord.sid:         return new DBCellRecord(in);
-            case DSFRecord.sid:            return new DSFRecord(in);
-            case DatRecord.sid:            return new DatRecord(in);
-            case DataFormatRecord.sid:     return new DataFormatRecord(in);
-            case DateWindow1904Record.sid: return new DateWindow1904Record(in);
-            case DefaultColWidthRecord.sid:return new DefaultColWidthRecord(in);
-            case DefaultDataLabelTextPropertiesRecord.sid: return new DefaultDataLabelTextPropertiesRecord(in);
-            case DefaultRowHeightRecord.sid: return new DefaultRowHeightRecord(in);
-            case DeltaRecord.sid:          return new DeltaRecord(in);
-            case DimensionsRecord.sid:     return new DimensionsRecord(in);
-            case DrawingGroupRecord.sid:   return new DrawingGroupRecord(in);
-            case DrawingRecordForBiffViewer.sid: return new DrawingRecordForBiffViewer(in);
-            case DrawingSelectionRecord.sid: return new DrawingSelectionRecord(in);
-            case DVRecord.sid:             return new DVRecord(in);
-            case DVALRecord.sid:           return new DVALRecord(in);
-            case EOFRecord.sid:            return new EOFRecord(in);
-            case EndRecord.sid:            return new EndRecord(in);
-            case ExtSSTRecord.sid:         return new ExtSSTRecord(in);
-            case ExtendedFormatRecord.sid: return new ExtendedFormatRecord(in);
-            case ExternSheetRecord.sid:    return new ExternSheetRecord(in);
-            case FilePassRecord.sid:       return new FilePassRecord(in);
-            case FileSharingRecord.sid:    return new FileSharingRecord(in);
-            case FnGroupCountRecord.sid:   return new FnGroupCountRecord(in);
-            case FontBasisRecord.sid:      return new FontBasisRecord(in);
-            case FontIndexRecord.sid:      return new FontIndexRecord(in);
-            case FontRecord.sid:           return new FontRecord(in);
-            case FooterRecord.sid:         return new FooterRecord(in);
-            case FormatRecord.sid:         return new FormatRecord(in);
-            case FormulaRecord.sid:        return new FormulaRecord(in);
-            case FrameRecord.sid:          return new FrameRecord(in);
-            case GridsetRecord.sid:        return new GridsetRecord(in);
-            case GutsRecord.sid:           return new GutsRecord(in);
-            case HCenterRecord.sid:        return new HCenterRecord(in);
-            case HeaderRecord.sid:         return new HeaderRecord(in);
-            case HideObjRecord.sid:        return new HideObjRecord(in);
-            case HorizontalPageBreakRecord.sid: return new HorizontalPageBreakRecord(in);
-            case HyperlinkRecord.sid:      return new HyperlinkRecord(in);
-            case IndexRecord.sid:          return new IndexRecord(in);
-            case InterfaceEndRecord.sid:   return new InterfaceEndRecord(in);
-            case InterfaceHdrRecord.sid:   return new InterfaceHdrRecord(in);
-            case IterationRecord.sid:      return new IterationRecord(in);
-            case LabelRecord.sid:          return new LabelRecord(in);
-            case LabelSSTRecord.sid:       return new LabelSSTRecord(in);
-            case LeftMarginRecord.sid:     return new LeftMarginRecord(in);
-            case LegendRecord.sid:         return new LegendRecord(in);
-            case LineFormatRecord.sid:     return new LineFormatRecord(in);
-            case LinkedDataRecord.sid:     return new LinkedDataRecord(in);
-            case MMSRecord.sid:            return new MMSRecord(in);
-            case MergeCellsRecord.sid:     return new MergeCellsRecord(in);
-            case MulBlankRecord.sid:       return new MulBlankRecord(in);
-            case MulRKRecord.sid:          return new MulRKRecord(in);
-            case NameRecord.sid:           return new NameRecord(in);
-            case NoteRecord.sid:           return new NoteRecord(in);
-            case NumberRecord.sid:         return new NumberRecord(in);
-            case ObjRecord.sid:            return new ObjRecord(in);
-            case ObjectLinkRecord.sid:     return new ObjectLinkRecord(in);
-            case PaletteRecord.sid:        return new PaletteRecord(in);
-            case PaneRecord.sid:           return new PaneRecord(in);
-            case PasswordRecord.sid:       return new PasswordRecord(in);
-            case PasswordRev4Record.sid:   return new PasswordRev4Record(in);
-            case PlotAreaRecord.sid:       return new PlotAreaRecord(in);
-            case PlotGrowthRecord.sid:     return new PlotGrowthRecord(in);
-            case PrecisionRecord.sid:      return new PrecisionRecord(in);
-            case PrintGridlinesRecord.sid: return new PrintGridlinesRecord(in);
-            case PrintHeadersRecord.sid:   return new PrintHeadersRecord(in);
-            case PrintSetupRecord.sid:     return new PrintSetupRecord(in);
-            case ProtectRecord.sid:        return new ProtectRecord(in);
-            case ProtectionRev4Record.sid: return new ProtectionRev4Record(in);
-            case RKRecord.sid:             return new RKRecord(in);
-            case RefModeRecord.sid:        return new RefModeRecord(in);
-            case RefreshAllRecord.sid:     return new RefreshAllRecord(in);
-            case RightMarginRecord.sid:    return new RightMarginRecord(in);
-            case RowRecord.sid:            return new RowRecord(in);
-            case SCLRecord.sid:            return new SCLRecord(in);
-            case SSTRecord.sid:            return new SSTRecord(in);
-            case SaveRecalcRecord.sid:     return new SaveRecalcRecord(in);
-            case SelectionRecord.sid:      return new SelectionRecord(in);
-            case SeriesIndexRecord.sid:    return new SeriesIndexRecord(in);
-            case SeriesListRecord.sid:     return new SeriesListRecord(in);
-            case SeriesRecord.sid:         return new SeriesRecord(in);
-            case SeriesTextRecord.sid:     return new SeriesTextRecord(in);
-            case SeriesToChartGroupRecord.sid: return new SeriesToChartGroupRecord(in);
-            case SharedFormulaRecord.sid:  return new SharedFormulaRecord(in);
-            case SheetPropertiesRecord.sid:return new SheetPropertiesRecord(in);
-            case StringRecord.sid:         return new StringRecord(in);
-            case StyleRecord.sid:          return new StyleRecord(in);
-            case SupBookRecord.sid:        return new SupBookRecord(in);
-            case TabIdRecord.sid:          return new TabIdRecord(in);
-            case TableRecord.sid:          return new TableRecord(in);
-            case TextObjectRecord.sid:     return new TextObjectRecord(in);
-            case TextRecord.sid:           return new TextRecord(in);
-            case TickRecord.sid:           return new TickRecord(in);
-            case TopMarginRecord.sid:      return new TopMarginRecord(in);
-            case UnitsRecord.sid:          return new UnitsRecord(in);
-            case UseSelFSRecord.sid:       return new UseSelFSRecord(in);
-            case VCenterRecord.sid:        return new VCenterRecord(in);
-            case ValueRangeRecord.sid:     return new ValueRangeRecord(in);
-            case VerticalPageBreakRecord.sid: return new VerticalPageBreakRecord(in);
-            case WSBoolRecord.sid:         return new WSBoolRecord(in);
-            case WindowOneRecord.sid:      return new WindowOneRecord(in);
-            case WindowProtectRecord.sid:  return new WindowProtectRecord(in);
-            case WindowTwoRecord.sid:      return new WindowTwoRecord(in);
-            case WriteAccessRecord.sid:    return new WriteAccessRecord(in);
-            case WriteProtectRecord.sid:   return new WriteProtectRecord(in);        
-        
-        }
-        return new UnknownRecord(in);
-    }
-
-
-    /**
-     *  Method setDump - hex dump out data or not.
-     */
-    public void setDump(boolean dump) {
-        this.dump = dump;
-    }
-
-
-    /**
-     * Method main with 1 argument just run straight biffview against given
-     * file<P>
-     *
-     * with 2 arguments where the second argument is "on" - run biffviewer<P>
-     *
-     * with hex dumps of records <P>
-     *
-     * with 2 arguments where the second argument is "bfd" just run a big fat
-     * hex dump of the file...don't worry about biffviewing it at all
-     * <p>
-     * Define the system property <code>poi.deserialize.escher</code> to turn on
-     * deserialization of escher records.
-     *
-     */
-    public static void main(String[] args) {
-
-        System.setProperty("poi.deserialize.escher", "true");
-
-        if (args.length == 0) {
-            System.out.println( "Biff viewer needs a filename" );
-            return;
-        }
-
-        try {
-            String inFileName = args[0];
-            File inputFile = new File(inFileName);
-            if(!inputFile.exists()) {
-                throw new RuntimeException("specified inputFile '" + inFileName + "' does not exist");
-            }
-            PrintStream ps;
-            if (false) { // set to true to output to file
-                OutputStream os = new FileOutputStream(inFileName + ".out");
-                ps = new PrintStream(os);
-            } else {
-                ps = System.out;
-            }
-            BiffViewer viewer = new BiffViewer(inputFile, ps);
-
-            if (args.length > 1 && args[1].equals("on")) {
-                viewer.setDump(true);
-            }
-            if (args.length > 1 && args[1].equals("bfd")) {
-                POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(inputFile));
-                InputStream stream = fs.createDocumentInputStream("Workbook");
-                int size = stream.available();
-                byte[] data = new byte[size];
-
-                stream.read(data);
-                HexDump.dump(data, 0, System.out, 0);
-            } else {
-                viewer.run();
-            }
-            ps.close();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * This record supports dumping of completed continue records.
-     */
-    private static final class RecordDetails
-    {
-        short rectype, recsize;
-        int startloc;
-        Record record;
-
-        public RecordDetails( short rectype, short recsize, int startloc, Record record )
-        {
-            this.rectype = rectype;
-            this.recsize = recsize;
-            this.startloc = startloc;
-            this.record = record;
-        }
-
-        public short getRectype()
-        {
-            return rectype;
-        }
-
-        public short getRecsize()
-        {
-            return recsize;
-        }
-
-        public Record getRecord()
-        {
-            return record;
-        }
-
-        public void dump(PrintStream ps) {
-            ps.println("Offset 0x" + Integer.toHexString(startloc) + " (" + startloc + ")");
-            ps.println( "recordid = 0x" + Integer.toHexString( rectype ) + ", size = " + recsize );
-            ps.println( record.toString() );
-        }
-    }
-
-    private static final class BiffviewRecordInputStream extends RecordInputStream {
-      public BiffviewRecordInputStream(InputStream in) {
-        super(in);
-      }
-      public void dumpBytes(PrintStream ps) {
-        ps.println(HexDump.dump(this.data, 0, this.currentLength));
-      }
-    }
+	static final char[] NEW_LINE_CHARS = System.getProperty("line.separator").toCharArray();
 
+	private BiffViewer() {
+		// no instances of this class
+	}
+
+	/**
+	 *  Create an array of records from an input stream
+	 *
+	 *@param  in the InputStream from which the records will be obtained
+	 *@return an array of Records created from the InputStream
+	 *@exception  RecordFormatException  on error processing the InputStream
+	 */
+	public static Record[] createRecords(InputStream is, PrintStream ps, BiffRecordListener recListener, boolean dumpInterpretedRecords)
+			throws RecordFormatException {
+		ArrayList temp = new ArrayList();
+
+		RecordInputStream recStream = new RecordInputStream(is);
+		while (recStream.hasNextRecord()) {
+			recStream.nextRecord();
+			if (recStream.getSid() == 0) {
+				continue;
+			}
+			Record record = createRecord (recStream);
+			if (record.getSid() == ContinueRecord.sid) {
+				continue;
+			}
+			temp.add(record);
+			if (dumpInterpretedRecords) {
+				String[] headers = recListener.getRecentHeaders();
+				for (int i = 0; i < headers.length; i++) {
+					ps.println(headers[i]);
+				}
+				ps.print(record.toString());
+			}
+			ps.println();
+		}
+		Record[] result = new Record[temp.size()];
+		temp.toArray(result);
+		return result;
+	}
+
+
+	/**
+	 *  Essentially a duplicate of RecordFactory. Kept separate as not to screw
+	 *  up non-debug operations.
+	 *
+	 */
+	private static Record createRecord(RecordInputStream in) {
+		switch (in.getSid()) {
+			case AreaFormatRecord.sid:     return new AreaFormatRecord(in);
+			case AreaRecord.sid:           return new AreaRecord(in);
+			case ArrayRecord.sid:          return new ArrayRecord(in);
+			case AxisLineFormatRecord.sid: return new AxisLineFormatRecord(in);
+			case AxisOptionsRecord.sid:    return new AxisOptionsRecord(in);
+			case AxisParentRecord.sid:     return new AxisParentRecord(in);
+			case AxisRecord.sid:           return new AxisRecord(in);
+			case AxisUsedRecord.sid:       return new AxisUsedRecord(in);
+			case BOFRecord.sid:            return new BOFRecord(in);
+			case BackupRecord.sid:         return new BackupRecord(in);
+			case BarRecord.sid:            return new BarRecord(in);
+			case BeginRecord.sid:          return new BeginRecord(in);
+			case BlankRecord.sid:          return new BlankRecord(in);
+			case BookBoolRecord.sid:       return new BookBoolRecord(in);
+			case BoolErrRecord.sid:        return new BoolErrRecord(in);
+			case BottomMarginRecord.sid:   return new BottomMarginRecord(in);
+			case BoundSheetRecord.sid:     return new BoundSheetRecord(in);
+			case CFHeaderRecord.sid:       return new CFHeaderRecord(in);
+			case CFRuleRecord.sid:         return new CFRuleRecord(in);
+			case CalcCountRecord.sid:      return new CalcCountRecord(in);
+			case CalcModeRecord.sid:       return new CalcModeRecord(in);
+			case CategorySeriesAxisRecord.sid: return new CategorySeriesAxisRecord(in);
+			case ChartFormatRecord.sid:    return new ChartFormatRecord(in);
+			case ChartRecord.sid:          return new ChartRecord(in);
+			case CodepageRecord.sid:       return new CodepageRecord(in);
+			case ColumnInfoRecord.sid:     return new ColumnInfoRecord(in);
+			case ContinueRecord.sid:       return new ContinueRecord(in);
+			case CountryRecord.sid:        return new CountryRecord(in);
+			case DBCellRecord.sid:         return new DBCellRecord(in);
+			case DSFRecord.sid:            return new DSFRecord(in);
+			case DatRecord.sid:            return new DatRecord(in);
+			case DataFormatRecord.sid:     return new DataFormatRecord(in);
+			case DateWindow1904Record.sid: return new DateWindow1904Record(in);
+			case DefaultColWidthRecord.sid:return new DefaultColWidthRecord(in);
+			case DefaultDataLabelTextPropertiesRecord.sid: return new DefaultDataLabelTextPropertiesRecord(in);
+			case DefaultRowHeightRecord.sid: return new DefaultRowHeightRecord(in);
+			case DeltaRecord.sid:          return new DeltaRecord(in);
+			case DimensionsRecord.sid:     return new DimensionsRecord(in);
+			case DrawingGroupRecord.sid:   return new DrawingGroupRecord(in);
+			case DrawingRecordForBiffViewer.sid: return new DrawingRecordForBiffViewer(in);
+			case DrawingSelectionRecord.sid: return new DrawingSelectionRecord(in);
+			case DVRecord.sid:             return new DVRecord(in);
+			case DVALRecord.sid:           return new DVALRecord(in);
+			case EOFRecord.sid:            return new EOFRecord(in);
+			case EndRecord.sid:            return new EndRecord(in);
+			case ExtSSTRecord.sid:         return new ExtSSTRecord(in);
+			case ExtendedFormatRecord.sid: return new ExtendedFormatRecord(in);
+			case ExternSheetRecord.sid:    return new ExternSheetRecord(in);
+			case FilePassRecord.sid:       return new FilePassRecord(in);
+			case FileSharingRecord.sid:    return new FileSharingRecord(in);
+			case FnGroupCountRecord.sid:   return new FnGroupCountRecord(in);
+			case FontBasisRecord.sid:      return new FontBasisRecord(in);
+			case FontIndexRecord.sid:      return new FontIndexRecord(in);
+			case FontRecord.sid:           return new FontRecord(in);
+			case FooterRecord.sid:         return new FooterRecord(in);
+			case FormatRecord.sid:         return new FormatRecord(in);
+			case FormulaRecord.sid:        return new FormulaRecord(in);
+			case FrameRecord.sid:          return new FrameRecord(in);
+			case GridsetRecord.sid:        return new GridsetRecord(in);
+			case GutsRecord.sid:           return new GutsRecord(in);
+			case HCenterRecord.sid:        return new HCenterRecord(in);
+			case HeaderRecord.sid:         return new HeaderRecord(in);
+			case HideObjRecord.sid:        return new HideObjRecord(in);
+			case HorizontalPageBreakRecord.sid: return new HorizontalPageBreakRecord(in);
+			case HyperlinkRecord.sid:      return new HyperlinkRecord(in);
+			case IndexRecord.sid:          return new IndexRecord(in);
+			case InterfaceEndRecord.sid:   return new InterfaceEndRecord(in);
+			case InterfaceHdrRecord.sid:   return new InterfaceHdrRecord(in);
+			case IterationRecord.sid:      return new IterationRecord(in);
+			case LabelRecord.sid:          return new LabelRecord(in);
+			case LabelSSTRecord.sid:       return new LabelSSTRecord(in);
+			case LeftMarginRecord.sid:     return new LeftMarginRecord(in);
+			case LegendRecord.sid:         return new LegendRecord(in);
+			case LineFormatRecord.sid:     return new LineFormatRecord(in);
+			case LinkedDataRecord.sid:     return new LinkedDataRecord(in);
+			case MMSRecord.sid:            return new MMSRecord(in);
+			case MergeCellsRecord.sid:     return new MergeCellsRecord(in);
+			case MulBlankRecord.sid:       return new MulBlankRecord(in);
+			case MulRKRecord.sid:          return new MulRKRecord(in);
+			case NameRecord.sid:           return new NameRecord(in);
+			case NoteRecord.sid:           return new NoteRecord(in);
+			case NumberRecord.sid:         return new NumberRecord(in);
+			case ObjRecord.sid:            return new ObjRecord(in);
+			case ObjectLinkRecord.sid:     return new ObjectLinkRecord(in);
+			case PaletteRecord.sid:        return new PaletteRecord(in);
+			case PaneRecord.sid:           return new PaneRecord(in);
+			case PasswordRecord.sid:       return new PasswordRecord(in);
+			case PasswordRev4Record.sid:   return new PasswordRev4Record(in);
+			case PlotAreaRecord.sid:       return new PlotAreaRecord(in);
+			case PlotGrowthRecord.sid:     return new PlotGrowthRecord(in);
+			case PrecisionRecord.sid:      return new PrecisionRecord(in);
+			case PrintGridlinesRecord.sid: return new PrintGridlinesRecord(in);
+			case PrintHeadersRecord.sid:   return new PrintHeadersRecord(in);
+			case PrintSetupRecord.sid:     return new PrintSetupRecord(in);
+			case ProtectRecord.sid:        return new ProtectRecord(in);
+			case ProtectionRev4Record.sid: return new ProtectionRev4Record(in);
+			case RKRecord.sid:             return new RKRecord(in);
+			case RefModeRecord.sid:        return new RefModeRecord(in);
+			case RefreshAllRecord.sid:     return new RefreshAllRecord(in);
+			case RightMarginRecord.sid:    return new RightMarginRecord(in);
+			case RowRecord.sid:            return new RowRecord(in);
+			case SCLRecord.sid:            return new SCLRecord(in);
+			case SSTRecord.sid:            return new SSTRecord(in);
+			case SaveRecalcRecord.sid:     return new SaveRecalcRecord(in);
+			case SelectionRecord.sid:      return new SelectionRecord(in);
+			case SeriesIndexRecord.sid:    return new SeriesIndexRecord(in);
+			case SeriesListRecord.sid:     return new SeriesListRecord(in);
+			case SeriesRecord.sid:         return new SeriesRecord(in);
+			case SeriesTextRecord.sid:     return new SeriesTextRecord(in);
+			case SeriesToChartGroupRecord.sid: return new SeriesToChartGroupRecord(in);
+			case SharedFormulaRecord.sid:  return new SharedFormulaRecord(in);
+			case SheetPropertiesRecord.sid:return new SheetPropertiesRecord(in);
+			case StringRecord.sid:         return new StringRecord(in);
+			case StyleRecord.sid:          return new StyleRecord(in);
+			case SupBookRecord.sid:        return new SupBookRecord(in);
+			case TabIdRecord.sid:          return new TabIdRecord(in);
+			case TableRecord.sid:          return new TableRecord(in);
+			case TextObjectRecord.sid:     return new TextObjectRecord(in);
+			case TextRecord.sid:           return new TextRecord(in);
+			case TickRecord.sid:           return new TickRecord(in);
+			case TopMarginRecord.sid:      return new TopMarginRecord(in);
+			case UnitsRecord.sid:          return new UnitsRecord(in);
+			case UseSelFSRecord.sid:       return new UseSelFSRecord(in);
+			case VCenterRecord.sid:        return new VCenterRecord(in);
+			case ValueRangeRecord.sid:     return new ValueRangeRecord(in);
+			case VerticalPageBreakRecord.sid: return new VerticalPageBreakRecord(in);
+			case WSBoolRecord.sid:         return new WSBoolRecord(in);
+			case WindowOneRecord.sid:      return new WindowOneRecord(in);
+			case WindowProtectRecord.sid:  return new WindowProtectRecord(in);
+			case WindowTwoRecord.sid:      return new WindowTwoRecord(in);
+			case WriteAccessRecord.sid:    return new WriteAccessRecord(in);
+			case WriteProtectRecord.sid:   return new WriteProtectRecord(in);        
+		
+		}
+		return new UnknownRecord(in);
+	}
+
+	/**
+	 * Method main with 1 argument just run straight biffview against given
+	 * file<P>
+	 *
+	 * with 2 arguments where the second argument is "on" - run biffviewer<P>
+	 *
+	 * with hex dumps of records <P>
+	 *
+	 * with 2 arguments where the second argument is "bfd" just run a big fat
+	 * hex dump of the file...don't worry about biffviewing it at all
+	 * <p>
+	 * Define the system property <code>poi.deserialize.escher</code> to turn on
+	 * deserialization of escher records.
+	 *
+	 */
+	public static void main(String[] args) {
+
+		System.setProperty("poi.deserialize.escher", "true");
+
+		if (args.length == 0) {
+			System.out.println( "Biff viewer needs a filename" );
+			return;
+		}
+
+		try {
+			String inFileName = args[0];
+			File inputFile = new File(inFileName);
+			if(!inputFile.exists()) {
+				throw new RuntimeException("specified inputFile '" + inFileName + "' does not exist");
+			}
+			PrintStream ps;
+			if (false) { // set to true to output to file
+				OutputStream os = new FileOutputStream(inFileName + ".out");
+				ps = new PrintStream(os);
+			} else {
+				ps = System.out;
+			}
+ 
+			if (args.length > 1 && args[1].equals("bfd")) {
+				POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(inputFile));
+				InputStream stream = fs.createDocumentInputStream("Workbook");
+				int size = stream.available();
+				byte[] data = new byte[size];
+
+				stream.read(data);
+				HexDump.dump(data, 0, System.out, 0);
+			} else {
+				boolean dumpInterpretedRecords = true;
+				boolean dumpHex = args.length > 1 && args[1].equals("on");
+
+				POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(inputFile));
+				InputStream is = fs.createDocumentInputStream("Workbook");
+				BiffRecordListener recListener = new BiffRecordListener(dumpHex ? new OutputStreamWriter(ps) : null);
+				is = new BiffDumpingStream(is, recListener);
+				createRecords(is, ps, recListener, dumpInterpretedRecords);
+			}
+			ps.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	private static final class BiffRecordListener implements IBiffRecordListener {
+		private final Writer _hexDumpWriter;
+		private final List _headers;
+		public BiffRecordListener(Writer hexDumpWriter) {
+			_hexDumpWriter = hexDumpWriter;
+			_headers = new ArrayList();
+		}
+
+		public void processRecord(int globalOffset, int recordCounter, int sid, int dataSize,
+				byte[] data) {
+			String header = formatRecordDetails(globalOffset, sid, dataSize, recordCounter);
+			_headers.add(header);
+			Writer w = _hexDumpWriter;
+			if (w != null) {
+				try {
+					w.write(header);
+					w.write(NEW_LINE_CHARS);
+					hexDumpAligned(w, data, 0, dataSize+4, globalOffset);
+					w.flush();
+				} catch (IOException e) {
+					throw new RuntimeException(e);
+				}
+			}
+		}
+		public String[] getRecentHeaders() {
+			String[] result = new String[_headers.size()];
+			_headers.toArray(result);
+			_headers.clear();
+			return result;
+		}
+		private static String formatRecordDetails(int globalOffset, int sid, int size, int recordCounter) {
+			StringBuffer sb = new StringBuffer(64);
+			sb.append("Offset=").append(HexDump.intToHex(globalOffset)).append("(").append(globalOffset).append(")");
+			sb.append(" recno=").append(recordCounter);
+			sb.append(  " sid=").append(HexDump.shortToHex(sid));
+			sb.append( " size=").append(HexDump.shortToHex(size)).append("(").append(size).append(")");
+			return sb.toString();
+		}
+	}
+	
+	private static interface IBiffRecordListener {
+
+		void processRecord(int globalOffset, int recordCounter, int sid, int dataSize, byte[] data);
+		
+	}
+
+	/**
+	 * Wraps a plain {@link InputStream} and allows BIFF record information to be tapped off
+	 *
+	 */
+	private static final class BiffDumpingStream extends InputStream {
+		private final DataInputStream _is;
+		private final IBiffRecordListener _listener;
+		private final byte[] _data;
+		private int _recordCounter;
+		private int _overallStreamPos;
+		private int _currentPos;
+		private int _currentSize;
+		private boolean _innerHasReachedEOF;
+		
+		public BiffDumpingStream(InputStream is, IBiffRecordListener listener) {
+			_is = new DataInputStream(is);
+			_listener = listener;
+			_data = new byte[RecordInputStream.MAX_RECORD_DATA_SIZE + 4];
+			_recordCounter = 0;
+			_overallStreamPos = 0;
+			_currentSize = 0;
+			_currentPos = 0;
+		}
+
+		public int read() throws IOException {
+			if (_currentPos >= _currentSize) {
+				fillNextBuffer();
+			}
+			if (_currentPos >= _currentSize) {
+				return -1;
+			}
+			int result = _data[_currentPos] & 0x00FF;
+			_currentPos ++;
+			_overallStreamPos ++;
+			formatBufferIfAtEndOfRec();
+			return result;
+		}
+		public int read(byte[] b, int off, int len) throws IOException {
+			if (_currentPos >= _currentSize) {
+				fillNextBuffer();
+			}
+			if (_currentPos >= _currentSize) {
+				return -1;
+			}
+			int availSize = _currentSize - _currentPos;
+			int result;
+			if (len > availSize) {
+				System.err.println("Unexpected request to read past end of current biff record");
+				result = availSize;
+			} else {
+				result = len;
+			}
+			System.arraycopy(_data, _currentPos, b, off, result);
+			_currentPos += result;
+			_overallStreamPos += result;
+			formatBufferIfAtEndOfRec();
+			return result;
+		}
+
+		public int available() throws IOException {
+			return _currentSize - _currentPos + _is.available();
+		}
+		private void fillNextBuffer() throws IOException {
+			if (_innerHasReachedEOF) {
+				return;
+			}
+			int b0 = _is.read();
+			if (b0 == -1) {
+				_innerHasReachedEOF = true;
+				return;
+			}
+			_data[0] = (byte) b0;
+			_is.readFully(_data, 1, 3);
+			int len = LittleEndian.getShort(_data, 2);
+			_is.readFully(_data, 4, len);
+			_currentPos = 0;
+			_currentSize = len + 4;
+			_recordCounter++;
+		}
+		private void formatBufferIfAtEndOfRec() {
+			if (_currentPos != _currentSize) {
+				return;
+			}
+			int dataSize = _currentSize-4;
+			int sid = LittleEndian.getShort(_data, 0);
+			int globalOffset = _overallStreamPos-_currentSize;
+			_listener.processRecord(globalOffset, _recordCounter, sid, dataSize, _data);
+		}
+		public void close() throws IOException {
+			_is.close();
+		}
+	}
+	
+	private static final int DUMP_LINE_LEN = 16;
+	private static final char[] COLUMN_SEPARATOR = " | ".toCharArray();
+	/**
+	 * Hex-dumps a portion of a byte array in typical format, also preserving dump-line alignment  
+	 * @param globalOffset (somewhat arbitrary) used to calculate the addresses printed at the 
+	 * start of each line 
+	 */
+	static void hexDumpAligned(Writer w, byte[] data, int baseDataOffset, int dumpLen, int globalOffset) {
+		// perhaps this code should be moved to HexDump
+		int globalStart = globalOffset + baseDataOffset;
+		int globalEnd = globalOffset + baseDataOffset + dumpLen;
+		int startDelta = globalStart % DUMP_LINE_LEN;
+		int endDelta = globalEnd % DUMP_LINE_LEN;
+		int startLineAddr = globalStart - startDelta;
+		int endLineAddr = globalEnd - endDelta;
+		
+		int lineDataOffset = baseDataOffset - startDelta;
+		int lineAddr = startLineAddr;
+		
+		// output (possibly incomplete) first line
+		if (startLineAddr == endLineAddr) {
+			hexDumpLine(w, data, lineAddr, lineDataOffset, startDelta, endDelta);
+			return;
+		}
+		hexDumpLine(w, data, lineAddr, lineDataOffset, startDelta, DUMP_LINE_LEN);
+		
+		// output all full lines in the middle
+		while (true) {
+			lineAddr += DUMP_LINE_LEN;
+			lineDataOffset += DUMP_LINE_LEN;
+			if (lineAddr >= endLineAddr) {
+				break;
+			}
+			hexDumpLine(w, data, lineAddr, lineDataOffset, 0, DUMP_LINE_LEN);
+		}
+		
+		
+		// output (possibly incomplete) last line
+		if (endDelta != 0) {
+			hexDumpLine(w, data, lineAddr, lineDataOffset, 0, endDelta);
+		}
+	}
+
+	private static void hexDumpLine(Writer w, byte[] data, int lineStartAddress, int lineDataOffset, int startDelta, int endDelta) {
+		if (startDelta >= endDelta) {
+			throw new IllegalArgumentException("Bad start/end delta");
+		}
+		try {
+			writeHex(w, lineStartAddress, 8);
+			w.write(COLUMN_SEPARATOR);
+			// raw hex data
+			for (int i=0; i< DUMP_LINE_LEN; i++) {
+				if (i>0) {
+					w.write(" ");
+				}
+				if (i >= startDelta && i < endDelta) {
+					writeHex(w, data[lineDataOffset+i], 2);
+				} else {
+					w.write("  ");
+				}
+			}
+			w.write(COLUMN_SEPARATOR);
+
+			// interpreted ascii
+			for (int i=0; i< DUMP_LINE_LEN; i++) {
+				if (i >= startDelta && i < endDelta) {
+					w.write(getPrintableChar(data[lineDataOffset+i]));
+				} else {
+					w.write(" ");
+				}
+			}
+			w.write(NEW_LINE_CHARS);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	private static char getPrintableChar(byte b) {
+		char ib = (char) (b & 0x00FF);
+		if (ib < 32 || ib > 126) {
+			return '.';
+		}
+		return ib;
+	}
+
+	private static void writeHex(Writer w, int value, int nDigits) throws IOException {
+		char[] buf = new char[nDigits];
+		int acc = value;
+		for(int i=nDigits-1; i>=0; i--) {
+			int digit = acc & 0x0F;
+			buf[i] = (char) (digit < 10 ? ('0' + digit) : ('A' + digit - 10));
+			acc >>= 4;
+		}
+		w.write(buf);
+	}
 }
 

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/RecordInputStream.java Fri Oct 10 15:59:14 2008
@@ -29,19 +29,19 @@
  *
  * @author Jason Height (jheight @ apache dot org)
  */
-public class RecordInputStream extends InputStream {
-  /** Maximum size of a single record (minus the 4 byte header) without a continue*/
-  public final static short MAX_RECORD_DATA_SIZE = 8224;
-  private static final int INVALID_SID_VALUE = -1;
-
-  private InputStream in;
-  protected short currentSid;
-  protected short currentLength = -1;
-  protected short nextSid;
-
-  protected byte[] data = new byte[MAX_RECORD_DATA_SIZE];
-  protected short recordOffset;
-  protected long pos;
+public final class RecordInputStream extends InputStream {
+	/** Maximum size of a single record (minus the 4 byte header) without a continue*/
+	public final static short MAX_RECORD_DATA_SIZE = 8224;
+	private static final int INVALID_SID_VALUE = -1;
+
+	private InputStream in;
+	private short currentSid;
+	private short currentLength = -1;
+	private short nextSid;
+
+	private final byte[] data = new byte[MAX_RECORD_DATA_SIZE];
+	private short recordOffset;
+	private long pos;
 
   private boolean autoContinue = true;
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java Fri Oct 10 15:59:14 2008
@@ -87,10 +87,8 @@
         bof.setHistoryBitMask(BOFRecord.HISTORY_MASK);
         
         byte[] bytes = bof.serialize();
-        byte[] nbytes = new byte[bytes.length - 4];
-        System.arraycopy(bytes,4,nbytes,0,nbytes.length);
             
-        Record[] records = RecordFactory.createRecord(new TestcaseRecordInputStream(bof.getSid(),(short)nbytes.length,nbytes));
+        Record[] records = RecordFactory.createRecord(TestcaseRecordInputStream.create(bytes));
         
         assertTrue("record.length must be 1, was ="+records.length,records.length == 1);
         assertTrue("record is the same", compareRec(bof,records[0]));

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAreaFormatRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAreaFormatRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAreaFormatRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAreaFormatRecord.java Fri Oct 10 15:59:14 2008
@@ -41,7 +41,7 @@
 
     public void testLoad() {
 
-        AreaFormatRecord record = new AreaFormatRecord(new TestcaseRecordInputStream((short)0x100a, (short)data.length, data));
+        AreaFormatRecord record = new AreaFormatRecord(TestcaseRecordInputStream.create(0x100a, data));
         assertEquals( 0xFFFFFF, record.getForegroundColor());
         assertEquals( 0x000000, record.getBackgroundColor());
         assertEquals( 1, record.getPattern());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAreaRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAreaRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAreaRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAreaRecord.java Fri Oct 10 15:59:14 2008
@@ -35,7 +35,7 @@
 
     public void testLoad() {
 
-        AreaRecord record = new AreaRecord(new TestcaseRecordInputStream((short)0x101A, (short)data.length, data));
+        AreaRecord record = new AreaRecord(TestcaseRecordInputStream.create(0x101A, data));
         assertEquals( 2, record.getFormatFlags());
         assertEquals( false, record.isStacked() );
         assertEquals( true, record.isDisplayAsPercentage() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisLineFormatRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisLineFormatRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisLineFormatRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisLineFormatRecord.java Fri Oct 10 15:59:14 2008
@@ -34,7 +34,7 @@
     };
 
     public void testLoad() {
-        AxisLineFormatRecord record = new AxisLineFormatRecord(new TestcaseRecordInputStream((short)0x1021, (short)data.length, data));
+        AxisLineFormatRecord record = new AxisLineFormatRecord(TestcaseRecordInputStream.create(0x1021, data));
         assertEquals( AxisLineFormatRecord.AXIS_TYPE_MAJOR_GRID_LINE, record.getAxisType());
 
         assertEquals( 6, record.getRecordSize() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisOptionsRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisOptionsRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisOptionsRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisOptionsRecord.java Fri Oct 10 15:59:14 2008
@@ -37,7 +37,7 @@
     };
 
     public void testLoad() {
-        AxisOptionsRecord record = new AxisOptionsRecord(new TestcaseRecordInputStream((short)0x1062, (short)data.length, data));
+        AxisOptionsRecord record = new AxisOptionsRecord(TestcaseRecordInputStream.create(0x1062, data));
         assertEquals( 0, record.getMinimumCategory());
         assertEquals( 0, record.getMaximumCategory());
         assertEquals( 1, record.getMajorUnitValue());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisParentRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisParentRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisParentRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisParentRecord.java Fri Oct 10 15:59:14 2008
@@ -37,7 +37,7 @@
     };
 
     public void testLoad() {
-        AxisParentRecord record = new AxisParentRecord(new TestcaseRecordInputStream((short)0x1041, (short)data.length, data));
+        AxisParentRecord record = new AxisParentRecord(TestcaseRecordInputStream.create(0x1041, data));
         assertEquals( AxisParentRecord.AXIS_TYPE_MAIN, record.getAxisType());
         assertEquals( 0x021d, record.getX());
         assertEquals( 0xdd, record.getY());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisRecord.java Fri Oct 10 15:59:14 2008
@@ -39,7 +39,7 @@
 
     public void testLoad() {
 
-        AxisRecord record = new AxisRecord(new TestcaseRecordInputStream((short)0x101d, (short)data.length, data));
+        AxisRecord record = new AxisRecord(TestcaseRecordInputStream.create(0x101d, data));
         assertEquals( AxisRecord.AXIS_TYPE_CATEGORY_OR_X_AXIS, record.getAxisType());
         assertEquals( 0, record.getReserved1());
         assertEquals( 0, record.getReserved2());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisUsedRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisUsedRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisUsedRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAxisUsedRecord.java Fri Oct 10 15:59:14 2008
@@ -34,7 +34,7 @@
     };
 
     public void testLoad() {
-        AxisUsedRecord record = new AxisUsedRecord(new TestcaseRecordInputStream((short)0x1046, (short)data.length, data));
+        AxisUsedRecord record = new AxisUsedRecord(TestcaseRecordInputStream.create(0x1046, data));
         assertEquals( 1, record.getNumAxis());
 
         assertEquals( 6, record.getRecordSize() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBarRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBarRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBarRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBarRecord.java Fri Oct 10 15:59:14 2008
@@ -37,7 +37,7 @@
 
     public void testLoad() {
 
-        BarRecord record = new BarRecord(new TestcaseRecordInputStream((short)0x1017, (short)data.length, data));
+        BarRecord record = new BarRecord(TestcaseRecordInputStream.create(0x1017, data));
         assertEquals( 0, record.getBarSpace());
         assertEquals( 0x96, record.getCategorySpace());
         assertEquals( 0, record.getFormatFlags());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBoundSheetRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBoundSheetRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBoundSheetRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBoundSheetRecord.java Fri Oct 10 15:59:14 2008
@@ -69,7 +69,7 @@
 			// </str>
 		};
 	
-		RecordInputStream in = new TestcaseRecordInputStream(BoundSheetRecord.sid, data);
+		RecordInputStream in = TestcaseRecordInputStream.create(BoundSheetRecord.sid, data);
 		BoundSheetRecord bsr = new BoundSheetRecord(in);
 		// sheet name is unicode Russian for 'minor page'
 		assertEquals("\u0421\u0442\u0440\u0430\u043D\u0438\u0447\u043A\u0430", bsr.getSheetname());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java Fri Oct 10 15:59:14 2008
@@ -90,7 +90,7 @@
 			(byte)0x03,	(byte)0x00,
 		};
 
-		CFHeaderRecord record = new CFHeaderRecord(new TestcaseRecordInputStream(CFHeaderRecord.sid, (short)recordData.length, recordData));
+		CFHeaderRecord record = new CFHeaderRecord(TestcaseRecordInputStream.create(CFHeaderRecord.sid, recordData));
 
 		assertEquals("#CFRULES", 3, record.getNumberOfConditionalFormats());
 		assertTrue(record.getNeedRecalculation());
@@ -143,7 +143,7 @@
 
 		CFHeaderRecord record;
 		try {
-			record = new CFHeaderRecord(new TestcaseRecordInputStream(CFHeaderRecord.sid, (short)recordData.length, recordData));
+			record = new CFHeaderRecord(TestcaseRecordInputStream.create(CFHeaderRecord.sid, recordData));
 		} catch (IllegalArgumentException e) {
 			if(e.getMessage().equals("invalid cell range (-25536, 2, -15536, 2)")) {
 				throw new AssertionFailedError("Identified bug 44739b");

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java Fri Oct 10 15:59:14 2008
@@ -54,7 +54,7 @@
 		System.arraycopy(serializedRecord, 4, recordData, 0, recordData.length);
 
 		// Deserialize
-		record = new CFRuleRecord(new TestcaseRecordInputStream(CFRuleRecord.sid, (short)recordData.length, recordData));
+		record = new CFRuleRecord(TestcaseRecordInputStream.create(CFRuleRecord.sid, recordData));
 
 		// Serialize again
 		byte[] output = record.serialize();
@@ -317,7 +317,7 @@
 	 */
 	public void testReserializeRefNTokens() {
 		
-		RecordInputStream is = new TestcaseRecordInputStream(CFRuleRecord.sid, DATA_REFN);
+		RecordInputStream is = TestcaseRecordInputStream.create(CFRuleRecord.sid, DATA_REFN);
 		CFRuleRecord rr = new CFRuleRecord(is);
 		Ptg[] ptgs = rr.getParsedExpression1();
 		assertEquals(3, ptgs.length);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCategorySeriesAxisRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCategorySeriesAxisRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCategorySeriesAxisRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCategorySeriesAxisRecord.java Fri Oct 10 15:59:14 2008
@@ -38,7 +38,7 @@
 
     public void testLoad() {
 
-        CategorySeriesAxisRecord record = new CategorySeriesAxisRecord(new TestcaseRecordInputStream((short)0x1020, (short)data.length, data));
+        CategorySeriesAxisRecord record = new CategorySeriesAxisRecord(TestcaseRecordInputStream.create(0x1020, data));
         assertEquals( 1, record.getCrossingPoint());
         assertEquals( 1, record.getLabelFrequency());
         assertEquals( 1, record.getTickMarkFrequency());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestChartRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestChartRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestChartRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestChartRecord.java Fri Oct 10 15:59:14 2008
@@ -38,7 +38,7 @@
 
     public void testLoad() {
 
-        ChartRecord record = new ChartRecord(new TestcaseRecordInputStream((short)0x1002, (short)data.length, data));
+        ChartRecord record = new ChartRecord(TestcaseRecordInputStream.create(0x1002, data));
         assertEquals( 0, record.getX());
         assertEquals( 0, record.getY());
         assertEquals( 30474216, record.getWidth());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java Fri Oct 10 15:59:14 2008
@@ -38,7 +38,7 @@
     };
 
     public void testLoad() {
-        CommonObjectDataSubRecord record = new CommonObjectDataSubRecord(new TestcaseRecordInputStream((short)0x15, (short)data.length, data));
+        CommonObjectDataSubRecord record = new CommonObjectDataSubRecord(TestcaseRecordInputStream.create(0x15, data));
 
         assertEquals( CommonObjectDataSubRecord.OBJECT_TYPE_LIST_BOX, record.getObjectType());
         assertEquals( (short)1, record.getObjectId());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDatRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDatRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDatRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDatRecord.java Fri Oct 10 15:59:14 2008
@@ -35,7 +35,7 @@
 
     public void testLoad() {
 
-        DatRecord record = new DatRecord(new TestcaseRecordInputStream((short)0x1063, (short)data.length, data));
+        DatRecord record = new DatRecord(TestcaseRecordInputStream.create(0x1063, data));
         assertEquals( 0xD, record.getOptions());
         assertEquals( true, record.isHorizontalBorder() );
         assertEquals( false, record.isVerticalBorder() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDataFormatRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDataFormatRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDataFormatRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDataFormatRecord.java Fri Oct 10 15:59:14 2008
@@ -38,7 +38,7 @@
 
     public void testLoad() {
 
-        DataFormatRecord record = new DataFormatRecord(new TestcaseRecordInputStream((short)0x1006, (short)data.length, data));
+        DataFormatRecord record = new DataFormatRecord(TestcaseRecordInputStream.create(0x1006, data));
         assertEquals( (short)0xFFFF, record.getPointNumber());
         assertEquals( 0, record.getSeriesIndex());
         assertEquals( 0, record.getSeriesNumber());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDefaultDataLabelTextPropertiesRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDefaultDataLabelTextPropertiesRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDefaultDataLabelTextPropertiesRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDefaultDataLabelTextPropertiesRecord.java Fri Oct 10 15:59:14 2008
@@ -35,7 +35,7 @@
 
     public void testLoad() {
 
-        DefaultDataLabelTextPropertiesRecord record = new DefaultDataLabelTextPropertiesRecord(new TestcaseRecordInputStream((short)0x1024, (short)data.length, data));
+        DefaultDataLabelTextPropertiesRecord record = new DefaultDataLabelTextPropertiesRecord(TestcaseRecordInputStream.create(0x1024, data));
         assertEquals( 2, record.getCategoryDataType());
 
         assertEquals( 6, record.getRecordSize() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java Fri Oct 10 15:59:14 2008
@@ -127,7 +127,7 @@
 	}
 
 	private static void confirmRead(byte[] data, int i) {
-		RecordInputStream in = new TestcaseRecordInputStream(EmbeddedObjectRefSubRecord.sid, (short)data.length, data);
+		RecordInputStream in = TestcaseRecordInputStream.create(EmbeddedObjectRefSubRecord.sid, data);
 
 		EmbeddedObjectRefSubRecord rec = new EmbeddedObjectRefSubRecord(in);
 		byte[] ser2 = rec.serialize();

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEndSubRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEndSubRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEndSubRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEndSubRecord.java Fri Oct 10 15:59:14 2008
@@ -33,7 +33,7 @@
     };
 
     public void testLoad() {
-        EndSubRecord record = new EndSubRecord(new TestcaseRecordInputStream((short)0x00, (short)data.length, data));
+        EndSubRecord record = new EndSubRecord(TestcaseRecordInputStream.create(0x00, data));
 
         assertEquals( 4, record.getRecordSize() );
     }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java Fri Oct 10 15:59:14 2008
@@ -37,7 +37,7 @@
     };
 
     public void testLoad() {
-        ExtendedFormatRecord record = new ExtendedFormatRecord(new TestcaseRecordInputStream((short)0xe0, (short)data.length, data));
+        ExtendedFormatRecord record = new ExtendedFormatRecord(TestcaseRecordInputStream.create(0xe0, data));
         assertEquals(0, record.getFontIndex());
         assertEquals(0, record.getFormatIndex());
         assertEquals(0xF5-256, record.getCellOptions());
@@ -117,7 +117,7 @@
     }
     
     public void testCloneOnto() throws Exception {
-        ExtendedFormatRecord base = new ExtendedFormatRecord(new TestcaseRecordInputStream((short)0xe0, (short)data.length, data));
+        ExtendedFormatRecord base = new ExtendedFormatRecord(TestcaseRecordInputStream.create(0xe0, data));
     	
     	ExtendedFormatRecord other = new ExtendedFormatRecord();
         other.cloneStyleFrom(base);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java Fri Oct 10 15:59:14 2008
@@ -43,7 +43,7 @@
 	};
 	
 	private static ExternalNameRecord createSimpleENR(byte[] data) {
-		return new ExternalNameRecord(new TestcaseRecordInputStream((short)0x0023, data));
+		return new ExternalNameRecord(TestcaseRecordInputStream.create(0x0023, data));
 	}
 	public void testBasicDeserializeReserialize() {
 		

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontBasisRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontBasisRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontBasisRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontBasisRecord.java Fri Oct 10 15:59:14 2008
@@ -39,7 +39,7 @@
 
     public void testLoad() {
 
-        FontBasisRecord record = new FontBasisRecord(new TestcaseRecordInputStream((short)0x1060, (short)data.length, data));
+        FontBasisRecord record = new FontBasisRecord(TestcaseRecordInputStream.create(0x1060, data));
         assertEquals( 0x1a28, record.getXBasis());
         assertEquals( 0x0f9c, record.getYBasis());
         assertEquals( 0xc8, record.getHeightBasis());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontIndexRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontIndexRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontIndexRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontIndexRecord.java Fri Oct 10 15:59:14 2008
@@ -35,7 +35,7 @@
 
     public void testLoad() {
 
-        FontIndexRecord record = new FontIndexRecord(new TestcaseRecordInputStream((short)0x1026, (short)data.length, data));
+        FontIndexRecord record = new FontIndexRecord(TestcaseRecordInputStream.create(0x1026, data));
         assertEquals( 5, record.getFontIndex());
 
         assertEquals( 6, record.getRecordSize() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontRecord.java Fri Oct 10 15:59:14 2008
@@ -44,7 +44,7 @@
 
     public void testLoad() {
 
-        FontRecord record = new FontRecord(new TestcaseRecordInputStream((short)0x31, (short)data.length, data));
+        FontRecord record = new FontRecord(TestcaseRecordInputStream.create(0x31, data));
         assertEquals( 0xc8, record.getFontHeight());
         assertEquals( 0x00, record.getAttributes());
         assertFalse( record.isItalic());
@@ -100,7 +100,7 @@
     }
     
     public void testCloneOnto() throws Exception {
-        FontRecord base = new FontRecord(new TestcaseRecordInputStream((short)0x31, (short)data.length, data));
+        FontRecord base = new FontRecord(TestcaseRecordInputStream.create(0x31, data));
     	
         FontRecord other = new FontRecord();
         other.cloneStyleFrom(base);
@@ -112,8 +112,8 @@
     }
     
     public void testSameProperties() throws Exception {
-        FontRecord f1 = new FontRecord(new TestcaseRecordInputStream((short)0x31, (short)data.length, data));
-        FontRecord f2 = new FontRecord(new TestcaseRecordInputStream((short)0x31, (short)data.length, data));
+        FontRecord f1 = new FontRecord(TestcaseRecordInputStream.create(0x31, data));
+        FontRecord f2 = new FontRecord(TestcaseRecordInputStream.create(0x31, data));
     	
         assertTrue(f1.sameProperties(f2));
         

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java Fri Oct 10 15:59:14 2008
@@ -82,7 +82,7 @@
 
 		};
 
-		FormulaRecord record = new FormulaRecord(new TestcaseRecordInputStream(FormulaRecord.sid, (short)29, formulaByte));
+		FormulaRecord record = new FormulaRecord(TestcaseRecordInputStream.create(FormulaRecord.sid, formulaByte));
 		assertEquals("Row", 0, record.getRow());
 		assertEquals("Column", 0, record.getColumn());
 		assertEquals(HSSFCell.CELL_TYPE_ERROR, record.getCachedResultType());
@@ -108,7 +108,7 @@
 		formulaByte[19]=(byte)0xFD;
 		formulaByte[20]=(byte)0x05;
 		formulaByte[22]=(byte)0x01;
-		FormulaRecord record = new FormulaRecord(new TestcaseRecordInputStream(FormulaRecord.sid, (short)27, formulaByte));
+		FormulaRecord record = new FormulaRecord(TestcaseRecordInputStream.create(FormulaRecord.sid, formulaByte));
 		assertEquals("Row", 0, record.getRow());
 		assertEquals("Column", 0, record.getColumn());
 		byte[] output = record.serialize();

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFrameRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFrameRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFrameRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFrameRecord.java Fri Oct 10 15:59:14 2008
@@ -36,7 +36,7 @@
 
     public void testLoad() {
 
-        FrameRecord record = new FrameRecord(new TestcaseRecordInputStream((short)0x1032, (short)data.length, data));
+        FrameRecord record = new FrameRecord(TestcaseRecordInputStream.create(0x1032, data));
         assertEquals( FrameRecord.BORDER_TYPE_REGULAR, record.getBorderType());
         assertEquals( 2, record.getOptions());
         assertEquals( false, record.isAutoSize() );

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java Fri Oct 10 15:59:14 2008
@@ -17,7 +17,6 @@
 package org.apache.poi.hssf.record;
 
 import java.io.ByteArrayInputStream;
-import java.net.URL;
 import java.util.Arrays;
 
 import junit.framework.TestCase;
@@ -28,7 +27,7 @@
  * @author Nick Burch
  * @author Yegor Kozlov
  */
-public class TestHyperlinkRecord extends TestCase {
+public final class TestHyperlinkRecord extends TestCase {
 
     //link to http://www.lakings.com/
     byte[] data1 = { 0x02, 0x00,    //First row of the hyperlink
@@ -165,7 +164,7 @@
                     0x00, 0x41, 0x00, 0x31, 0x00, 0x00, 0x00};
 
     public void testReadURLLink(){
-        RecordInputStream is = new TestcaseRecordInputStream((short)HyperlinkRecord.sid, (short)data1.length, data1);
+        RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid, data1);
         HyperlinkRecord link = new HyperlinkRecord(is);
         assertEquals(2, link.getFirstRow());
         assertEquals(2, link.getLastRow());
@@ -184,7 +183,7 @@
     }
 
     public void testReadFileLink(){
-        RecordInputStream is = new TestcaseRecordInputStream((short)HyperlinkRecord.sid, (short)data2.length, data2);
+        RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid, data2);
         HyperlinkRecord link = new HyperlinkRecord(is);
         assertEquals(0, link.getFirstRow());
         assertEquals(0, link.getLastRow());
@@ -202,7 +201,7 @@
     }
 
     public void testReadEmailLink(){
-        RecordInputStream is = new TestcaseRecordInputStream((short)HyperlinkRecord.sid, (short)data3.length, data3);
+        RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid, data3);
         HyperlinkRecord link = new HyperlinkRecord(is);
         assertEquals(1, link.getFirstRow());
         assertEquals(1, link.getLastRow());
@@ -220,7 +219,7 @@
     }
 
     public void testReadDocumentLink(){
-        RecordInputStream is = new TestcaseRecordInputStream((short)HyperlinkRecord.sid, (short)data4.length, data4);
+        RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid, data4);
         HyperlinkRecord link = new HyperlinkRecord(is);
         assertEquals(3, link.getFirstRow());
         assertEquals(3, link.getLastRow());
@@ -237,7 +236,7 @@
     }
 
     private void serialize(byte[] data){
-        RecordInputStream is = new TestcaseRecordInputStream((short)HyperlinkRecord.sid, (short)data.length, data);
+        RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid, data);
         HyperlinkRecord link = new HyperlinkRecord(is);
         byte[] bytes1 = link.serialize();
         is = new RecordInputStream(new ByteArrayInputStream(bytes1));
@@ -318,7 +317,7 @@
     public void testClone() throws Exception {
         byte[][] data = {data1, data2, data3, data4};
         for (int i = 0; i < data.length; i++) {
-            RecordInputStream is = new TestcaseRecordInputStream((short)HyperlinkRecord.sid, (short)data[i].length, data[i]);
+            RecordInputStream is = TestcaseRecordInputStream.create(HyperlinkRecord.sid, data[i]);
             HyperlinkRecord link = new HyperlinkRecord(is);
             HyperlinkRecord clone = (HyperlinkRecord)link.clone();
             assertTrue(Arrays.equals(link.serialize(), clone.serialize()));

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLegendRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLegendRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLegendRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLegendRecord.java Fri Oct 10 15:59:14 2008
@@ -17,80 +17,73 @@
 
 package org.apache.poi.hssf.record;
 
-
 import junit.framework.TestCase;
 
 /**
- * Tests the serialization and deserialization of the LegendRecord
- * class works correctly.  Test data taken directly from a real
- * Excel file.
- *
-
+ * Tests the serialization and deserialization of the LegendRecord class works
+ * correctly. Test data taken directly from a real Excel file.
+ * 
+ * 
  * @author Andrew C. Oliver (acoliver at apache.org)
  */
-public class TestLegendRecord extends TestCase {
-    byte[] data = new byte[] {
-	(byte)0x76,(byte)0x0E,(byte)0x00,(byte)0x00,(byte)0x86,(byte)0x07,(byte)0x00,(byte)0x00,(byte)0x19,(byte)0x01,(byte)0x00,(byte)0x00,(byte)0x8B,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x03,(byte)0x01,(byte)0x1F,(byte)0x00
-    };
-
-    public void testLoad() {
-        LegendRecord record = new LegendRecord(new TestcaseRecordInputStream((short)0x1015, (short)data.length, data));
-        
-
-        assertEquals( (int)0xe76, record.getXAxisUpperLeft());
-
-        assertEquals( (int)0x786, record.getYAxisUpperLeft());
-
-        assertEquals( (int)0x119, record.getXSize());
+public final class TestLegendRecord extends TestCase {
+	byte[] data = new byte[] { (byte) 0x76, (byte) 0x0E, (byte) 0x00, (byte) 0x00, (byte) 0x86,
+			(byte) 0x07, (byte) 0x00, (byte) 0x00, (byte) 0x19, (byte) 0x01, (byte) 0x00,
+			(byte) 0x00, (byte) 0x8B, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03,
+			(byte) 0x01, (byte) 0x1F, (byte) 0x00 };
 
-        assertEquals( (int)0x8b, record.getYSize());
+	public void testLoad() {
+		LegendRecord record = new LegendRecord(TestcaseRecordInputStream.create(0x1015, data));
 
-        assertEquals( (byte)0x3, record.getType());
+		assertEquals(0xe76, record.getXAxisUpperLeft());
 
-        assertEquals( (byte)0x1, record.getSpacing());
+		assertEquals(0x786, record.getYAxisUpperLeft());
 
-        assertEquals( (short)0x1f, record.getOptions());
-        assertEquals( true, record.isAutoPosition() );
-        assertEquals( true, record.isAutoSeries() );
-        assertEquals( true, record.isAutoXPositioning() );
-        assertEquals( true, record.isAutoYPositioning() );
-        assertEquals( true, record.isVertical() );
-        assertEquals( false, record.isDataTable() );
+		assertEquals(0x119, record.getXSize());
 
+		assertEquals(0x8b, record.getYSize());
 
-        assertEquals( 24, record.getRecordSize() );
-    }
+		assertEquals((byte) 0x3, record.getType());
 
-    public void testStore()
-    {
-        LegendRecord record = new LegendRecord();
+		assertEquals((byte) 0x1, record.getSpacing());
 
+		assertEquals((short) 0x1f, record.getOptions());
+		assertEquals(true, record.isAutoPosition());
+		assertEquals(true, record.isAutoSeries());
+		assertEquals(true, record.isAutoXPositioning());
+		assertEquals(true, record.isAutoYPositioning());
+		assertEquals(true, record.isVertical());
+		assertEquals(false, record.isDataTable());
 
+		assertEquals(24, record.getRecordSize());
+	}
 
-        record.setXAxisUpperLeft( (int)0xe76 );
+	public void testStore() {
+		LegendRecord record = new LegendRecord();
 
-        record.setYAxisUpperLeft( (int)0x786 );
+		record.setXAxisUpperLeft(0xe76);
 
-        record.setXSize( (int)0x119 );
+		record.setYAxisUpperLeft(0x786);
 
-        record.setYSize( (int)0x8b );
+		record.setXSize(0x119);
 
-        record.setType( (byte)0x3 );
+		record.setYSize(0x8b);
 
-        record.setSpacing( (byte)0x1 );
+		record.setType((byte) 0x3);
 
-        record.setOptions( (short)0x1f );
-        record.setAutoPosition( true );
-        record.setAutoSeries( true );
-        record.setAutoXPositioning( true );
-        record.setAutoYPositioning( true );
-        record.setVertical( true );
-        record.setDataTable( false );
+		record.setSpacing((byte) 0x1);
 
+		record.setOptions((short) 0x1f);
+		record.setAutoPosition(true);
+		record.setAutoSeries(true);
+		record.setAutoXPositioning(true);
+		record.setAutoYPositioning(true);
+		record.setVertical(true);
+		record.setDataTable(false);
 
-        byte [] recordBytes = record.serialize();
-        assertEquals(recordBytes.length - 4, data.length);
-        for (int i = 0; i < data.length; i++)
-            assertEquals("At offset " + i, data[i], recordBytes[i+4]);
-    }
+		byte[] recordBytes = record.serialize();
+		assertEquals(recordBytes.length - 4, data.length);
+		for (int i = 0; i < data.length; i++)
+			assertEquals("At offset " + i, data[i], recordBytes[i + 4]);
+	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLineFormatRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLineFormatRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLineFormatRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLineFormatRecord.java Fri Oct 10 15:59:14 2008
@@ -28,7 +28,7 @@
 
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class TestLineFormatRecord extends TestCase {
+public final class TestLineFormatRecord extends TestCase {
     byte[] data = new byte[] {
         (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,    // colour
         (byte)0x00,(byte)0x00,                          // pattern
@@ -38,7 +38,7 @@
     };
 
     public void testLoad() {
-        LineFormatRecord record = new LineFormatRecord(new TestcaseRecordInputStream((short)0x1007, (short)data.length, data));
+        LineFormatRecord record = new LineFormatRecord(TestcaseRecordInputStream.create(0x1007, data));
         assertEquals( 0, record.getLineColor());
         assertEquals( 0, record.getLinePattern());
         assertEquals( 0, record.getWeight());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLinkedDataRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLinkedDataRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLinkedDataRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLinkedDataRecord.java Fri Oct 10 15:59:14 2008
@@ -157,7 +157,7 @@
 
     public void testLoad() {
 
-        LinkedDataRecord record = new LinkedDataRecord(new TestcaseRecordInputStream((short)0x1051, (short)data.length, data));
+        LinkedDataRecord record = new LinkedDataRecord(TestcaseRecordInputStream.create(0x1051, data));
         assertEquals( LinkedDataRecord.LINK_TYPE_VALUES, record.getLinkType());
         assertEquals( LinkedDataRecord.REFERENCE_TYPE_WORKSHEET, record.getReferenceType());
         assertEquals( 0, record.getOptions());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNameRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNameRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNameRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNameRecord.java Fri Oct 10 15:59:14 2008
@@ -1,4 +1,3 @@
-        
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -25,9 +24,7 @@
  *
  * @author Danny Mui (dmui at apache dot org)
  */
-public class TestNameRecord
-        extends TestCase
-{
+public final class TestNameRecord extends TestCase {
 
     /**
      * Makes sure that additional name information is parsed properly such as menu/description
@@ -55,13 +52,11 @@
         };
 
 
-        NameRecord name = new NameRecord(new TestcaseRecordInputStream(NameRecord.sid, (short) examples.length, examples));
+        NameRecord name = new NameRecord(TestcaseRecordInputStream.create(NameRecord.sid, examples));
         String description = name.getDescriptionText();
         assertNotNull( description );
         assertTrue( "text contains ALLWOR", description.indexOf( "ALLWOR" ) > 0 );
-
     }
-
 }
 
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java Fri Oct 10 15:59:14 2008
@@ -29,9 +29,7 @@
  *
  * @author Yegor Kozlov
  */
-public class TestNoteRecord
-        extends TestCase
-{
+public final class TestNoteRecord extends TestCase {
     private byte[] data = new byte[] {
         0x06, 0x00, 0x01, 0x00, 0x02, 0x00, 0x02, 0x04, 0x1A, 0x00,
         0x00, 0x41, 0x70, 0x61, 0x63, 0x68, 0x65, 0x20, 0x53, 0x6F,
@@ -41,7 +39,7 @@
 
     public void testRead() {
 
-        NoteRecord record = new NoteRecord(new TestcaseRecordInputStream(NoteRecord.sid, (short)data.length, data));
+        NoteRecord record = new NoteRecord(TestcaseRecordInputStream.create(NoteRecord.sid, data));
 
         assertEquals(NoteRecord.sid, record.getSid());
         assertEquals(6, record.getRow());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java Fri Oct 10 15:59:14 2008
@@ -38,7 +38,7 @@
 
     public void testRead() {
 
-        NoteStructureSubRecord record = new NoteStructureSubRecord(new TestcaseRecordInputStream(NoteStructureSubRecord.sid, (short)data.length, data));
+        NoteStructureSubRecord record = new NoteStructureSubRecord(TestcaseRecordInputStream.create(NoteStructureSubRecord.sid, data));
 
         assertEquals(NoteStructureSubRecord.sid, record.getSid());
         assertEquals(data.length + 4, record.getRecordSize());

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNumberFormatIndexRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNumberFormatIndexRecord.java?rev=703596&r1=703595&r2=703596&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNumberFormatIndexRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestNumberFormatIndexRecord.java Fri Oct 10 15:59:14 2008
@@ -35,7 +35,7 @@
 
     public void testLoad() {
 
-        NumberFormatIndexRecord record = new NumberFormatIndexRecord(new TestcaseRecordInputStream((short)0x104e, (short)data.length, data));
+        NumberFormatIndexRecord record = new NumberFormatIndexRecord(TestcaseRecordInputStream.create(0x104e, data));
         assertEquals( 5, record.getFormatIndex());
 
         assertEquals( 6, record.getRecordSize() );



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message