1 19 20 package jxl.biff.formula; 21 22 import java.util.Stack ; 23 24 import jxl.biff.IntegerHelper; 25 26 29 abstract class BinaryOperator extends Operator implements ParsedThing 30 { 31 34 public BinaryOperator() 35 { 36 } 37 38 45 public int read(byte[] data, int pos) 46 { 47 return 0; 48 } 49 50 53 public void getOperands(Stack s) 54 { 55 ParseItem o1 = (ParseItem) s.pop(); 56 ParseItem o2 = (ParseItem) s.pop(); 57 58 add(o1); 59 add(o2); 60 } 61 62 67 public void getString(StringBuffer buf) 68 { 69 ParseItem[] operands = getOperands(); 70 operands[1].getString(buf); 71 buf.append(getSymbol()); 72 operands[0].getString(buf); 73 } 74 75 82 public void adjustRelativeCellReferences(int colAdjust, int rowAdjust) 83 { 84 ParseItem[] operands = getOperands(); 85 operands[1].adjustRelativeCellReferences(colAdjust, rowAdjust); 86 operands[0].adjustRelativeCellReferences(colAdjust, rowAdjust); 87 } 88 89 99 void columnInserted(int sheetIndex, int col, boolean currentSheet) 100 { 101 ParseItem[] operands = getOperands(); 102 operands[1].columnInserted(sheetIndex, col, currentSheet); 103 operands[0].columnInserted(sheetIndex, col, currentSheet); 104 } 105 106 116 void columnRemoved(int sheetIndex, int col, boolean currentSheet) 117 { 118 ParseItem[] operands = getOperands(); 119 operands[1].columnRemoved(sheetIndex, col, currentSheet); 120 operands[0].columnRemoved(sheetIndex, col, currentSheet); 121 } 122 123 133 void rowInserted(int sheetIndex, int row, boolean currentSheet) 134 { 135 ParseItem[] operands = getOperands(); 136 operands[1].rowInserted(sheetIndex, row, currentSheet); 137 operands[0].rowInserted(sheetIndex, row, currentSheet); 138 } 139 140 150 void rowRemoved(int sheetIndex, int row, boolean currentSheet) 151 { 152 ParseItem[] operands = getOperands(); 153 operands[1].rowRemoved(sheetIndex, row, currentSheet); 154 operands[0].rowRemoved(sheetIndex, row, currentSheet); 155 } 156 157 162 byte[] getBytes() 163 { 164 ParseItem[] operands = getOperands(); 166 byte[] data = new byte[0]; 167 168 for (int i = operands.length - 1 ; i >= 0 ; i--) 170 { 171 byte[] opdata = operands[i].getBytes(); 172 173 byte[] newdata = new byte[data.length + opdata.length]; 175 System.arraycopy(data, 0, newdata, 0, data.length); 176 System.arraycopy(opdata, 0, newdata, data.length, opdata.length); 177 data = newdata; 178 } 179 180 byte[] newdata = new byte[data.length + 1]; 182 System.arraycopy(data, 0, newdata, 0, data.length); 183 newdata[data.length] = getToken().getCode(); 184 185 return newdata; 186 } 187 188 193 abstract String getSymbol(); 194 195 200 abstract Token getToken(); 201 202 } 203 204 205 206 207 208 | Popular Tags |