1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 24 abstract public class SubRecord 25 extends Record 26 { 27 public SubRecord() 28 { 29 } 30 31 public SubRecord( short id, short size, byte[] data ) 32 { 33 super( id, size, data ); 34 } 35 36 public SubRecord( short id, short size, byte[] data, int offset ) 37 { 38 super( id, size, data, offset ); 39 } 40 41 public static Record createSubRecord( short subRecordSid, short size, byte[] data, int offset ) 42 { 43 Record r = null; 44 45 short adjustedSize = size; 46 if ( size < 0 ) 47 { 48 adjustedSize = 0; 49 } 50 else if ( offset + size > data.length ) 51 { 52 adjustedSize = (short) ( data.length - offset ); 53 if ( adjustedSize > 4 ) 54 { 55 adjustedSize -= 4; 56 } 57 } 58 59 switch ( subRecordSid ) 60 { 61 case CommonObjectDataSubRecord.sid: 62 r = new CommonObjectDataSubRecord( subRecordSid, adjustedSize, data, offset ); 63 break; 64 case GroupMarkerSubRecord.sid: 65 r = new GroupMarkerSubRecord( subRecordSid, adjustedSize, data, offset ); 66 break; 67 case EndSubRecord.sid: 68 r = new EndSubRecord( subRecordSid, adjustedSize, data, offset ); 69 break; 70 default: 71 r = new UnknownRecord( subRecordSid, adjustedSize, data, offset ); 72 } 73 74 return r; 75 } 76 } 77 | Popular Tags |