KickJava   Java API By Example, From Geeks To Geeks.

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


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 common.Logger;
23
24 import jxl.biff.IntegerHelper;
25 import jxl.biff.RecordData;
26
27 /**
28  * Contains an array of RK numbers
29  */

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

35   private static Logger logger = Logger.getLogger(MulRKRecord.class);
36
37   /**
38    * The row containing these numbers
39    */

40   private int row;
41   /**
42    * The first column these rk number occur on
43    */

44   private int colFirst;
45   /**
46    * The last column these rk numbers occur on
47    */

48   private int colLast;
49   /**
50    * The number of rk numbers contained in this record
51    */

52   private int numrks;
53   /**
54    * The array of rk numbers
55    */

56   private int[] rknumbers;
57   /**
58    * The array of xf indices
59    */

60   private int[] xfIndices;
61
62   /**
63    * Constructs the rk numbers from the raw data
64    *
65    * @param t the raw data
66    */

67   public MulRKRecord(Record t)
68   {
69     super(t);
70     byte[] data = getRecord().getData();
71     int length = getRecord().getLength();
72     row = IntegerHelper.getInt(data[0], data[1]);
73     colFirst = IntegerHelper.getInt(data[2], data[3]);
74     colLast = IntegerHelper.getInt(data[length - 2], data[length - 1]);
75     numrks = colLast - colFirst + 1;
76     rknumbers = new int[numrks];
77     xfIndices = new int[numrks];
78
79     readRks(data);
80   }
81
82   /**
83    * Reads the rks from the raw data
84    *
85    * @param data the raw data
86    */

87   private void readRks(byte[] data)
88   {
89     int pos = 4;
90     int rk;
91     for (int i = 0; i < numrks; i++)
92     {
93       xfIndices[i] = IntegerHelper.getInt(data[pos], data[pos + 1]);
94       rk = IntegerHelper.getInt
95         (data[pos + 2], data[pos + 3], data[pos + 4], data[pos + 5]);
96       rknumbers[i] = rk;
97       pos += 6;
98     }
99   }
100
101   /**
102    * Accessor for the row
103    *
104    * @return the row of containing these rk numbers
105    */

106   public int getRow()
107   {
108     return row;
109   }
110
111   /**
112    * The first column containing the rk numbers
113    *
114    * @return the first column
115    */

116   public int getFirstColumn()
117   {
118     return colFirst;
119   }
120
121   /**
122    * Accessor for the number of rk values
123    *
124    * @return the number of rk values
125    */

126   public int getNumberOfColumns()
127   {
128     return numrks;
129   }
130
131   /**
132    * Returns a specific rk number
133    *
134    * @param index the rk number to return
135    * @return the rk number in bits
136    */

137   public int getRKNumber(int index)
138   {
139     return rknumbers[index];
140   }
141
142   /**
143    * Return a specific formatting index
144    *
145    * @param index the index of the cell in this group
146    * @return the xf index
147    */

148   public int getXFIndex(int index)
149   {
150     return xfIndices[index];
151   }
152 }
153
154
155
156
157
Popular Tags