1 16 17 package org.apache.poi.hssf.record; 18 19 import org.apache.poi.util.*; 20 21 27 public class TopMarginRecord extends Record implements Margin 28 { 29 public final static short sid = 0x28; 30 private double field_1_margin; 31 32 public TopMarginRecord() { } 33 34 42 public TopMarginRecord( short id, short size, byte[] data ) 43 { super( id, size, data ); } 44 45 54 public TopMarginRecord( short id, short size, byte[] data, int offset ) 55 { super( id, size, data, offset ); } 56 57 62 protected void validateSid( short id ) 63 { 64 if ( id != sid ) 65 { 66 throw new RecordFormatException( "Not a TopMargin record" ); 67 } 68 } 69 70 protected void fillFields( byte[] data, short size, int offset ) 71 { 72 field_1_margin = LittleEndian.getDouble( data, 0x0 + offset ); 73 } 74 75 public String toString() 76 { 77 StringBuffer buffer = new StringBuffer (); 78 buffer.append( "[TopMargin]\n" ); 79 buffer.append( " .margin = " ).append( " (" ).append( getMargin() ).append( " )\n" ); 80 buffer.append( "[/TopMargin]\n" ); 81 return buffer.toString(); 82 } 83 84 public int serialize( int offset, byte[] data ) 85 { 86 LittleEndian.putShort( data, 0 + offset, sid ); 87 LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) ); 88 LittleEndian.putDouble( data, 4 + offset, field_1_margin ); 89 return getRecordSize(); 90 } 91 92 95 public int getRecordSize() { return 4 + 8; } 96 97 public short getSid() { return this.sid; } 98 99 102 public double getMargin() { return field_1_margin; } 103 104 107 public void setMargin( double field_1_margin ) 108 { this.field_1_margin = field_1_margin; } 109 110 public Object clone() 111 { 112 TopMarginRecord rec = new TopMarginRecord(); 113 rec.field_1_margin = this.field_1_margin; 114 return rec; 115 } 116 } | Popular Tags |