KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*********************************************************************
2 *
3 * Copyright (C) 2001 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 common.Logger;
23
24 import jxl.biff.IntegerHelper;
25 import jxl.biff.RecordData;
26
27 /**
28  * A row record
29  */

30 public class RowRecord extends RecordData
31 {
32   /**
33    * The logger
34    */

35   private static Logger logger = Logger.getLogger(RowRecord.class);
36
37   /**
38    * The number of this row
39    */

40   private int rowNumber;
41   /**
42    * The height of this row
43    */

44   private int rowHeight;
45   /**
46    * Flag to indicate whether this row is collapsed or not
47    */

48   private boolean collapsed;
49   /**
50    * Indicates whether this row has an explicit default format
51    */

52   private boolean defaultFormat;
53   /**
54    * Indicates whether the row record height matches the default font height
55    */

56   private boolean matchesDefFontHeight;
57   /**
58    * The (default) xf index for cells on this row
59    */

60   private int xfIndex;
61
62   /**
63    * Indicates that the row is default height
64    */

65   private static final int defaultHeightIndicator = 0xff;
66
67   /**
68    * Constructs this object from the raw data
69    *
70    * @param t the raw data
71    */

72   RowRecord(Record t)
73   {
74     super(t);
75
76     byte[] data = getRecord().getData();
77     rowNumber = IntegerHelper.getInt(data[0], data[1]);
78     rowHeight = IntegerHelper.getInt(data[6], data[7]);
79
80     int options = IntegerHelper.getInt(data[12], data[13],
81                                        data[14], data[15]);
82
83     collapsed = (options & 0x20) != 0;
84     matchesDefFontHeight = (options & 0x40) == 0;
85     defaultFormat = (options & 0x80) != 0;
86     xfIndex = (options & 0x0fff0000) >> 16;
87   }
88
89   /**
90    * Interrogates whether this row is of default height
91    *
92    * @return TRUE if this is set to the default height, FALSE otherwise
93    */

94   boolean isDefaultHeight()
95   {
96     return rowHeight == defaultHeightIndicator;
97   }
98
99   /**
100    * Interrogates this row to see whether it matches the default font height
101    *
102    * @return TRUE if this matches the default font height, FALSE otherwise
103    */

104   public boolean matchesDefaultFontHeight()
105   {
106     return matchesDefFontHeight;
107   }
108
109   /**
110    * Gets the row number
111    *
112    * @return the number of this row
113    */

114   public int getRowNumber()
115   {
116     return rowNumber;
117   }
118
119   /**
120    * Gets the height of the row
121    *
122    * @return the row height
123    */

124   public int getRowHeight()
125   {
126     return rowHeight;
127   }
128
129   /**
130    * Queries whether the row is collapsed
131    *
132    * @return the collapsed indicator
133    */

134   public boolean isCollapsed()
135   {
136     return collapsed;
137   }
138
139   /**
140    * Gets the default xf index for this row
141    *
142    * @return the xf index
143    */

144   public int getXFIndex()
145   {
146     return xfIndex;
147   }
148
149   /**
150    * Queries whether the row has a specific default cell format applied
151    *
152    * @return the default cell format
153    */

154   public boolean hasDefaultFormat()
155   {
156     return defaultFormat;
157   }
158 }
159
160
161
Popular Tags