1 16 17 package org.apache.poi.hssf.record.formula; 18 19 import org.apache.poi.util.LittleEndian; 20 import org.apache.poi.hssf.model.Workbook; 21 28 29 public class NumberPtg 30 extends Ptg 31 { 32 public final static int SIZE = 9; 33 public final static byte sid = 0x1f; 34 private double field_1_value; 35 36 private NumberPtg() { 37 } 39 40 41 public NumberPtg(byte [] data, int offset) 42 { 43 setValue(LittleEndian.getDouble(data, offset + 1)); 44 } 45 46 51 public NumberPtg(String value) { 52 setValue(Double.parseDouble(value)); 53 } 54 55 56 public void setValue(double value) 57 { 58 field_1_value = value; 59 } 60 61 62 public double getValue() 63 { 64 return field_1_value; 65 } 66 67 public void writeBytes(byte [] array, int offset) 68 { 69 array[ offset + 0 ] = sid; 70 LittleEndian.putDouble(array, offset + 1, getValue()); 71 } 72 73 public int getSize() 74 { 75 return SIZE; 76 } 77 78 public String toFormulaString(Workbook book) 79 { 80 return "" + getValue(); 81 } 82 public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;} 83 84 public Object clone() { 85 NumberPtg ptg = new NumberPtg(); 86 ptg.field_1_value = field_1_value; 87 return ptg; 88 } 89 } 90 | Popular Tags |