Source Code Cross Referenced for RowRecord.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hssf » record » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » poi 3.0.2 beta2 » org.apache.poi.hssf.record 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:         Licensed to the Apache Software Foundation (ASF) under one or more
003:         contributor license agreements.  See the NOTICE file distributed with
004:         this work for additional information regarding copyright ownership.
005:         The ASF licenses this file to You under the Apache License, Version 2.0
006:         (the "License"); you may not use this file except in compliance with
007:         the License.  You may obtain a copy of the License at
008:
009:         http://www.apache.org/licenses/LICENSE-2.0
010:
011:         Unless required by applicable law or agreed to in writing, software
012:         distributed under the License is distributed on an "AS IS" BASIS,
013:         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         See the License for the specific language governing permissions and
015:         limitations under the License.
016:         ==================================================================== */
017:
018:        package org.apache.poi.hssf.record;
019:
020:        import org.apache.poi.util.BitField;
021:        import org.apache.poi.util.BitFieldFactory;
022:        import org.apache.poi.util.LittleEndian;
023:
024:        /**
025:         * Title:        Row Record<P>
026:         * Description:  stores the row information for the sheet. <P>
027:         * REFERENCE:  PG 379 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
028:         * @author Andrew C. Oliver (acoliver at apache dot org)
029:         * @author Jason Height (jheight at chariot dot net dot au)
030:         * @version 2.0-pre
031:         */
032:
033:        public class RowRecord extends Record implements  Comparable {
034:            public final static short sid = 0x208;
035:
036:            /** The maximum row number that excel can handle (zero bazed) ie 65536 rows is
037:             *  max number of rows.
038:             */
039:            public final static int MAX_ROW_NUMBER = 65535;
040:
041:            //private short             field_1_row_number;
042:            private int field_1_row_number;
043:            private short field_2_first_col;
044:            private short field_3_last_col; // plus 1
045:            private short field_4_height;
046:            private short field_5_optimize; // hint field for gui, can/should be set to zero
047:
048:            // for generated sheets.
049:            private short field_6_reserved;
050:            private short field_7_option_flags;
051:            private static final BitField outlineLevel = BitFieldFactory
052:                    .getInstance(0x07);
053:
054:            // bit 3 reserved
055:            private static final BitField colapsed = BitFieldFactory
056:                    .getInstance(0x10);
057:            private static final BitField zeroHeight = BitFieldFactory
058:                    .getInstance(0x20);
059:            private static final BitField badFontHeight = BitFieldFactory
060:                    .getInstance(0x40);
061:            private static final BitField formatted = BitFieldFactory
062:                    .getInstance(0x80);
063:            private short field_8_xf_index; // only if isFormatted
064:
065:            public RowRecord() {
066:            }
067:
068:            /**
069:             * Constructs a Row record and sets its fields appropriately.
070:             * @param in the RecordInputstream to read the record from
071:             */
072:
073:            public RowRecord(RecordInputStream in) {
074:                super (in);
075:            }
076:
077:            protected void validateSid(short id) {
078:                if (id != sid) {
079:                    throw new RecordFormatException("NOT A valid ROW RECORD");
080:                }
081:            }
082:
083:            protected void fillFields(RecordInputStream in) {
084:                //field_1_row_number   = LittleEndian.getShort(data, 0 + offset);
085:                field_1_row_number = in.readUShort();
086:                field_2_first_col = in.readShort();
087:                field_3_last_col = in.readShort();
088:                field_4_height = in.readShort();
089:                field_5_optimize = in.readShort();
090:                field_6_reserved = in.readShort();
091:                field_7_option_flags = in.readShort();
092:                field_8_xf_index = in.readShort();
093:            }
094:
095:            /**
096:             * set the logical row number for this row (0 based index)
097:             * @param row - the row number
098:             */
099:
100:            //public void setRowNumber(short row)
101:            public void setRowNumber(int row) {
102:                field_1_row_number = row;
103:            }
104:
105:            /**
106:             * set the logical col number for the first cell this row (0 based index)
107:             * @param col - the col number
108:             */
109:
110:            public void setFirstCol(short col) {
111:                field_2_first_col = col;
112:            }
113:
114:            /**
115:             * set the logical col number for the last cell this row (0 based index)
116:             * @param col - the col number
117:             */
118:
119:            public void setLastCol(short col) {
120:                field_3_last_col = col;
121:            }
122:
123:            /**
124:             * set the height of the row
125:             * @param height of the row
126:             */
127:
128:            public void setHeight(short height) {
129:                field_4_height = height;
130:            }
131:
132:            /**
133:             * set whether to optimize or not (set to 0)
134:             * @param optimize (set to 0)
135:             */
136:
137:            public void setOptimize(short optimize) {
138:                field_5_optimize = optimize;
139:            }
140:
141:            /**
142:             * sets the option bitmask.  (use the individual bit setters that refer to this
143:             * method)
144:             * @param options - the bitmask
145:             */
146:
147:            public void setOptionFlags(short options) {
148:                field_7_option_flags = options;
149:            }
150:
151:            // option bitfields
152:
153:            /**
154:             * set the outline level of this row
155:             * @param ol - the outline level
156:             * @see #setOptionFlags(short)
157:             */
158:
159:            public void setOutlineLevel(short ol) {
160:                field_7_option_flags = outlineLevel.setShortValue(
161:                        field_7_option_flags, ol);
162:            }
163:
164:            /**
165:             * set whether or not to colapse this row
166:             * @param c - colapse or not
167:             * @see #setOptionFlags(short)
168:             */
169:
170:            public void setColapsed(boolean c) {
171:                field_7_option_flags = colapsed.setShortBoolean(
172:                        field_7_option_flags, c);
173:            }
174:
175:            /**
176:             * set whether or not to display this row with 0 height
177:             * @param z  height is zero or not.
178:             * @see #setOptionFlags(short)
179:             */
180:
181:            public void setZeroHeight(boolean z) {
182:                field_7_option_flags = zeroHeight.setShortBoolean(
183:                        field_7_option_flags, z);
184:            }
185:
186:            /**
187:             * set whether the font and row height are not compatible
188:             * @param  f  true if they aren't compatible (damn not logic)
189:             * @see #setOptionFlags(short)
190:             */
191:
192:            public void setBadFontHeight(boolean f) {
193:                field_7_option_flags = badFontHeight.setShortBoolean(
194:                        field_7_option_flags, f);
195:            }
196:
197:            /**
198:             * set whether the row has been formatted (even if its got all blank cells)
199:             * @param f  formatted or not
200:             * @see #setOptionFlags(short)
201:             */
202:
203:            public void setFormatted(boolean f) {
204:                field_7_option_flags = formatted.setShortBoolean(
205:                        field_7_option_flags, f);
206:            }
207:
208:            // end bitfields
209:
210:            /**
211:             * if the row is formatted then this is the index to the extended format record
212:             * @see org.apache.poi.hssf.record.ExtendedFormatRecord
213:             * @param index to the XF record
214:             */
215:
216:            public void setXFIndex(short index) {
217:                field_8_xf_index = index;
218:            }
219:
220:            /**
221:             * get the logical row number for this row (0 based index)
222:             * @return row - the row number
223:             */
224:
225:            //public short getRowNumber()
226:            public int getRowNumber() {
227:                return field_1_row_number;
228:            }
229:
230:            /**
231:             * get the logical col number for the first cell this row (0 based index)
232:             * @return col - the col number
233:             */
234:
235:            public short getFirstCol() {
236:                return field_2_first_col;
237:            }
238:
239:            /**
240:             * get the logical col number for the last cell this row plus one (0 based index)
241:             * @return col - the last col number + 1
242:             */
243:
244:            public short getLastCol() {
245:                return field_3_last_col;
246:            }
247:
248:            /**
249:             * get the height of the row
250:             * @return height of the row
251:             */
252:
253:            public short getHeight() {
254:                return field_4_height;
255:            }
256:
257:            /**
258:             * get whether to optimize or not (set to 0)
259:             * @return optimize (set to 0)
260:             */
261:
262:            public short getOptimize() {
263:                return field_5_optimize;
264:            }
265:
266:            /**
267:             * gets the option bitmask.  (use the individual bit setters that refer to this
268:             * method)
269:             * @return options - the bitmask
270:             */
271:
272:            public short getOptionFlags() {
273:                return field_7_option_flags;
274:            }
275:
276:            // option bitfields
277:
278:            /**
279:             * get the outline level of this row
280:             * @return ol - the outline level
281:             * @see #getOptionFlags()
282:             */
283:
284:            public short getOutlineLevel() {
285:                return outlineLevel.getShortValue(field_7_option_flags);
286:            }
287:
288:            /**
289:             * get whether or not to colapse this row
290:             * @return c - colapse or not
291:             * @see #getOptionFlags()
292:             */
293:
294:            public boolean getColapsed() {
295:                return (colapsed.isSet(field_7_option_flags));
296:            }
297:
298:            /**
299:             * get whether or not to display this row with 0 height
300:             * @return - z height is zero or not.
301:             * @see #getOptionFlags()
302:             */
303:
304:            public boolean getZeroHeight() {
305:                return zeroHeight.isSet(field_7_option_flags);
306:            }
307:
308:            /**
309:             * get whether the font and row height are not compatible
310:             * @return - f -true if they aren't compatible (damn not logic)
311:             * @see #getOptionFlags()
312:             */
313:
314:            public boolean getBadFontHeight() {
315:                return badFontHeight.isSet(field_7_option_flags);
316:            }
317:
318:            /**
319:             * get whether the row has been formatted (even if its got all blank cells)
320:             * @return formatted or not
321:             * @see #getOptionFlags()
322:             */
323:
324:            public boolean getFormatted() {
325:                return formatted.isSet(field_7_option_flags);
326:            }
327:
328:            // end bitfields
329:
330:            /**
331:             * if the row is formatted then this is the index to the extended format record
332:             * @see org.apache.poi.hssf.record.ExtendedFormatRecord
333:             * @return index to the XF record or bogus value (undefined) if isn't formatted
334:             */
335:
336:            public short getXFIndex() {
337:                return field_8_xf_index;
338:            }
339:
340:            public boolean isInValueSection() {
341:                return true;
342:            }
343:
344:            public String toString() {
345:                StringBuffer buffer = new StringBuffer();
346:
347:                buffer.append("[ROW]\n");
348:                buffer.append("    .rownumber      = ").append(
349:                        Integer.toHexString(getRowNumber())).append("\n");
350:                buffer.append("    .firstcol       = ").append(
351:                        Integer.toHexString(getFirstCol())).append("\n");
352:                buffer.append("    .lastcol        = ").append(
353:                        Integer.toHexString(getLastCol())).append("\n");
354:                buffer.append("    .height         = ").append(
355:                        Integer.toHexString(getHeight())).append("\n");
356:                buffer.append("    .optimize       = ").append(
357:                        Integer.toHexString(getOptimize())).append("\n");
358:                buffer.append("    .reserved       = ").append(
359:                        Integer.toHexString(field_6_reserved)).append("\n");
360:                buffer.append("    .optionflags    = ").append(
361:                        Integer.toHexString(getOptionFlags())).append("\n");
362:                buffer.append("        .outlinelvl = ").append(
363:                        Integer.toHexString(getOutlineLevel())).append("\n");
364:                buffer.append("        .colapsed   = ").append(getColapsed())
365:                        .append("\n");
366:                buffer.append("        .zeroheight = ").append(getZeroHeight())
367:                        .append("\n");
368:                buffer.append("        .badfontheig= ").append(
369:                        getBadFontHeight()).append("\n");
370:                buffer.append("        .formatted  = ").append(getFormatted())
371:                        .append("\n");
372:                buffer.append("    .xfindex        = ").append(
373:                        Integer.toHexString(getXFIndex())).append("\n");
374:                buffer.append("[/ROW]\n");
375:                return buffer.toString();
376:            }
377:
378:            public int serialize(int offset, byte[] data) {
379:                LittleEndian.putShort(data, 0 + offset, sid);
380:                LittleEndian.putShort(data, 2 + offset, (short) 16);
381:                //LittleEndian.putShort(data, 4 + offset, getRowNumber());
382:                LittleEndian.putShort(data, 4 + offset, (short) getRowNumber());
383:                LittleEndian.putShort(data, 6 + offset,
384:                        getFirstCol() == -1 ? (short) 0 : getFirstCol());
385:                LittleEndian.putShort(data, 8 + offset,
386:                        getLastCol() == -1 ? (short) 0 : getLastCol());
387:                LittleEndian.putShort(data, 10 + offset, getHeight());
388:                LittleEndian.putShort(data, 12 + offset, getOptimize());
389:                LittleEndian.putShort(data, 14 + offset, field_6_reserved);
390:                LittleEndian.putShort(data, 16 + offset, getOptionFlags());
391:
392:                //    LittleEndian.putShort(data,18,getOutlineLevel());
393:                LittleEndian.putShort(data, 18 + offset, getXFIndex());
394:                return getRecordSize();
395:            }
396:
397:            public int getRecordSize() {
398:                return 20;
399:            }
400:
401:            public short getSid() {
402:                return sid;
403:            }
404:
405:            public int compareTo(Object obj) {
406:                RowRecord loc = (RowRecord) obj;
407:
408:                if (this .getRowNumber() == loc.getRowNumber()) {
409:                    return 0;
410:                }
411:                if (this .getRowNumber() < loc.getRowNumber()) {
412:                    return -1;
413:                }
414:                if (this .getRowNumber() > loc.getRowNumber()) {
415:                    return 1;
416:                }
417:                return -1;
418:            }
419:
420:            public boolean equals(Object obj) {
421:                if (!(obj instanceof  RowRecord)) {
422:                    return false;
423:                }
424:                RowRecord loc = (RowRecord) obj;
425:
426:                if (this .getRowNumber() == loc.getRowNumber()) {
427:                    return true;
428:                }
429:                return false;
430:            }
431:
432:            public Object clone() {
433:                RowRecord rec = new RowRecord();
434:                rec.field_1_row_number = field_1_row_number;
435:                rec.field_2_first_col = field_2_first_col;
436:                rec.field_3_last_col = field_3_last_col;
437:                rec.field_4_height = field_4_height;
438:                rec.field_5_optimize = field_5_optimize;
439:                rec.field_6_reserved = field_6_reserved;
440:                rec.field_7_option_flags = field_7_option_flags;
441:                rec.field_8_xf_index = field_8_xf_index;
442:                return rec;
443:            }
444:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.