1 16 17 18 package org.apache.poi.hssf.record.aggregates; 19 20 import org.apache.poi.hssf.record.*; 21 22 28 public class FormulaRecordAggregate 29 extends Record 30 implements CellValueRecordInterface, Comparable 31 { 32 public final static short sid = -2000; 33 34 private FormulaRecord formulaRecord; 35 private StringRecord stringRecord; 36 37 40 private SharedFormulaRecord sharedFormulaRecord; 41 42 public FormulaRecordAggregate( FormulaRecord formulaRecord, StringRecord stringRecord ) 43 { 44 this.formulaRecord = formulaRecord; 45 this.stringRecord = stringRecord; 46 } 47 48 54 public FormulaRecordAggregate( FormulaRecord formulaRecord, StringRecord stringRecord, SharedFormulaRecord sharedRecord) 55 { 56 this.formulaRecord = formulaRecord; 57 this.stringRecord = stringRecord; 58 this.sharedFormulaRecord = sharedRecord; 59 } 60 61 62 63 protected void validateSid( short id ) 64 { 65 } 66 67 protected void fillFields( byte[] data, short size, int offset ) 68 { 69 } 70 71 80 81 public int serialize( int offset, byte[] data ) 82 { 83 int pos = offset; 84 pos += formulaRecord.serialize(pos, data); 85 if (this.getSharedFormulaRecord() != null) 86 { 87 pos += getSharedFormulaRecord().serialize(pos, data); 88 } 89 if (stringRecord != null) 90 { 91 pos += stringRecord.serialize(pos, data); 92 } 93 return pos - offset; 94 95 } 96 97 100 public int getRecordSize() 101 { 102 int size = formulaRecord.getRecordSize() + (stringRecord == null ? 0 : stringRecord.getRecordSize()); 103 size += (getSharedFormulaRecord() == null) ? 0 : getSharedFormulaRecord().getRecordSize(); 104 return size; 105 } 106 107 108 111 public short getSid() 112 { 113 return sid; 114 } 115 116 public void setStringRecord( StringRecord stringRecord ) 117 { 118 this.stringRecord = stringRecord; 119 } 120 121 public void setFormulaRecord( FormulaRecord formulaRecord ) 122 { 123 this.formulaRecord = formulaRecord; 124 } 125 126 public FormulaRecord getFormulaRecord() 127 { 128 return formulaRecord; 129 } 130 131 public StringRecord getStringRecord() 132 { 133 return stringRecord; 134 } 135 136 public boolean isEqual(CellValueRecordInterface i) 137 { 138 return formulaRecord.isEqual( i ); 139 } 140 141 public boolean isAfter(CellValueRecordInterface i) 142 { 143 return formulaRecord.isAfter( i ); 144 } 145 146 public boolean isBefore(CellValueRecordInterface i) 147 { 148 return formulaRecord.isBefore( i ); 149 } 150 151 public short getXFIndex() 152 { 153 return formulaRecord.getXFIndex(); 154 } 155 156 public void setXFIndex(short xf) 157 { 158 formulaRecord.setXFIndex( xf ); 159 } 160 161 public void setColumn(short col) 162 { 163 formulaRecord.setColumn( col ); 164 } 165 166 public void setRow(int row) 167 { 168 formulaRecord.setRow( row ); 169 } 170 171 public short getColumn() 172 { 173 return formulaRecord.getColumn(); 174 } 175 176 public int getRow() 177 { 178 return formulaRecord.getRow(); 179 } 180 181 public int compareTo(Object o) 182 { 183 return formulaRecord.compareTo( o ); 184 } 185 186 public boolean equals(Object obj) 187 { 188 return formulaRecord.equals( obj ); 189 } 190 191 public String toString() 192 { 193 return formulaRecord.toString(); 194 } 195 196 199 public Object clone() { 200 StringRecord clonedString = (stringRecord == null) ? null : (StringRecord)stringRecord.clone(); 201 SharedFormulaRecord clonedShared = (sharedFormulaRecord == null) ? null : (SharedFormulaRecord)sharedFormulaRecord.clone(); 202 203 return new FormulaRecordAggregate((FormulaRecord) this.formulaRecord.clone(), clonedString, clonedShared); 204 } 205 206 207 208 211 public SharedFormulaRecord getSharedFormulaRecord() { 212 return sharedFormulaRecord; 213 } 214 215 219 public void setSharedFormulaRecord(SharedFormulaRecord sharedFormulaRecord) { 220 this.sharedFormulaRecord = sharedFormulaRecord; 221 } 222 223 228 public boolean isInValueSection() { 229 230 return true; 231 } 232 233 public String getStringValue() { 234 if(stringRecord==null) return null; 235 return stringRecord.getString(); 236 } 237 238 } 239 | Popular Tags |