Source Code Cross Referenced for HSSFHeader.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hssf » usermodel » 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.usermodel 
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.usermodel;
019:
020:        import org.apache.poi.hssf.record.HeaderRecord;
021:
022:        /**
023:         * Class to read and manipulate the header.
024:         * <P>
025:         * The header works by having a left, center, and right side.  The total cannot
026:         * be more that 255 bytes long.  One uses this class by getting the HSSFHeader
027:         * from HSSFSheet and then getting or setting the left, center, and right side.
028:         * For special things (such as page numbers and date), one can use a the methods
029:         * that return the characters used to represent these.  One can also change the
030:         * fonts by using similar methods.
031:         * <P>
032:         *
033:         * @author Shawn Laubach (slaubach at apache dot org)
034:         */
035:        public class HSSFHeader {
036:
037:            HeaderRecord headerRecord;
038:            String left;
039:            String center;
040:            String right;
041:
042:            /**
043:             * Constructor.  Creates a new header interface from a header record
044:             *
045:             * @param headerRecord Header record to create the header with
046:             */
047:            protected HSSFHeader(HeaderRecord headerRecord) {
048:                this .headerRecord = headerRecord;
049:                String head = headerRecord.getHeader();
050:                while (head != null && head.length() > 1) {
051:                    int pos = head.length();
052:                    switch (head.substring(1, 2).charAt(0)) {
053:                    case 'L':
054:                        if (head.indexOf("&C") >= 0) {
055:                            pos = Math.min(pos, head.indexOf("&C"));
056:                        }
057:                        if (head.indexOf("&R") >= 0) {
058:                            pos = Math.min(pos, head.indexOf("&R"));
059:                        }
060:                        left = head.substring(2, pos);
061:                        head = head.substring(pos);
062:                        break;
063:                    case 'C':
064:                        if (head.indexOf("&L") >= 0) {
065:                            pos = Math.min(pos, head.indexOf("&L"));
066:                        }
067:                        if (head.indexOf("&R") >= 0) {
068:                            pos = Math.min(pos, head.indexOf("&R"));
069:                        }
070:                        center = head.substring(2, pos);
071:                        head = head.substring(pos);
072:                        break;
073:                    case 'R':
074:                        if (head.indexOf("&C") >= 0) {
075:                            pos = Math.min(pos, head.indexOf("&C"));
076:                        }
077:                        if (head.indexOf("&L") >= 0) {
078:                            pos = Math.min(pos, head.indexOf("&L"));
079:                        }
080:                        right = head.substring(2, pos);
081:                        head = head.substring(pos);
082:                        break;
083:                    default:
084:                        head = null;
085:                    }
086:                }
087:            }
088:
089:            /**
090:             * Get the left side of the header.
091:             *
092:             * @return The string representing the left side.
093:             */
094:            public String getLeft() {
095:                return left;
096:            }
097:
098:            /**
099:             * Sets the left string.
100:             *
101:             * @param newLeft The string to set as the left side.
102:             */
103:            public void setLeft(String newLeft) {
104:                left = newLeft;
105:                createHeaderString();
106:            }
107:
108:            /**
109:             * Get the center of the header.
110:             *
111:             * @return The string representing the center.
112:             */
113:            public String getCenter() {
114:                return center;
115:            }
116:
117:            /**
118:             * Sets the center string.
119:             *
120:             * @param newCenter The string to set as the center.
121:             */
122:            public void setCenter(String newCenter) {
123:                center = newCenter;
124:                createHeaderString();
125:            }
126:
127:            /**
128:             * Get the right side of the header.
129:             *
130:             * @return The string representing the right side.
131:             */
132:            public String getRight() {
133:                return right;
134:            }
135:
136:            /**
137:             * Sets the right string.
138:             *
139:             * @param newRight The string to set as the right side.
140:             */
141:            public void setRight(String newRight) {
142:                right = newRight;
143:                createHeaderString();
144:            }
145:
146:            /**
147:             * Creates the complete header string based on the left, center, and middle
148:             * strings.
149:             */
150:            private void createHeaderString() {
151:                headerRecord.setHeader("&C" + (center == null ? "" : center)
152:                        + "&L" + (left == null ? "" : left) + "&R"
153:                        + (right == null ? "" : right));
154:                headerRecord.setHeaderLength((byte) headerRecord.getHeader()
155:                        .length());
156:            }
157:
158:            /**
159:             * Returns the string that represents the change in font size.
160:             *
161:             * @param size the new font size
162:             * @return The special string to represent a new font size
163:             */
164:            public static String fontSize(short size) {
165:                return "&" + size;
166:            }
167:
168:            /**
169:             * Returns the string that represents the change in font.
170:             *
171:             * @param font  the new font
172:             * @param style the fonts style
173:             * @return The special string to represent a new font size
174:             */
175:            public static String font(String font, String style) {
176:                return "&\"" + font + "," + style + "\"";
177:            }
178:
179:            /**
180:             * Returns the string representing the current page number
181:             *
182:             * @return The special string for page number
183:             */
184:            public static String page() {
185:                return "&P";
186:            }
187:
188:            /**
189:             * Returns the string representing the number of pages.
190:             *
191:             * @return The special string for the number of pages
192:             */
193:            public static String numPages() {
194:                return "&N";
195:            }
196:
197:            /**
198:             * Returns the string representing the current date
199:             *
200:             * @return The special string for the date
201:             */
202:            public static String date() {
203:                return "&D";
204:            }
205:
206:            /**
207:             * Returns the string representing the current time
208:             *
209:             * @return The special string for the time
210:             */
211:            public static String time() {
212:                return "&T";
213:            }
214:
215:            /**
216:             * Returns the string representing the current file name
217:             *
218:             * @return The special string for the file name
219:             */
220:            public static String file() {
221:                return "&F";
222:            }
223:
224:            /**
225:             * Returns the string representing the current tab (sheet) name
226:             *
227:             * @return The special string for tab name
228:             */
229:            public static String tab() {
230:                return "&A";
231:            }
232:
233:            /**
234:             * Returns the string representing the start underline
235:             *
236:             * @return The special string for start underline
237:             */
238:            public static String startUnderline() {
239:                return "&U";
240:            }
241:
242:            /**
243:             * Returns the string representing the end underline
244:             *
245:             * @return The special string for end underline
246:             */
247:            public static String endUnderline() {
248:                return "&U";
249:            }
250:
251:            /**
252:             * Returns the string representing the start double underline
253:             *
254:             * @return The special string for start double underline
255:             */
256:            public static String startDoubleUnderline() {
257:                return "&E";
258:            }
259:
260:            /**
261:             * Returns the string representing the end double underline
262:             *
263:             * @return The special string for end double underline
264:             */
265:            public static String endDoubleUnderline() {
266:                return "&E";
267:            }
268:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.