Source Code Cross Referenced for EPCell.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » components » elementprocessor » impl » poi » hssf » elements » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements 
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.cocoon.components.elementprocessor.impl.poi.hssf.elements;
019:
020:        import java.io.IOException;
021:        import java.util.Locale;
022:
023:        import org.apache.cocoon.components.elementprocessor.ElementProcessor;
024:        import org.apache.cocoon.components.elementprocessor.LocaleAware;
025:        import org.apache.cocoon.components.elementprocessor.types.Attribute;
026:        import org.apache.cocoon.components.elementprocessor.types.NumericConverter;
027:        import org.apache.cocoon.components.elementprocessor.types.NumericResult;
028:        import org.apache.cocoon.components.elementprocessor.types.Validator;
029:        import org.apache.poi.hssf.util.Region;
030:
031:        /**
032:         * Implementation of ElementProcessor to handle the "Cell" tag.
033:         * This element has several attributes and may contain other elements.
034:         *
035:         * @author Marc Johnson (marc_johnson27591@hotmail.com)
036:         * @version CVS $Id: EPCell.java 433543 2006-08-22 06:22:54Z crossley $
037:         */
038:        public class EPCell extends BaseElementProcessor implements  LocaleAware {
039:
040:            private Cell _cell;
041:            private NumericResult _col;
042:            private NumericResult _row;
043:            private NumericResult _expr_id;
044:            private NumericResult _cols;
045:            private NumericResult _rows;
046:            private NumericResult _value_type;
047:            private String _value_format;
048:            private boolean _expr_id_fetched;
049:            private boolean _cols_fetched;
050:            private boolean _rows_fetched;
051:            private boolean _value_type_fetched;
052:            private boolean _value_format_fetched;
053:            private static final String _col_attribute = "Col";
054:            private static final String _row_attribute = "Row";
055:            private static final String _expr_id_attribute = "ExprID";
056:            private static final String _cols_attribute = "Cols";
057:            private static final String _rows_attribute = "Rows";
058:            private static final String _value_type_attribute = "ValueType";
059:            private static final String _value_format_attribute = "ValueFormat";
060:            private String locale; // the locale for this EPCell
061:            private static final Validator _cell_type_validator = new Validator() {
062:                public IOException validate(final Number number) {
063:                    return CellType.isValid(number.intValue()) ? null
064:                            : new IOException("\"" + number
065:                                    + "\" is not a legal value");
066:                }
067:            };
068:
069:            /**
070:             * constructor
071:             */
072:            public EPCell() {
073:                super (null);
074:                _cell = null;
075:                _col = null;
076:                _row = null;
077:                _expr_id = null;
078:                _cols = null;
079:                _rows = null;
080:                _value_type = null;
081:                _value_format = null;
082:                _expr_id_fetched = false;
083:                _cols_fetched = false;
084:                _rows_fetched = false;
085:                _value_type_fetched = false;
086:                _value_format_fetched = false;
087:            }
088:
089:            /**
090:             * @return column
091:             *
092:             * @exception IOException
093:             */
094:            public int getColumn() throws IOException {
095:                if (_col == null) {
096:                    _col = NumericConverter
097:                            .extractNonNegativeInteger(getValue(_col_attribute));
098:                }
099:                return _col.intValue();
100:            }
101:
102:            /**
103:             * @return row
104:             *
105:             * @exception IOException
106:             */
107:            public int getRow() throws IOException {
108:                if (_row == null) {
109:                    _row = NumericConverter
110:                            .extractNonNegativeInteger(getValue(_row_attribute));
111:                }
112:                return _row.intValue();
113:            }
114:
115:            /**
116:             * @return expression id
117:             *
118:             * @exception IOException
119:             * @exception NullPointerException
120:             */
121:            public int getExpressionId() throws IOException,
122:                    NullPointerException {
123:                if (!_expr_id_fetched) {
124:                    String valueString = getValue(_expr_id_attribute);
125:                    if (valueString != null) {
126:                        _expr_id = NumericConverter
127:                                .extractPositiveInteger(valueString);
128:                    }
129:                    _expr_id_fetched = true;
130:                }
131:                return _expr_id.intValue();
132:            }
133:
134:            /**
135:             * @return columns
136:             *
137:             * @exception IOException
138:             * @exception NullPointerException
139:             */
140:            public int getColumns() throws IOException, NullPointerException {
141:                if (!_cols_fetched) {
142:                    String valueString = getValue(_cols_attribute);
143:                    if (valueString != null) {
144:                        _cols = NumericConverter
145:                                .extractPositiveInteger(valueString);
146:                        _cols_fetched = true;
147:                    }
148:
149:                }
150:                return _cols_fetched ? _cols.intValue() : -1;
151:            }
152:
153:            /**
154:             * @return rows
155:             *
156:             * @exception IOException
157:             * @exception NullPointerException
158:             */
159:            public int getRows() throws IOException, NullPointerException {
160:                if (!_rows_fetched) {
161:                    String valueString = getValue(_rows_attribute);
162:                    if (valueString != null) {
163:                        _rows = NumericConverter
164:                                .extractPositiveInteger(valueString);
165:                        _rows_fetched = true;
166:                    }
167:
168:                }
169:                return _rows_fetched ? _rows.intValue() : -1;
170:            }
171:
172:            /**
173:             * @return cell type as a public member of CellType
174:             *
175:             * @exception IOException
176:             * @exception NullPointerException
177:             */
178:            public int getCellType() throws IOException, NullPointerException {
179:                if (!_value_type_fetched) {
180:                    String valueString = getValue(_value_type_attribute);
181:                    if (valueString != null) {
182:                        _value_type = NumericConverter.extractInteger(
183:                                valueString, _cell_type_validator);
184:                    }
185:                    _value_type_fetched = true;
186:                }
187:                return _value_type.intValue();
188:            }
189:
190:            /**
191:             * @return format string; null if no such attribute
192:             *
193:             * @exception IOException
194:             */
195:            public String getFormat() throws IOException {
196:                if (!_value_format_fetched) {
197:                    _value_format = getValue(_value_format_attribute);
198:                    _value_format_fetched = true;
199:                }
200:                return _value_format;
201:            }
202:
203:            /**
204:             * Override of initialize() implementation
205:             *
206:             * @param attributes the array of Attribute instances; may be
207:             *                   empty, will never be null
208:             * @param parent the parent ElementProcessor; may be null
209:             *
210:             * @exception IOException if anything is wrong
211:             */
212:            public void initialize(final Attribute[] attributes,
213:                    final ElementProcessor parent) throws IOException {
214:                super .initialize(attributes, parent);
215:                // default value (when <gmr:Cell> has no ValueType attribute)
216:                int cellType = CellType.CELL_TYPE_FORMULA;
217:                try {
218:                    cellType = getCellType();
219:                } catch (NullPointerException ignored) {
220:                }
221:                _cell = getSheet().getRow(getRow()).createCell(getColumn(),
222:                        cellType);
223:            }
224:
225:            public String getContent() {
226:                String content = getData();
227:                return content;
228:            }
229:
230:            /**
231:             * end processing -- apply content to the cell.
232:             *
233:             * @exception IOException
234:             */
235:            public void endProcessing() throws IOException {
236:                String content = getContent();
237:                if (content != null && locale != null) {
238:                    // if there is a locale then set it (otherwise the default locale
239:                    // will be used)
240:                    getCell().setLocale(
241:                            new Locale(locale, locale.toUpperCase()));
242:                }
243:                if (content != null && !content.trim().equals("")) {
244:                    getCell().setContent(getContent());
245:                }
246:
247:                if (getColumns() != -1 && getRows() != -1) {
248:                    getSheet().addMergedRegion(
249:                            new Region(getRow(), (short) getColumn(), getRow()
250:                                    + getRows() - 1, (short) (getColumn()
251:                                    + getColumns() - 1)));
252:                }
253:
254:            }
255:
256:            /**
257:             * override of getCell()
258:             *
259:             * @return the cell
260:             */
261:            protected Cell getCell() {
262:                return _cell;
263:            }
264:
265:            // from LocaleAware - set the locale for a cell
266:            public void setLocale(String locale) {
267:                this .locale = locale;
268:            }
269:
270:        } // end public class EPCell
w_ww__._j__a__v_a__2_s.___c___o__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.