Source Code Cross Referenced for AreaPtg.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hssf » record » formula » 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.formula 
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.formula;
019:
020:        import org.apache.poi.util.LittleEndian;
021:        import org.apache.poi.util.BitField;
022:        import org.apache.poi.util.BitFieldFactory;
023:
024:        import org.apache.poi.hssf.util.AreaReference;
025:        import org.apache.poi.hssf.util.CellReference;
026:        import org.apache.poi.hssf.model.Workbook;
027:        import org.apache.poi.hssf.record.RecordInputStream;
028:
029:        /**
030:         * Specifies a rectangular area of cells A1:A4 for instance.
031:         * @author  andy
032:         * @author Jason Height (jheight at chariot dot net dot au)
033:         */
034:
035:        public class AreaPtg extends Ptg {
036:            public final static short sid = 0x25;
037:            private final static int SIZE = 9;
038:            private short field_1_first_row;
039:            private short field_2_last_row;
040:            private short field_3_first_column;
041:            private short field_4_last_column;
042:
043:            private BitField rowRelative = BitFieldFactory.getInstance(0x8000);
044:            private BitField colRelative = BitFieldFactory.getInstance(0x4000);
045:            private BitField column = BitFieldFactory.getInstance(0x3FFF);
046:
047:            protected AreaPtg() {
048:                //Required for clone methods
049:            }
050:
051:            public AreaPtg(String arearef) {
052:                AreaReference ar = new AreaReference(arearef);
053:                setFirstRow((short) ar.getCells()[0].getRow());
054:                setFirstColumn((short) ar.getCells()[0].getCol());
055:                setLastRow((short) ar.getCells()[1].getRow());
056:                setLastColumn((short) ar.getCells()[1].getCol());
057:                setFirstColRelative(!ar.getCells()[0].isColAbsolute());
058:                setLastColRelative(!ar.getCells()[1].isColAbsolute());
059:                setFirstRowRelative(!ar.getCells()[0].isRowAbsolute());
060:                setLastRowRelative(!ar.getCells()[1].isRowAbsolute());
061:            }
062:
063:            public AreaPtg(short firstRow, short lastRow, short firstColumn,
064:                    short lastColumn, boolean firstRowRelative,
065:                    boolean lastRowRelative, boolean firstColRelative,
066:                    boolean lastColRelative) {
067:                setFirstRow(firstRow);
068:                setLastRow(lastRow);
069:                setFirstColumn(firstColumn);
070:                setLastColumn(lastColumn);
071:                setFirstRowRelative(firstRowRelative);
072:                setLastRowRelative(lastRowRelative);
073:                setFirstColRelative(firstColRelative);
074:                setLastColRelative(lastColRelative);
075:            }
076:
077:            public AreaPtg(RecordInputStream in) {
078:                field_1_first_row = in.readShort();
079:                field_2_last_row = in.readShort();
080:                field_3_first_column = in.readShort();
081:                field_4_last_column = in.readShort();
082:                //System.out.println(toString());
083:            }
084:
085:            public String getAreaPtgName() {
086:                return "AreaPtg";
087:            }
088:
089:            public String toString() {
090:                StringBuffer buffer = new StringBuffer();
091:
092:                buffer.append(getAreaPtgName());
093:                buffer.append("\n");
094:                buffer.append("firstRow = " + getFirstRow()).append("\n");
095:                buffer.append("lastRow  = " + getLastRow()).append("\n");
096:                buffer.append("firstCol = " + getFirstColumn()).append("\n");
097:                buffer.append("lastCol  = " + getLastColumn()).append("\n");
098:                buffer.append("firstColRowRel= " + isFirstRowRelative())
099:                        .append("\n");
100:                buffer.append("lastColRowRel = " + isLastRowRelative()).append(
101:                        "\n");
102:                buffer.append("firstColRel   = " + isFirstColRelative())
103:                        .append("\n");
104:                buffer.append("lastColRel    = " + isLastColRelative()).append(
105:                        "\n");
106:                return buffer.toString();
107:            }
108:
109:            public void writeBytes(byte[] array, int offset) {
110:                array[offset] = (byte) (sid + ptgClass);
111:                LittleEndian.putShort(array, offset + 1, field_1_first_row);
112:                LittleEndian.putShort(array, offset + 3, field_2_last_row);
113:                LittleEndian.putShort(array, offset + 5, field_3_first_column);
114:                LittleEndian.putShort(array, offset + 7, field_4_last_column);
115:            }
116:
117:            public int getSize() {
118:                return SIZE;
119:            }
120:
121:            /**
122:             * @return the first row in the area
123:             */
124:            public short getFirstRow() {
125:                return field_1_first_row;
126:            }
127:
128:            /**
129:             * sets the first row
130:             * @param row number (0-based)
131:             */
132:            public void setFirstRow(short row) {
133:                field_1_first_row = row;
134:            }
135:
136:            /**
137:             * @return last row in the range (x2 in x1,y1-x2,y2)
138:             */
139:            public short getLastRow() {
140:                return field_2_last_row;
141:            }
142:
143:            /**
144:             * @param row last row number in the area 
145:             */
146:            public void setLastRow(short row) {
147:                field_2_last_row = row;
148:            }
149:
150:            /**
151:             * @return the first column number in the area.
152:             */
153:            public short getFirstColumn() {
154:                return column.getShortValue(field_3_first_column);
155:            }
156:
157:            /**
158:             * @return the first column number + the options bit settings unstripped
159:             */
160:            public short getFirstColumnRaw() {
161:                return field_3_first_column;
162:            }
163:
164:            /**
165:             * @return whether or not the first row is a relative reference or not.
166:             */
167:            public boolean isFirstRowRelative() {
168:                return rowRelative.isSet(field_3_first_column);
169:            }
170:
171:            /**
172:             * sets the first row to relative or not
173:             * @param rel is relative or not.
174:             */
175:            public void setFirstRowRelative(boolean rel) {
176:                field_3_first_column = rowRelative.setShortBoolean(
177:                        field_3_first_column, rel);
178:            }
179:
180:            /**
181:             * @return isrelative first column to relative or not
182:             */
183:            public boolean isFirstColRelative() {
184:                return colRelative.isSet(field_3_first_column);
185:            }
186:
187:            /**
188:             * set whether the first column is relative 
189:             */
190:            public void setFirstColRelative(boolean rel) {
191:                field_3_first_column = colRelative.setShortBoolean(
192:                        field_3_first_column, rel);
193:            }
194:
195:            /**
196:             * set the first column in the area
197:             */
198:            public void setFirstColumn(short column) {
199:                field_3_first_column = column; // fixme
200:            }
201:
202:            /**
203:             * set the first column irespective of the bitmasks
204:             */
205:            public void setFirstColumnRaw(short column) {
206:                field_3_first_column = column;
207:            }
208:
209:            /**
210:             * @return lastcolumn in the area
211:             */
212:            public short getLastColumn() {
213:                return column.getShortValue(field_4_last_column);
214:            }
215:
216:            /**
217:             * @return last column and bitmask (the raw field)
218:             */
219:            public short getLastColumnRaw() {
220:                return field_4_last_column;
221:            }
222:
223:            /**
224:             * @return last row relative or not
225:             */
226:            public boolean isLastRowRelative() {
227:                return rowRelative.isSet(field_4_last_column);
228:            }
229:
230:            /**
231:             * set whether the last row is relative or not
232:             * @param rel <code>true</code> if the last row relative, else
233:             * <code>false</code>
234:             */
235:            public void setLastRowRelative(boolean rel) {
236:                field_4_last_column = rowRelative.setShortBoolean(
237:                        field_4_last_column, rel);
238:            }
239:
240:            /**
241:             * @return lastcol relative or not
242:             */
243:            public boolean isLastColRelative() {
244:                return colRelative.isSet(field_4_last_column);
245:            }
246:
247:            /**
248:             * set whether the last column should be relative or not
249:             */
250:            public void setLastColRelative(boolean rel) {
251:                field_4_last_column = colRelative.setShortBoolean(
252:                        field_4_last_column, rel);
253:            }
254:
255:            /**
256:             * set the last column in the area
257:             */
258:            public void setLastColumn(short column) {
259:                field_4_last_column = column; // fixme
260:            }
261:
262:            /**
263:             * set the last column irrespective of the bitmasks
264:             */
265:            public void setLastColumnRaw(short column) {
266:                field_4_last_column = column;
267:            }
268:
269:            public String toFormulaString(Workbook book) {
270:                return (new CellReference(getFirstRow(), getFirstColumn(),
271:                        !isFirstRowRelative(), !isFirstColRelative()))
272:                        .toString()
273:                        + ":"
274:                        + (new CellReference(getLastRow(), getLastColumn(),
275:                                !isLastRowRelative(), !isLastColRelative()))
276:                                .toString();
277:            }
278:
279:            public byte getDefaultOperandClass() {
280:                return Ptg.CLASS_REF;
281:            }
282:
283:            public Object clone() {
284:                AreaPtg ptg = new AreaPtg();
285:                ptg.field_1_first_row = field_1_first_row;
286:                ptg.field_2_last_row = field_2_last_row;
287:                ptg.field_3_first_column = field_3_first_column;
288:                ptg.field_4_last_column = field_4_last_column;
289:                ptg.setClass(ptgClass);
290:                return ptg;
291:            }
292:
293:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.