1 2 17 18 package org.apache.poi.ddf; 19 20 import org.apache.poi.util.HexDump; 21 import org.apache.poi.util.LittleEndian; 22 23 import java.io.ByteArrayOutputStream ; 24 25 31 public class EscherClientDataRecord 32 extends EscherRecord 33 { 34 public static final short RECORD_ID = (short) 0xF011; 35 public static final String RECORD_DESCRIPTION = "MsofbtClientData"; 36 37 private byte[] remainingData; 38 39 47 public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory ) 48 { 49 int bytesRemaining = readHeader( data, offset ); 50 int pos = offset + 8; 51 remainingData = new byte[bytesRemaining]; 52 System.arraycopy( data, pos, remainingData, 0, bytesRemaining ); 53 return 8 + bytesRemaining; 54 } 55 56 65 public int serialize( int offset, byte[] data, EscherSerializationListener listener ) 66 { 67 listener.beforeRecordSerialize( offset, getRecordId(), this ); 68 69 if (remainingData == null) remainingData = new byte[0]; 70 LittleEndian.putShort( data, offset, getOptions() ); 71 LittleEndian.putShort( data, offset + 2, getRecordId() ); 72 LittleEndian.putInt( data, offset + 4, remainingData.length ); 73 System.arraycopy( remainingData, 0, data, offset + 8, remainingData.length ); 74 int pos = offset + 8 + remainingData.length; 75 76 listener.afterRecordSerialize( pos, getRecordId(), pos - offset, this ); 77 return pos - offset; 78 } 79 80 85 public int getRecordSize() 86 { 87 return 8 + (remainingData == null ? 0 : remainingData.length); 88 } 89 90 93 public short getRecordId() 94 { 95 return RECORD_ID; 96 } 97 98 101 public String getRecordName() 102 { 103 return "ClientData"; 104 } 105 106 109 public String toString() 110 { 111 String nl = System.getProperty("line.separator"); 112 113 String extraData; 114 ByteArrayOutputStream b = new ByteArrayOutputStream (); 115 try 116 { 117 HexDump.dump(this.remainingData, 0, b, 0); 118 extraData = b.toString(); 119 } 120 catch ( Exception e ) 121 { 122 extraData = "error"; 123 } 124 return getClass().getName() + ":" + nl + 125 " RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl + 126 " Options: 0x" + HexDump.toHex(getOptions()) + nl + 127 " Extra Data:" + nl + 128 extraData; 129 130 } 131 132 135 public byte[] getRemainingData() 136 { 137 return remainingData; 138 } 139 140 143 public void setRemainingData( byte[] remainingData ) 144 { 145 this.remainingData = remainingData; 146 } 147 } 148 | Popular Tags |