1 19 20 package jxl.biff.formula; 21 22 import common.Logger; 23 24 import jxl.Cell; 25 import jxl.WorkbookSettings; 26 import jxl.biff.StringHelper; 27 import jxl.biff.IntegerHelper; 28 29 32 class StringValue extends Operand implements ParsedThing 33 { 34 37 private final static Logger logger = Logger.getLogger(StringValue.class); 38 39 42 private String value; 43 44 47 private WorkbookSettings settings; 48 49 52 public StringValue(WorkbookSettings ws) 53 { 54 settings = ws; 55 } 56 57 62 public StringValue(String s) 63 { 64 value = s; 66 } 67 68 75 public int read(byte[] data, int pos) 76 { 77 int length = IntegerHelper.getInt(data[pos], data[pos+1]); 78 int consumed = 2; 79 80 if ((data[pos+1] & 0x01) == 0) 81 { 82 value = StringHelper.getString(data, length, pos+2, settings); 83 consumed += length; 84 } 85 else 86 { 87 value = StringHelper.getUnicodeString(data, length, pos+2); 88 consumed += length * 2; 89 } 90 91 return consumed; 92 } 93 94 99 byte[] getBytes() 100 { 101 byte[] data = new byte[value.length() * 2 + 3]; 102 data[0] = Token.STRING.getCode(); 103 data[1] = (byte) (value.length()); 104 data[2] = 0x01; 105 StringHelper.getUnicodeBytes(value, data, 3); 106 107 return data; 108 } 109 110 116 public void getString(StringBuffer buf) 117 { 118 buf.append("\""); 119 buf.append(value); 120 buf.append("\""); 121 } 122 } 123 124 | Popular Tags |