1 19 20 package jxl.biff.formula; 21 22 import common.Logger; 23 24 import jxl.Cell; 25 import jxl.biff.IntegerHelper; 26 27 30 class IntegerValue extends NumberValue implements ParsedThing 31 { 32 35 private static Logger logger = Logger.getLogger(IntegerValue.class); 36 37 40 private double value; 41 42 45 private boolean outOfRange; 46 47 50 public IntegerValue() 51 { 52 outOfRange = false; 53 } 54 55 58 public IntegerValue(String s) 59 { 60 try 61 { 62 value = Integer.parseInt(s); 63 } 64 catch (NumberFormatException e) 65 { 66 logger.warn(e, e); 67 value = 0; 68 } 69 70 short v = (short) value; 71 outOfRange = (value != v); 72 } 73 74 81 public int read(byte[] data, int pos) 82 { 83 value = IntegerHelper.getInt(data[pos], data[pos+1]); 84 85 return 2; 86 } 87 88 93 byte[] getBytes() 94 { 95 byte[] data = new byte[3]; 96 data[0] = Token.INTEGER.getCode(); 97 98 IntegerHelper.getTwoBytes((int) value, data, 1); 99 100 return data; 101 } 102 103 108 public double getValue() 109 { 110 return value; 111 } 112 113 118 boolean isOutOfRange() 119 { 120 return outOfRange; 121 } 122 } 123 | Popular Tags |