KickJava   Java API By Example, From Geeks To Geeks.

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


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.biff.IntegerHelper;
23 import jxl.biff.RecordData;
24
25 /**
26  * A Beginning Of File record, found at the commencement of all substreams
27  * within a biff8 file
28  */

29 public class BOFRecord extends RecordData
30 {
31   /**
32    * The code used for biff8 files
33    */

34   private static final int Biff8 = 0x600;
35   /**
36    * The code used for biff8 files
37    */

38   private static final int Biff7 = 0x500;
39   /**
40    * The code used for workbook globals
41    */

42   private static final int WorkbookGlobals = 0x5;
43   /**
44    * The code used for worksheets
45    */

46   private static final int Worksheet = 0x10;
47   /**
48    * The code used for charts
49    */

50   private static final int Chart = 0x20;
51   /**
52    * The code used for macro sheets
53    */

54   private static final int MacroSheet = 0x40;
55
56   /**
57    * The biff version of this substream
58    */

59   private int version;
60   /**
61    * The type of this substream
62    */

63   private int substreamType;
64
65   /**
66    * Constructs this object from the raw data
67    *
68    * @param t the raw data
69    */

70   BOFRecord(Record t)
71   {
72     super(t);
73     byte[] data = getRecord().getData();
74     version = IntegerHelper.getInt(data[0], data[1]);
75     substreamType = IntegerHelper.getInt(data[2], data[3]);
76   }
77
78   /**
79    * Interrogates this object to see if it is a biff8 substream
80    *
81    * @return TRUE if this substream is biff8, false otherwise
82    */

83   public boolean isBiff8()
84   {
85     return version == Biff8;
86   }
87
88   /**
89    * Interrogates this object to see if it is a biff7 substream
90    *
91    * @return TRUE if this substream is biff7, false otherwise
92    */

93   public boolean isBiff7()
94   {
95     return version == Biff7;
96   }
97
98
99   /**
100    * Interrogates this substream to see if it represents the commencement of
101    * the workbook globals substream
102    *
103    * @return TRUE if this is the commencement of a workbook globals substream,
104    * FALSE otherwise
105    */

106   boolean isWorkbookGlobals()
107   {
108     return substreamType == WorkbookGlobals;
109   }
110
111   /**
112    * Interrogates the substream to see if it is the commencement of a worksheet
113    *
114    * @return TRUE if this substream is the beginning of a worksheet, FALSE
115    * otherwise
116    */

117   public boolean isWorksheet()
118   {
119     return substreamType == Worksheet;
120   }
121
122   /**
123    * Interrogates the substream to see if it is the commencement of a worksheet
124    *
125    * @return TRUE if this substream is the beginning of a worksheet, FALSE
126    * otherwise
127    */

128   public boolean isMacroSheet()
129   {
130     return substreamType == MacroSheet;
131   }
132
133   /**
134    * Interrogates the substream to see if it is a chart
135    *
136    * @return TRUE if this substream is the beginning of a worksheet, FALSE
137    * otherwise
138    */

139   public boolean isChart()
140   {
141     return substreamType == Chart;
142   }
143
144   /**
145    * Gets the length of the data portion of this record
146    * Used to adjust when reading sheets which contain just a chart
147    * @return the length of the data portion of this record
148    */

149   int getLength()
150   {
151     return getRecord().getLength();
152   }
153
154 }
155
156
157
158
159
160
161
162
163
164
Popular Tags