1 2 17 18 19 package org.apache.poi.hwpf.model; 20 21 import org.apache.poi.util.LittleEndian; 22 23 import java.util.Arrays ; 24 25 public class ListFormatOverride 26 { 27 int _lsid; 28 int _reserved1; 29 int _reserved2; 30 byte _clfolvl; 31 byte[] _reserved3 = new byte[3]; 32 ListFormatOverrideLevel[] _levelOverrides; 33 34 public ListFormatOverride(int lsid) 35 { 36 _lsid = lsid; 37 _levelOverrides = new ListFormatOverrideLevel[0]; 38 } 39 40 public ListFormatOverride(byte[] buf, int offset) 41 { 42 _lsid = LittleEndian.getInt(buf, offset); 43 offset += LittleEndian.INT_SIZE; 44 _reserved1 = LittleEndian.getInt(buf, offset); 45 offset += LittleEndian.INT_SIZE; 46 _reserved2 = LittleEndian.getInt(buf, offset); 47 offset += LittleEndian.INT_SIZE; 48 _clfolvl = buf[offset++]; 49 System.arraycopy(buf, offset, _reserved3, 0, _reserved3.length); 50 _levelOverrides = new ListFormatOverrideLevel[_clfolvl]; 51 } 52 53 public int numOverrides() 54 { 55 return _clfolvl; 56 } 57 58 public int getLsid() 59 { 60 return _lsid; 61 } 62 63 void setLsid(int lsid) 64 { 65 _lsid = lsid; 66 } 67 68 public ListFormatOverrideLevel[] getLevelOverrides() 69 { 70 return _levelOverrides; 71 } 72 73 public void setOverride(int index, ListFormatOverrideLevel lfolvl) 74 { 75 _levelOverrides[index] = lfolvl; 76 } 77 78 public ListFormatOverrideLevel getOverrideLevel(int level) 79 { 80 81 ListFormatOverrideLevel retLevel = null; 82 83 for(int x = 0; x < _levelOverrides.length; x++) 84 { 85 if (_levelOverrides[x].getLevelNum() == level) 86 { 87 retLevel = _levelOverrides[x]; 88 } 89 } 90 return retLevel; 91 } 92 93 public boolean equals(Object obj) 94 { 95 if (obj == null) 96 { 97 return false; 98 } 99 100 ListFormatOverride lfo = (ListFormatOverride)obj; 101 return lfo._clfolvl == _clfolvl && lfo._lsid == _lsid && 102 lfo._reserved1 == _reserved1 && lfo._reserved2 == _reserved2 && 103 Arrays.equals(lfo._reserved3, _reserved3) && 104 Arrays.equals(lfo._levelOverrides, _levelOverrides); 105 } 106 107 public byte[] toByteArray() 108 { 109 byte[] buf = new byte[16]; 110 int offset = 0; 111 LittleEndian.putInt(buf, offset, _lsid); 112 offset += LittleEndian.INT_SIZE; 113 LittleEndian.putInt(buf, offset, _reserved1); 114 offset += LittleEndian.INT_SIZE; 115 LittleEndian.putInt(buf, offset, _reserved2); 116 offset += LittleEndian.INT_SIZE; 117 buf[offset++] = _clfolvl; 118 System.arraycopy(_reserved3, 0, buf, offset, 3); 119 120 return buf; 121 } 122 } 123 | Popular Tags |