Source Code Cross Referenced for IndexRecord.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.IntList;
021:        import org.apache.poi.util.LittleEndian;
022:
023:        /**
024:         * Title:        Index Record<P>
025:         * Description:  Occurs right after BOF, tells you where the DBCELL records are for a sheet
026:         *               Important for locating cells<P>
027:         * NOT USED IN THIS RELEASE
028:         * REFERENCE:  PG 323 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
029:         * @author Andrew C. Oliver (acoliver at apache dot org)
030:         * @author Jason Height (jheight at chariot dot net dot au)
031:         * @version 2.0-pre
032:         */
033:
034:        public class IndexRecord extends Record {
035:            public final static short sid = 0x20B;
036:            public final static int DBCELL_CAPACITY = 30;
037:            public int field_1_zero; // reserved must be 0
038:            public int field_2_first_row; // first row on the sheet
039:            public int field_3_last_row_add1; // last row
040:            public int field_4_zero; // reserved must be 0
041:            public IntList field_5_dbcells; // array of offsets to DBCELL records
042:
043:            public IndexRecord() {
044:            }
045:
046:            /**
047:             * Constructs an Index record and sets its fields appropriately.
048:             * @param in the RecordInputstream to read the record from
049:             */
050:
051:            public IndexRecord(RecordInputStream in) {
052:                super (in);
053:            }
054:
055:            protected void validateSid(short id) {
056:                if (id != sid) {
057:                    throw new RecordFormatException("NOT An Index RECORD");
058:                }
059:            }
060:
061:            protected void fillFields(RecordInputStream in) {
062:                field_5_dbcells = new IntList(DBCELL_CAPACITY); // initial capacity of 30
063:                field_1_zero = in.readInt();
064:                field_2_first_row = in.readInt();
065:                field_3_last_row_add1 = in.readInt();
066:                field_4_zero = in.readInt();
067:                while (in.remaining() > 0) {
068:
069:                    // System.out.println("getting " + k);
070:                    field_5_dbcells.add(in.readInt());
071:                }
072:            }
073:
074:            public void setFirstRow(int row) {
075:                field_2_first_row = row;
076:            }
077:
078:            public void setLastRowAdd1(int row) {
079:                field_3_last_row_add1 = row;
080:            }
081:
082:            public void addDbcell(int cell) {
083:                if (field_5_dbcells == null) {
084:                    field_5_dbcells = new IntList();
085:                }
086:                field_5_dbcells.add(cell);
087:            }
088:
089:            public void setDbcell(int cell, int value) {
090:                field_5_dbcells.set(cell, value);
091:            }
092:
093:            public int getFirstRow() {
094:                return field_2_first_row;
095:            }
096:
097:            public int getLastRowAdd1() {
098:                return field_3_last_row_add1;
099:            }
100:
101:            public int getNumDbcells() {
102:                if (field_5_dbcells == null) {
103:                    return 0;
104:                }
105:                return field_5_dbcells.size();
106:            }
107:
108:            public int getDbcellAt(int cellnum) {
109:                return field_5_dbcells.get(cellnum);
110:            }
111:
112:            public String toString() {
113:                StringBuffer buffer = new StringBuffer();
114:
115:                buffer.append("[INDEX]\n");
116:                buffer.append("    .firstrow       = ").append(
117:                        Integer.toHexString(getFirstRow())).append("\n");
118:                buffer.append("    .lastrowadd1    = ").append(
119:                        Integer.toHexString(getLastRowAdd1())).append("\n");
120:                for (int k = 0; k < getNumDbcells(); k++) {
121:                    buffer.append("    .dbcell_" + k + "       = ").append(
122:                            Integer.toHexString(getDbcellAt(k))).append("\n");
123:                }
124:                buffer.append("[/INDEX]\n");
125:                return buffer.toString();
126:            }
127:
128:            public int serialize(int offset, byte[] data) {
129:                LittleEndian.putShort(data, 0 + offset, sid);
130:                LittleEndian.putShort(data, 2 + offset,
131:                        (short) (16 + (getNumDbcells() * 4)));
132:                LittleEndian.putInt(data, 4 + offset, 0);
133:                LittleEndian.putInt(data, 8 + offset, getFirstRow());
134:                LittleEndian.putInt(data, 12 + offset, getLastRowAdd1());
135:                LittleEndian.putInt(data, 16 + offset, 0);
136:                for (int k = 0; k < getNumDbcells(); k++) {
137:                    LittleEndian.putInt(data, (k * 4) + 20 + offset,
138:                            getDbcellAt(k));
139:                }
140:                return getRecordSize();
141:            }
142:
143:            public int getRecordSize() {
144:                return 20 + (getNumDbcells() * 4);
145:            }
146:
147:            /** Returns the size of an INdexRecord when it needs to index the specified number of blocks
148:             *
149:             */
150:            public static int getRecordSizeForBlockCount(int blockCount) {
151:                return 20 + (4 * blockCount);
152:            }
153:
154:            public short getSid() {
155:                return sid;
156:            }
157:
158:            public Object clone() {
159:                IndexRecord rec = new IndexRecord();
160:                rec.field_1_zero = field_1_zero;
161:                rec.field_2_first_row = field_2_first_row;
162:                rec.field_3_last_row_add1 = field_3_last_row_add1;
163:                rec.field_4_zero = field_4_zero;
164:                rec.field_5_dbcells = new IntList();
165:                rec.field_5_dbcells.addAll(field_5_dbcells);
166:                return rec;
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.