Source Code Cross Referenced for BoolErrRecord.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:         * BoolErrRecord.java
020:         *
021:         * Created on January 19, 2002, 9:30 AM
022:         */
023:        package org.apache.poi.hssf.record;
024:
025:        import org.apache.poi.util.LittleEndian;
026:
027:        /**
028:         * Creates new BoolErrRecord. <P>
029:         * REFERENCE:  PG ??? Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
030:         * @author Michael P. Harhen
031:         * @author Jason Height (jheight at chariot dot net dot au)
032:         * @version 2.0-pre
033:         */
034:
035:        public class BoolErrRecord extends Record implements 
036:                CellValueRecordInterface, Comparable {
037:            public final static short sid = 0x205;
038:            //private short             field_1_row;
039:            private int field_1_row;
040:            private short field_2_column;
041:            private short field_3_xf_index;
042:            private byte field_4_bBoolErr;
043:            private byte field_5_fError;
044:
045:            /** Creates new BoolErrRecord */
046:
047:            public BoolErrRecord() {
048:            }
049:
050:            /**
051:             * Constructs a BoolErr record and sets its fields appropriately.
052:             *
053:             * @param in the RecordInputstream to read the record from
054:             */
055:
056:            public BoolErrRecord(RecordInputStream in) {
057:                super (in);
058:            }
059:
060:            /**
061:             * @param in the RecordInputstream to read the record from
062:             */
063:
064:            protected void fillFields(RecordInputStream in) {
065:                //field_1_row      = LittleEndian.getShort(data, 0 + offset);
066:                field_1_row = in.readUShort();
067:                field_2_column = in.readShort();
068:                field_3_xf_index = in.readShort();
069:                field_4_bBoolErr = in.readByte();
070:                field_5_fError = in.readByte();
071:            }
072:
073:            //public void setRow(short row)
074:            public void setRow(int row) {
075:                field_1_row = row;
076:            }
077:
078:            public void setColumn(short col) {
079:                field_2_column = col;
080:            }
081:
082:            /**
083:             * set the index to the ExtendedFormat
084:             * @see org.apache.poi.hssf.record.ExtendedFormatRecord
085:             * @param xf    index to the XF record
086:             */
087:
088:            public void setXFIndex(short xf) {
089:                field_3_xf_index = xf;
090:            }
091:
092:            /**
093:             * set the boolean value for the cell
094:             *
095:             * @param value   representing the boolean value
096:             */
097:
098:            public void setValue(boolean value) {
099:                field_4_bBoolErr = value ? (byte) 1 : (byte) 0;
100:                field_5_fError = (byte) 0;
101:            }
102:
103:            /**
104:             * set the error value for the cell
105:             *
106:             * @param value     error representing the error value
107:             *                  this value can only be 0,7,15,23,29,36 or 42
108:             *                  see bugzilla bug 16560 for an explanation
109:             */
110:
111:            public void setValue(byte value) {
112:                if ((value == 0) || (value == 7) || (value == 15)
113:                        || (value == 23) || (value == 29) || (value == 36)
114:                        || (value == 42)) {
115:                    field_4_bBoolErr = value;
116:                    field_5_fError = (byte) 1;
117:                } else {
118:                    throw new RuntimeException(
119:                            "Error Value can only be 0,7,15,23,29,36 or 42. It cannot be "
120:                                    + value);
121:                }
122:            }
123:
124:            //public short getRow()
125:            public int getRow() {
126:                return field_1_row;
127:            }
128:
129:            public short getColumn() {
130:                return field_2_column;
131:            }
132:
133:            /**
134:             * get the index to the ExtendedFormat
135:             * @see org.apache.poi.hssf.record.ExtendedFormatRecord
136:             * @return index to the XF record
137:             */
138:
139:            public short getXFIndex() {
140:                return field_3_xf_index;
141:            }
142:
143:            /**
144:             * get the value for the cell
145:             *
146:             * @return boolean representing the boolean value
147:             */
148:
149:            public boolean getBooleanValue() {
150:                return (field_4_bBoolErr != 0);
151:            }
152:
153:            /**
154:             * get the error value for the cell
155:             *
156:             * @return byte representing the error value
157:             */
158:
159:            public byte getErrorValue() {
160:                return field_4_bBoolErr;
161:            }
162:
163:            /**
164:             * Indicates whether the call holds a boolean value
165:             *
166:             * @return boolean true if the cell holds a boolean value
167:             */
168:
169:            public boolean isBoolean() {
170:                return (field_5_fError == (byte) 0);
171:            }
172:
173:            /**
174:             * manually indicate this is an error rather than a boolean
175:             */
176:            public void setError(boolean val) {
177:                field_5_fError = (byte) (val == false ? 0 : 1);
178:            }
179:
180:            /**
181:             * Indicates whether the call holds an error value
182:             *
183:             * @return boolean true if the cell holds an error value
184:             */
185:
186:            public boolean isError() {
187:                return (field_5_fError != (byte) 0);
188:            }
189:
190:            public String toString() {
191:                StringBuffer buffer = new StringBuffer();
192:
193:                buffer.append("[BOOLERR]\n");
194:                buffer.append("    .row            = ").append(
195:                        Integer.toHexString(getRow())).append("\n");
196:                buffer.append("    .col            = ").append(
197:                        Integer.toHexString(getColumn())).append("\n");
198:                buffer.append("    .xfindex        = ").append(
199:                        Integer.toHexString(getXFIndex())).append("\n");
200:                if (isBoolean()) {
201:                    buffer.append("    .booleanValue   = ").append(
202:                            getBooleanValue()).append("\n");
203:                } else {
204:                    buffer.append("    .errorValue     = ").append(
205:                            getErrorValue()).append("\n");
206:                }
207:                buffer.append("[/BOOLERR]\n");
208:                return buffer.toString();
209:            }
210:
211:            /**
212:             * called by the class that is responsible for writing this sucker.
213:             * Subclasses should implement this so that their data is passed back in a
214:             * byte array.
215:             *
216:             * @return byte array containing instance data
217:             */
218:
219:            public int serialize(int offset, byte[] data) {
220:                LittleEndian.putShort(data, 0 + offset, sid);
221:                LittleEndian.putShort(data, 2 + offset, (short) 8);
222:                //LittleEndian.putShort(data, 4 + offset, getRow());
223:                LittleEndian.putShort(data, 4 + offset, (short) getRow());
224:                LittleEndian.putShort(data, 6 + offset, getColumn());
225:                LittleEndian.putShort(data, 8 + offset, getXFIndex());
226:                data[10 + offset] = field_4_bBoolErr;
227:                data[11 + offset] = field_5_fError;
228:                return getRecordSize();
229:            }
230:
231:            public int getRecordSize() {
232:                return 12;
233:            }
234:
235:            /**
236:             * called by constructor, should throw runtime exception in the event of a
237:             * record passed with a differing ID.
238:             *
239:             * @param id alleged id for this record
240:             */
241:
242:            protected void validateSid(short id) {
243:                if (id != BoolErrRecord.sid) {
244:                    throw new RecordFormatException("Not a valid BoolErrRecord");
245:                }
246:            }
247:
248:            public short getSid() {
249:                return sid;
250:            }
251:
252:            public boolean isBefore(CellValueRecordInterface i) {
253:                if (this .getRow() > i.getRow()) {
254:                    return false;
255:                }
256:                if ((this .getRow() == i.getRow())
257:                        && (this .getColumn() > i.getColumn())) {
258:                    return false;
259:                }
260:                if ((this .getRow() == i.getRow())
261:                        && (this .getColumn() == i.getColumn())) {
262:                    return false;
263:                }
264:                return true;
265:            }
266:
267:            public boolean isAfter(CellValueRecordInterface i) {
268:                if (this .getRow() < i.getRow()) {
269:                    return false;
270:                }
271:                if ((this .getRow() == i.getRow())
272:                        && (this .getColumn() < i.getColumn())) {
273:                    return false;
274:                }
275:                if ((this .getRow() == i.getRow())
276:                        && (this .getColumn() == i.getColumn())) {
277:                    return false;
278:                }
279:                return true;
280:            }
281:
282:            public boolean isEqual(CellValueRecordInterface i) {
283:                return ((this .getRow() == i.getRow()) && (this .getColumn() == i
284:                        .getColumn()));
285:            }
286:
287:            public boolean isInValueSection() {
288:                return true;
289:            }
290:
291:            public boolean isValue() {
292:                return true;
293:            }
294:
295:            public int compareTo(Object obj) {
296:                CellValueRecordInterface loc = (CellValueRecordInterface) obj;
297:
298:                if ((this .getRow() == loc.getRow())
299:                        && (this .getColumn() == loc.getColumn())) {
300:                    return 0;
301:                }
302:                if (this .getRow() < loc.getRow()) {
303:                    return -1;
304:                }
305:                if (this .getRow() > loc.getRow()) {
306:                    return 1;
307:                }
308:                if (this .getColumn() < loc.getColumn()) {
309:                    return -1;
310:                }
311:                if (this .getColumn() > loc.getColumn()) {
312:                    return 1;
313:                }
314:                return -1;
315:            }
316:
317:            public boolean equals(Object obj) {
318:                if (!(obj instanceof  CellValueRecordInterface)) {
319:                    return false;
320:                }
321:                CellValueRecordInterface loc = (CellValueRecordInterface) obj;
322:
323:                if ((this .getRow() == loc.getRow())
324:                        && (this .getColumn() == loc.getColumn())) {
325:                    return true;
326:                }
327:                return false;
328:            }
329:
330:            public Object clone() {
331:                BoolErrRecord rec = new BoolErrRecord();
332:                rec.field_1_row = field_1_row;
333:                rec.field_2_column = field_2_column;
334:                rec.field_3_xf_index = field_3_xf_index;
335:                rec.field_4_bBoolErr = field_4_bBoolErr;
336:                rec.field_5_fError = field_5_fError;
337:                return rec;
338:            }
339:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.