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