KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*********************************************************************
2 *
3 * Copyright (C) 2004 Andrew Khan, Al Mantei
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.Type;
23 import jxl.biff.RecordData;
24 import jxl.biff.StringHelper;
25
26 /**
27  * A storage area for the last Sort dialog box area
28  */

29 public class SortRecord extends RecordData
30 {
31     private int col1Size;
32     private int col2Size;
33     private int col3Size;
34     private String JavaDoc col1Name;
35     private String JavaDoc col2Name;
36     private String JavaDoc col3Name;
37     private byte optionFlags;
38     private boolean sortColumns = false;
39     private boolean sortKey1Desc = false;
40     private boolean sortKey2Desc = false;
41     private boolean sortKey3Desc = false;
42     private boolean sortCaseSensitive = false;
43     /**
44      * Constructs this object from the raw data
45      *
46      * @param r the raw data
47      */

48     public SortRecord(Record r)
49   {
50         super(Type.SORT);
51
52         byte[] data = r.getData();
53
54         optionFlags = data[0];
55
56         sortColumns = ((optionFlags & 0x01) != 0);
57         sortKey1Desc = ((optionFlags & 0x02) != 0);
58         sortKey2Desc = ((optionFlags & 0x04) != 0);
59         sortKey3Desc = ((optionFlags & 0x08) != 0);
60         sortCaseSensitive = ((optionFlags & 0x10) != 0);
61
62         // data[1] contains sort list index - not implemented...
63

64         col1Size = data[2];
65         col2Size = data[3];
66         col3Size = data[4];
67         int curPos = 5;
68         if (data[curPos++] == 0x00)
69     {
70             col1Name = new String JavaDoc(data, curPos, col1Size);
71             curPos += col1Size;
72         }
73     else
74     {
75             col1Name = StringHelper.getUnicodeString(data, col1Size, curPos);
76             curPos += col1Size * 2;
77         }
78
79         if (col2Size > 0)
80     {
81             if (data[curPos++] == 0x00)
82       {
83                 col2Name = new String JavaDoc(data, curPos, col2Size);
84                 curPos += col2Size;
85             }
86       else
87       {
88                 col2Name = StringHelper.getUnicodeString(data, col2Size, curPos);
89                 curPos += col2Size * 2;
90             }
91         }
92     else
93     {
94             col2Name = "";
95     }
96         if (col3Size > 0)
97     {
98             if (data[curPos++] == 0x00)
99       {
100                 col3Name = new String JavaDoc(data, curPos, col3Size);
101                 curPos += col3Size;
102             }
103       else
104       {
105                 col3Name = StringHelper.getUnicodeString(data, col3Size, curPos);
106                 curPos += col3Size * 2;
107             }
108         }
109     else
110     {
111             col3Name = "";
112     }
113     }
114
115     /**
116      * Accessor for the 1st Sort Column Name
117      *
118      * @return the 1st Sort Column Name
119      */

120     public String JavaDoc getSortCol1Name() {
121         return col1Name;
122     }
123     /**
124      * Accessor for the 2nd Sort Column Name
125      *
126      * @return the 2nd Sort Column Name
127      */

128     public String JavaDoc getSortCol2Name() {
129         return col2Name;
130     }
131     /**
132      * Accessor for the 3rd Sort Column Name
133      *
134      * @return the 3rd Sort Column Name
135      */

136     public String JavaDoc getSortCol3Name() {
137         return col3Name;
138     }
139     /**
140      * Accessor for the Sort by Columns flag
141      *
142      * @return the Sort by Columns flag
143      */

144     public boolean getSortColumns() {
145         return sortColumns;
146     }
147     /**
148      * Accessor for the Sort Column 1 Descending flag
149      *
150      * @return the Sort Column 1 Descending flag
151      */

152     public boolean getSortKey1Desc() {
153         return sortKey1Desc;
154     }
155     /**
156      * Accessor for the Sort Column 2 Descending flag
157      *
158      * @return the Sort Column 2 Descending flag
159      */

160     public boolean getSortKey2Desc() {
161         return sortKey2Desc;
162     }
163     /**
164      * Accessor for the Sort Column 3 Descending flag
165      *
166      * @return the Sort Column 3 Descending flag
167      */

168     public boolean getSortKey3Desc() {
169         return sortKey3Desc;
170     }
171     /**
172      * Accessor for the Sort Case Sensitivity flag
173      *
174      * @return the Sort Case Secsitivity flag
175      */

176     public boolean getSortCaseSensitive() {
177         return sortCaseSensitive;
178     }
179 }
180
Popular Tags