Source Code Cross Referenced for WSBoolRecord.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:        WSBool Record.<p>
026:         * Description:  stores workbook settings  (aka its a big "everything we didn't
027:         *               put somewhere else")<P>
028:         * REFERENCE:  PG 425 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
029:         * @author Andrew C. Oliver (acoliver at apache dot org)
030:         * @author Glen Stampoultzis (gstamp@iprimus.com.au)
031:         * @author Jason Height (jheight at chariot dot net dot au)
032:         * @version 2.0-pre
033:         */
034:
035:        public class WSBoolRecord extends Record {
036:            public final static short sid = 0x81;
037:            private byte field_1_wsbool; // crappy names are because this is really one big short field (2byte)
038:            private byte field_2_wsbool; // but the docs inconsistantly use it as 2 seperate bytes
039:
040:            // I decided to be consistant in this way.
041:            static final private BitField autobreaks = BitFieldFactory
042:                    .getInstance(0x01); // are automatic page breaks visible
043:
044:            // bits 1 to 3 unused
045:            static final private BitField dialog = BitFieldFactory
046:                    .getInstance(0x10); // is sheet dialog sheet
047:            static final private BitField applystyles = BitFieldFactory
048:                    .getInstance(0x20); // whether to apply automatic styles to outlines
049:            static final private BitField rowsumsbelow = BitFieldFactory
050:                    .getInstance(0x40); // whether summary rows will appear below detail in outlines
051:            static final private BitField rowsumsright = BitFieldFactory
052:                    .getInstance(0x80); // whether summary rows will appear right of the detail in outlines
053:            static final private BitField fittopage = BitFieldFactory
054:                    .getInstance(0x01); // whether to fit stuff to the page
055:
056:            // bit 2 reserved
057:            static final private BitField displayguts = BitFieldFactory
058:                    .getInstance(0x06); // whether to display outline symbols (in the gutters)
059:
060:            // bits 4-5 reserved
061:            static final private BitField alternateexpression = // whether to use alternate expression eval
062:            BitFieldFactory.getInstance(0x40);
063:            static final private BitField alternateformula = // whether to use alternate formula entry
064:            BitFieldFactory.getInstance(0x80);
065:
066:            public WSBoolRecord() {
067:            }
068:
069:            /**
070:             * Constructs a WSBool record and sets its fields appropriately.
071:             * @param in the RecordInputstream to read the record from
072:             */
073:
074:            public WSBoolRecord(RecordInputStream in) {
075:                super (in);
076:            }
077:
078:            protected void validateSid(short id) {
079:                if (id != sid) {
080:                    throw new RecordFormatException("NOT A WSBoolRECORD");
081:                }
082:            }
083:
084:            protected void fillFields(RecordInputStream in) {
085:                byte data[] = in.readRemainder();
086:                field_1_wsbool = data[1]; // backwards because theoretically this is one short field
087:                field_2_wsbool = data[0]; // but it was easier to implement it this way to avoid confusion
088:            } // because the dev kit shows the masks for it as 2 byte fields
089:
090:            // why?  Why ask why?  But don't drink bud dry as its a really
091:            // crappy beer, try the czech "Budvar" beer (which is the real
092:            // budweiser though its ironically good...its sold in the USs
093:            // as czechvar  --- odd that they had the name first but can't
094:            // use it)...
095:
096:            /**
097:             * set first byte (see bit setters)
098:             */
099:
100:            public void setWSBool1(byte bool1) {
101:                field_1_wsbool = bool1;
102:            }
103:
104:            // bool1 bitfields
105:
106:            /**
107:             * show automatic page breaks or not
108:             * @param ab  whether to show auto page breaks
109:             */
110:
111:            public void setAutobreaks(boolean ab) {
112:                field_1_wsbool = autobreaks.setByteBoolean(field_1_wsbool, ab);
113:            }
114:
115:            /**
116:             * set whether sheet is a dialog sheet or not
117:             * @param isDialog or not
118:             */
119:
120:            public void setDialog(boolean isDialog) {
121:                field_1_wsbool = dialog
122:                        .setByteBoolean(field_1_wsbool, isDialog);
123:            }
124:
125:            /**
126:             * set if row summaries appear below detail in the outline
127:             * @param below or not
128:             */
129:
130:            public void setRowSumsBelow(boolean below) {
131:                field_1_wsbool = rowsumsbelow.setByteBoolean(field_1_wsbool,
132:                        below);
133:            }
134:
135:            /**
136:             * set if col summaries appear right of the detail in the outline
137:             * @param right or not
138:             */
139:
140:            public void setRowSumsRight(boolean right) {
141:                field_1_wsbool = rowsumsright.setByteBoolean(field_1_wsbool,
142:                        right);
143:            }
144:
145:            // end bitfields
146:
147:            /**
148:             * set the second byte (see bit setters)
149:             */
150:
151:            public void setWSBool2(byte bool2) {
152:                field_2_wsbool = bool2;
153:            }
154:
155:            // bool2 bitfields
156:
157:            /**
158:             * fit to page option is on
159:             * @param fit2page  fit or not
160:             */
161:
162:            public void setFitToPage(boolean fit2page) {
163:                field_2_wsbool = fittopage.setByteBoolean(field_2_wsbool,
164:                        fit2page);
165:            }
166:
167:            /**
168:             * set whether to display the guts or not
169:             *
170:             * @param guts or no guts (or glory)
171:             */
172:
173:            public void setDisplayGuts(boolean guts) {
174:                field_2_wsbool = displayguts.setByteBoolean(field_2_wsbool,
175:                        guts);
176:            }
177:
178:            /**
179:             * whether alternate expression evaluation is on
180:             * @param altexp  alternative expression evaluation or not
181:             */
182:
183:            public void setAlternateExpression(boolean altexp) {
184:                field_2_wsbool = alternateexpression.setByteBoolean(
185:                        field_2_wsbool, altexp);
186:            }
187:
188:            /**
189:             * whether alternative formula entry is on
190:             * @param formula  alternative formulas or not
191:             */
192:
193:            public void setAlternateFormula(boolean formula) {
194:                field_2_wsbool = alternateformula.setByteBoolean(
195:                        field_2_wsbool, formula);
196:            }
197:
198:            // end bitfields
199:
200:            /**
201:             * get first byte (see bit getters)
202:             */
203:
204:            public byte getWSBool1() {
205:                return field_1_wsbool;
206:            }
207:
208:            // bool1 bitfields
209:
210:            /**
211:             * show automatic page breaks or not
212:             * @return whether to show auto page breaks
213:             */
214:
215:            public boolean getAutobreaks() {
216:                return autobreaks.isSet(field_1_wsbool);
217:            }
218:
219:            /**
220:             * get whether sheet is a dialog sheet or not
221:             * @return isDialog or not
222:             */
223:
224:            public boolean getDialog() {
225:                return dialog.isSet(field_1_wsbool);
226:            }
227:
228:            /**
229:             * get if row summaries appear below detail in the outline
230:             * @return below or not
231:             */
232:
233:            public boolean getRowSumsBelow() {
234:                return rowsumsbelow.isSet(field_1_wsbool);
235:            }
236:
237:            /**
238:             * get if col summaries appear right of the detail in the outline
239:             * @return right or not
240:             */
241:
242:            public boolean getRowSumsRight() {
243:                return rowsumsright.isSet(field_1_wsbool);
244:            }
245:
246:            // end bitfields
247:
248:            /**
249:             * get the second byte (see bit getters)
250:             */
251:
252:            public byte getWSBool2() {
253:                return field_2_wsbool;
254:            }
255:
256:            // bool2 bitfields
257:
258:            /**
259:             * fit to page option is on
260:             * @return fit or not
261:             */
262:
263:            public boolean getFitToPage() {
264:                return fittopage.isSet(field_2_wsbool);
265:            }
266:
267:            /**
268:             * get whether to display the guts or not
269:             *
270:             * @return guts or no guts (or glory)
271:             */
272:
273:            public boolean getDisplayGuts() {
274:                return displayguts.isSet(field_2_wsbool);
275:            }
276:
277:            /**
278:             * whether alternate expression evaluation is on
279:             * @return alternative expression evaluation or not
280:             */
281:
282:            public boolean getAlternateExpression() {
283:                return alternateexpression.isSet(field_2_wsbool);
284:            }
285:
286:            /**
287:             * whether alternative formula entry is on
288:             * @return alternative formulas or not
289:             */
290:
291:            public boolean getAlternateFormula() {
292:                return alternateformula.isSet(field_2_wsbool);
293:            }
294:
295:            // end bitfields
296:            public String toString() {
297:                StringBuffer buffer = new StringBuffer();
298:
299:                buffer.append("[WSBOOL]\n");
300:                buffer.append("    .wsbool1        = ").append(
301:                        Integer.toHexString(getWSBool1())).append("\n");
302:                buffer.append("        .autobreaks = ").append(getAutobreaks())
303:                        .append("\n");
304:                buffer.append("        .dialog     = ").append(getDialog())
305:                        .append("\n");
306:                buffer.append("        .rowsumsbelw= ").append(
307:                        getRowSumsBelow()).append("\n");
308:                buffer.append("        .rowsumsrigt= ").append(
309:                        getRowSumsRight()).append("\n");
310:                buffer.append("    .wsbool2        = ").append(
311:                        Integer.toHexString(getWSBool2())).append("\n");
312:                buffer.append("        .fittopage  = ").append(getFitToPage())
313:                        .append("\n");
314:                buffer.append("        .displayguts= ")
315:                        .append(getDisplayGuts()).append("\n");
316:                buffer.append("        .alternateex= ").append(
317:                        getAlternateExpression()).append("\n");
318:                buffer.append("        .alternatefo= ").append(
319:                        getAlternateFormula()).append("\n");
320:                buffer.append("[/WSBOOL]\n");
321:                return buffer.toString();
322:            }
323:
324:            public int serialize(int offset, byte[] data) {
325:                LittleEndian.putShort(data, 0 + offset, sid);
326:                LittleEndian.putShort(data, 2 + offset, (short) 0x2);
327:                data[5 + offset] = getWSBool1();
328:                data[4 + offset] = getWSBool2();
329:                return getRecordSize();
330:            }
331:
332:            public int getRecordSize() {
333:                return 6;
334:            }
335:
336:            public short getSid() {
337:                return sid;
338:            }
339:
340:            public Object clone() {
341:                WSBoolRecord rec = new WSBoolRecord();
342:                rec.field_1_wsbool = field_1_wsbool;
343:                rec.field_2_wsbool = field_2_wsbool;
344:                return rec;
345:            }
346:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.