KickJava   Java API By Example, From Geeks To Geeks.

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


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.WorkbookSettings;
25 import jxl.biff.StringHelper;
26 import jxl.biff.IntegerHelper;
27 import jxl.biff.RecordData;
28
29 /**
30  * A workbook page header record
31  */

32 public class HeaderRecord extends RecordData
33 {
34   /**
35    * The logger
36    */

37   private static Logger logger = Logger.getLogger(HeaderRecord.class);
38
39   /**
40    * The footer
41    */

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

47   private static class Biff7 {};
48   public static Biff7 biff7 = new Biff7();
49
50   /**
51    * Constructs this object from the raw data
52    *
53    * @param t the record data
54    * @param ws the workbook settings
55    */

56   HeaderRecord(Record t, WorkbookSettings ws)
57   {
58     super(t);
59     byte[] data = getRecord().getData();
60
61     if (data.length == 0)
62     {
63       return;
64     }
65
66     int chars = IntegerHelper.getInt(data[0], data[1]);
67
68     boolean unicode = data[2] == 1;
69
70     if (unicode)
71     {
72       header = StringHelper.getUnicodeString(data, chars, 3);
73     }
74     else
75     {
76       header = StringHelper.getString(data, chars, 3, ws);
77     }
78   }
79
80   /**
81    * Constructs this object from the raw data
82    *
83    * @param t the record data
84    * @param ws the workbook settings
85    * @param dummy dummy record to indicate a biff7 document
86    */

87   HeaderRecord(Record t, WorkbookSettings ws, Biff7 dummy)
88   {
89     super(t);
90     byte[] data = getRecord().getData();
91
92     if (data.length == 0)
93     {
94       return;
95     }
96
97     int chars = data[0];
98     header = StringHelper.getString(data, chars, 1, ws);
99   }
100
101   /**
102    * Gets the header string
103    *
104    * @return the header string
105    */

106   String JavaDoc getHeader()
107   {
108     return header;
109   }
110 }
111
Popular Tags