1 2 17 18 package org.apache.poi.hwpf.model; 19 20 import java.io.IOException ; 21 22 import org.apache.poi.util.LittleEndian; 23 24 import org.apache.poi.hwpf.model.io.HWPFOutputStream; 25 26 class FIBShortHandler 27 { 28 public final static int MAGICCREATED = 0; 29 public final static int MAGICREVISED = 1; 30 public final static int MAGICCREATEDPRIVATE = 2; 31 public final static int MAGICREVISEDPRIVATE = 3; 32 public final static int LIDFE = 13; 33 34 final static int START = 0x20; 35 36 short[] _shorts; 37 38 public FIBShortHandler(byte[] mainStream) 39 { 40 int offset = START; 41 int shortCount = LittleEndian.getShort(mainStream, offset); 42 offset += LittleEndian.SHORT_SIZE; 43 _shorts = new short[shortCount]; 44 45 for (int x = 0; x < shortCount; x++) 46 { 47 _shorts[x] = LittleEndian.getShort(mainStream, offset); 48 offset += LittleEndian.SHORT_SIZE; 49 } 50 } 51 52 public short getShort(int shortCode) 53 { 54 return _shorts[shortCode]; 55 } 56 57 int sizeInBytes() 58 { 59 return (_shorts.length * LittleEndian.SHORT_SIZE) + LittleEndian.SHORT_SIZE; 60 } 61 62 void serialize(byte[] mainStream) 63 throws IOException 64 { 65 int offset = START; 66 LittleEndian.putShort(mainStream, offset, (short)_shorts.length); 67 offset += LittleEndian.SHORT_SIZE; 68 70 for (int x = 0; x < _shorts.length; x++) 71 { 72 LittleEndian.putShort(mainStream, offset, _shorts[x]); 73 offset += LittleEndian.SHORT_SIZE; 74 } 75 } 76 77 78 } 79 | Popular Tags |