KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > read > biff > RStringRecord


1 /*********************************************************************
2 *
3 * Copyright (C) 2002 Andrew Khan
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ***************************************************************************/

19
20 package jxl.read.biff;
21
22 import jxl.LabelCell;
23 import jxl.CellType;
24 import jxl.WorkbookSettings;
25 import jxl.biff.IntegerHelper;
26 import jxl.biff.FormattingRecords;
27 import jxl.biff.StringHelper;
28
29 /**
30  * A label which is stored in the cell
31  */

32 class RStringRecord extends CellValue implements LabelCell
33 {
34   /**
35    * The length of the label in characters
36    */

37   private int length;
38   /**
39    * The label
40    */

41   private String JavaDoc string;
42
43   /**
44    * Dummy indicators for overloading the constructor
45    */

46   private static class Biff7 {};
47   public static Biff7 biff7 = new Biff7();
48
49   /**
50    * Constructs this object from the raw data
51    *
52    * @param t the raw data
53    * @param fr the formatting records
54    * @param si the sheet
55    * @param ws the workbook settings
56    * @param dummy dummy overload to indicate a biff 7 workbook
57    */

58   public RStringRecord(Record t, FormattingRecords fr,
59                        SheetImpl si, WorkbookSettings ws, Biff7 dummy)
60   {
61     super(t, fr, si);
62     byte[] data = getRecord().getData();
63     length = IntegerHelper.getInt(data[6], data[7]);
64
65     string = StringHelper.getString(data, length, 8, ws);
66   }
67
68   /**
69    * Gets the label
70    *
71    * @return the label
72    */

73   public String JavaDoc getString()
74   {
75     return string;
76   }
77
78   /**
79    * Gets the cell contents as a string
80    *
81    * @return the label
82    */

83   public String JavaDoc getContents()
84   {
85     return string;
86   }
87
88   /**
89    * Accessor for the cell type
90    *
91    * @return the cell type
92    */

93   public CellType getType()
94   {
95     return CellType.LABEL;
96   }
97 }
98
Popular Tags