Source Code Cross Referenced for NumberRecord.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:        /*
019:         * NumberRecord.java
020:         *
021:         * Created on October 1, 2001, 8:01 PM
022:         */
023:        package org.apache.poi.hssf.record;
024:
025:        import org.apache.poi.util.LittleEndian;
026:        import org.apache.poi.hssf.record.Record;
027:
028:        /**
029:         * Contains a numeric cell value. <P>
030:         * REFERENCE:  PG 334 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
031:         * @author Andrew C. Oliver (acoliver at apache dot org)
032:         * @author Jason Height (jheight at chariot dot net dot au)
033:         * @version 2.0-pre
034:         */
035:
036:        public class NumberRecord extends Record implements 
037:                CellValueRecordInterface, Comparable {
038:            public static final short sid = 0x203;
039:            //private short             field_1_row;
040:            private int field_1_row;
041:            private short field_2_col;
042:            private short field_3_xf;
043:            private double field_4_value;
044:
045:            /** Creates new NumberRecord */
046:            public NumberRecord() {
047:            }
048:
049:            /**
050:             * Constructs a Number record and sets its fields appropriately.
051:             *
052:             * @param in the RecordInputstream to read the record from
053:             */
054:
055:            public NumberRecord(RecordInputStream in) {
056:                super (in);
057:            }
058:
059:            /**
060:             * @param in the RecordInputstream to read the record from
061:             */
062:
063:            protected void fillFields(RecordInputStream in) {
064:                //field_1_row   = LittleEndian.getShort(data, 0 + offset);
065:                field_1_row = in.readUShort();
066:                field_2_col = in.readShort();
067:                field_3_xf = in.readShort();
068:                field_4_value = in.readDouble();
069:            }
070:
071:            //public void setRow(short row)
072:            public void setRow(int row) {
073:                field_1_row = row;
074:            }
075:
076:            public void setColumn(short col) {
077:                field_2_col = col;
078:            }
079:
080:            /**
081:             * set the index to the ExtendedFormat
082:             * @see org.apache.poi.hssf.record.ExtendedFormatRecord
083:             * @param xf  index to the XF record
084:             */
085:
086:            public void setXFIndex(short xf) {
087:                field_3_xf = xf;
088:            }
089:
090:            /**
091:             * set the value for the cell
092:             *
093:             * @param value  double representing the value
094:             */
095:
096:            public void setValue(double value) {
097:                field_4_value = value;
098:            }
099:
100:            //public short getRow()
101:            public int getRow() {
102:                return field_1_row;
103:            }
104:
105:            public short getColumn() {
106:                return field_2_col;
107:            }
108:
109:            /**
110:             * get the index to the ExtendedFormat
111:             * @see org.apache.poi.hssf.record.ExtendedFormatRecord
112:             * @return index to the XF record
113:             */
114:
115:            public short getXFIndex() {
116:                return field_3_xf;
117:            }
118:
119:            /**
120:             * get the value for the cell
121:             *
122:             * @return double representing the value
123:             */
124:
125:            public double getValue() {
126:                return field_4_value;
127:            }
128:
129:            public String toString() {
130:                StringBuffer buffer = new StringBuffer();
131:
132:                buffer.append("[NUMBER]\n");
133:                buffer.append("    .row            = ").append(
134:                        Integer.toHexString(getRow())).append("\n");
135:                buffer.append("    .col            = ").append(
136:                        Integer.toHexString(getColumn())).append("\n");
137:                buffer.append("    .xfindex        = ").append(
138:                        Integer.toHexString(getXFIndex())).append("\n");
139:                buffer.append("    .value          = ").append(getValue())
140:                        .append("\n");
141:                buffer.append("[/NUMBER]\n");
142:                return buffer.toString();
143:            }
144:
145:            /**
146:             * called by the class that is responsible for writing this sucker.
147:             * Subclasses should implement this so that their data is passed back in a
148:             * byte array.
149:             *
150:             * @return byte array containing instance data
151:             */
152:
153:            public int serialize(int offset, byte[] data) {
154:                LittleEndian.putShort(data, 0 + offset, sid);
155:                LittleEndian.putShort(data, 2 + offset, (short) 14);
156:                //LittleEndian.putShort(data, 4 + offset, getRow());
157:                LittleEndian.putShort(data, 4 + offset, (short) getRow());
158:                LittleEndian.putShort(data, 6 + offset, getColumn());
159:                LittleEndian.putShort(data, 8 + offset, getXFIndex());
160:                LittleEndian.putDouble(data, 10 + offset, getValue());
161:                return getRecordSize();
162:            }
163:
164:            public int getRecordSize() {
165:                return 18;
166:            }
167:
168:            /**
169:             * called by constructor, should throw runtime exception in the event of a
170:             * record passed with a differing ID.
171:             *
172:             * @param id alleged id for this record
173:             */
174:
175:            protected void validateSid(short id) {
176:                if (id != sid) {
177:                    throw new RecordFormatException("NOT A Number RECORD");
178:                }
179:            }
180:
181:            public short getSid() {
182:                return sid;
183:            }
184:
185:            public boolean isBefore(CellValueRecordInterface i) {
186:                if (this .getRow() > i.getRow()) {
187:                    return false;
188:                }
189:                if ((this .getRow() == i.getRow())
190:                        && (this .getColumn() > i.getColumn())) {
191:                    return false;
192:                }
193:                if ((this .getRow() == i.getRow())
194:                        && (this .getColumn() == i.getColumn())) {
195:                    return false;
196:                }
197:                return true;
198:            }
199:
200:            public boolean isAfter(CellValueRecordInterface i) {
201:                if (this .getRow() < i.getRow()) {
202:                    return false;
203:                }
204:                if ((this .getRow() == i.getRow())
205:                        && (this .getColumn() < i.getColumn())) {
206:                    return false;
207:                }
208:                if ((this .getRow() == i.getRow())
209:                        && (this .getColumn() == i.getColumn())) {
210:                    return false;
211:                }
212:                return true;
213:            }
214:
215:            public boolean isEqual(CellValueRecordInterface i) {
216:                return ((this .getRow() == i.getRow()) && (this .getColumn() == i
217:                        .getColumn()));
218:            }
219:
220:            public boolean isInValueSection() {
221:                return true;
222:            }
223:
224:            public boolean isValue() {
225:                return true;
226:            }
227:
228:            public int compareTo(Object obj) {
229:                CellValueRecordInterface loc = (CellValueRecordInterface) obj;
230:
231:                if ((this .getRow() == loc.getRow())
232:                        && (this .getColumn() == loc.getColumn())) {
233:                    return 0;
234:                }
235:                if (this .getRow() < loc.getRow()) {
236:                    return -1;
237:                }
238:                if (this .getRow() > loc.getRow()) {
239:                    return 1;
240:                }
241:                if (this .getColumn() < loc.getColumn()) {
242:                    return -1;
243:                }
244:                if (this .getColumn() > loc.getColumn()) {
245:                    return 1;
246:                }
247:                return -1;
248:            }
249:
250:            public boolean equals(Object obj) {
251:                if (!(obj instanceof  CellValueRecordInterface)) {
252:                    return false;
253:                }
254:                CellValueRecordInterface loc = (CellValueRecordInterface) obj;
255:
256:                if ((this .getRow() == loc.getRow())
257:                        && (this .getColumn() == loc.getColumn())) {
258:                    return true;
259:                }
260:                return false;
261:            }
262:
263:            public Object clone() {
264:                NumberRecord rec = new NumberRecord();
265:                rec.field_1_row = field_1_row;
266:                rec.field_2_col = field_2_col;
267:                rec.field_3_xf = field_3_xf;
268:                rec.field_4_value = field_4_value;
269:                return rec;
270:            }
271:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.