Source Code Cross Referenced for HSSFDataValidation.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hssf » util » 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.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:           Copyright 2002-2004   Apache Software Foundation
003:
004:           Licensed under the Apache License, Version 2.0 (the "License");
005:           you may not use this file except in compliance with the License.
006:           You may obtain a copy of the License at
007:
008:               http://www.apache.org/licenses/LICENSE-2.0
009:
010:           Unless required by applicable law or agreed to in writing, software
011:           distributed under the License is distributed on an "AS IS" BASIS,
012:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:           See the License for the specific language governing permissions and
014:           limitations under the License.
015:        ==================================================================== */
016:
017:        package org.apache.poi.hssf.util;
018:
019:        /**
020:         * <p>Title: HSSFDataValidation</p>
021:         * <p>Description: Utilty class for creating data validation cells</p>
022:         * <p>Copyright: Copyright (c) 2004</p>
023:         * <p>Company: </p>
024:         * @author Dragos Buleandra (dragos.buleandra@trade2b.ro)
025:         * @version 2.0-pre
026:         */
027:
028:        public class HSSFDataValidation {
029:            /**
030:             * Validation data type constants
031:             */
032:            /**
033:             * Any type
034:             */
035:            public static final int DATA_TYPE_ANY = 0x00;
036:            /**
037:             * Integer type
038:             */
039:            public static final int DATA_TYPE_INTEGER = 0x01;
040:            /**
041:             * Decimal type
042:             */
043:            public static final int DATA_TYPE_DECIMAL = 0x02;
044:            /**
045:             * List type ( combo box type )
046:             */
047:            public static final int DATA_TYPE_LIST = 0x03;
048:            /**
049:             * Date type
050:             */
051:            public static final int DATA_TYPE_DATE = 0x04;
052:            /**
053:             * Time type
054:             */
055:            public static final int DATA_TYPE_TIME = 0x05;
056:            /**
057:             * String length type
058:             */
059:            public static final int DATA_TYPE_TEXT_LENGTH = 0x06;
060:            /**
061:             * Formula ( custom ) type
062:             */
063:            public static final int DATA_TYPE_FORMULA = 0x07;
064:
065:            /**
066:             * Error style constants for error box
067:             */
068:            /**
069:             * STOP style like
070:             */
071:            public static final int ERROR_STYLE_STOP = 0x00;
072:            /**
073:             * WARNING style like
074:             */
075:            public static final int ERROR_STYLE_WARNING = 0x01;
076:            /**
077:             * INFO style like
078:             */
079:            public static final int ERROR_STYLE_INFO = 0x02;
080:
081:            /**
082:             * Condition operator
083:             */
084:            public static final int OPERATOR_BETWEEN = 0x00;
085:            public static final int OPERATOR_NOT_BETWEEN = 0x01;
086:            public static final int OPERATOR_EQUAL = 0x02;
087:            public static final int OPERATOR_NOT_EQUAL = 0x03;
088:            public static final int OPERATOR_GREATER_THAN = 0x04;
089:            public static final int OPERATOR_LESS_THAN = 0x05;
090:            public static final int OPERATOR_GREATER_OR_EQUAL = 0x06;
091:            public static final int OPERATOR_LESS_OR_EQUAL = 0x07;
092:
093:            private short _first_row = 0;
094:            private short _first_col = 0;
095:            private short _last_row = 0;
096:            private short _last_col = 0;
097:
098:            private String _prompt_title = null;
099:            private String _prompt_text = null;
100:            private String _error_title = null;
101:            private String _error_text = null;
102:            private String _string_first_formula = null;
103:            private String _string_sec_formula = null;
104:
105:            private int _data_type = HSSFDataValidation.DATA_TYPE_ANY;
106:            private int _error_style = HSSFDataValidation.ERROR_STYLE_STOP;
107:            private boolean _list_explicit_formula = true;
108:            private boolean _empty_cell_allowed = true;
109:            private boolean _surpress_dropdown_arrow = false;
110:            private boolean _show_prompt_box = true;
111:            private boolean _show_error_box = true;
112:            private int _operator = HSSFDataValidation.OPERATOR_BETWEEN;
113:
114:            /**
115:             * Empty constructor
116:             */
117:            public HSSFDataValidation() {
118:            }
119:
120:            /**
121:             * Constructor wich initializes the cell range on wich this object will be applied
122:             * @param first_row First row
123:             * @param first_col First column
124:             * @param last_row Last row
125:             * @param last_col Last column
126:             */
127:            public HSSFDataValidation(short first_row, short first_col,
128:                    short last_row, short last_col) {
129:                this ._first_row = first_row;
130:                this ._first_col = first_col;
131:                this ._last_row = last_row;
132:                this ._last_col = last_col;
133:            }
134:
135:            /**
136:             * Set the type of this object
137:             * @param data_type The type
138:             * @see DATA_TYPE_ANY, DATA_TYPE_INTEGER, DATA_TYPE_DECIMNAL, DATA_TYPE_LIST, DATA_TYPE_DATE,
139:             *      DATA_TYPE_TIME, DATA_TYPE_TEXT_LENTGH, DATA_TYPE_FORMULA
140:             */
141:            public void setDataValidationType(int data_type) {
142:                this ._data_type = data_type;
143:            }
144:
145:            /**
146:             * The data type of this object
147:             * @return The type
148:             * @see DATA_TYPE_ANY, DATA_TYPE_INTEGER, DATA_TYPE_DECIMNAL, DATA_TYPE_LIST, DATA_TYPE_DATE,
149:             *      DATA_TYPE_TIME, DATA_TYPE_TEXT_LENTGH, DATA_TYPE_FORMULA
150:             */
151:            public int getDataValidationType() {
152:                return this ._data_type;
153:            }
154:
155:            /**
156:             * Sets the error style for error box
157:             * @param error_style Error style constant
158:             * @see ERROR_STYLE_STOP, ERROR_STYLE_WARNING, ERROR_STYLE_INFO
159:             */
160:            public void setErrorStyle(int error_style) {
161:                this ._error_style = error_style;
162:            }
163:
164:            /**
165:             * returns the error style of errror box
166:             * @return the style constant
167:             * @see ERROR_STYLE_STOP, ERROR_STYLE_WARNING, ERROR_STYLE_INFO
168:             */
169:            public int getErrorStyle() {
170:                return this ._error_style;
171:            }
172:
173:            /**
174:             * If this object has an explicit formula . This is useful only for list data validation object
175:             * @param explicit True if use an explicit formula
176:             */
177:            public void setExplicitListFormula(boolean explicit) {
178:                this ._list_explicit_formula = explicit;
179:            }
180:
181:            /**
182:             * Returns the settings for explicit formula . This is useful only for list data validation objects.
183:             * This method always returns false if the object isn't a list validation object
184:             * @see setDataValidationType( int data_type )
185:             * @return
186:             */
187:            public boolean getExplicitListFormula() {
188:                if (this ._data_type != HSSFDataValidation.DATA_TYPE_LIST) {
189:                    return false;
190:                }
191:                return this ._list_explicit_formula;
192:            }
193:
194:            /**
195:             * Sets if this object allows empty as a valid value
196:             * @param allowed True if this object should treats empty as valid value , false otherwise
197:             */
198:            public void setEmptyCellAllowed(boolean allowed) {
199:                this ._empty_cell_allowed = allowed;
200:            }
201:
202:            /**
203:             * Retrieve the settings for empty cells allowed
204:             * @return True if this object should treats empty as valid value , false otherwise
205:             */
206:            public boolean getEmptyCellAllowed() {
207:                return this ._empty_cell_allowed;
208:            }
209:
210:            /**
211:             * Useful for list validation objects .
212:             * @param surppres True if a list should display the values into a drop down list , false otherwise .
213:             *                 In other words , if a list should display the arrow sign on its right side
214:             */
215:            public void setSurppressDropDownArrow(boolean surppres) {
216:                this ._surpress_dropdown_arrow = surppres;
217:            }
218:
219:            /**
220:             * Useful only list validation objects .
221:             * This method always returns false if the object isn't a list validation object
222:             * @return True if a list should display the values into a drop down list , false otherwise .
223:             * @see setDataValidationType( int data_type )
224:             */
225:            public boolean getSurppressDropDownArrow() {
226:                if (this ._data_type != HSSFDataValidation.DATA_TYPE_LIST) {
227:                    return false;
228:                }
229:                return this ._surpress_dropdown_arrow;
230:            }
231:
232:            /**
233:             * Sets the behaviour when a cell which belongs to this object is selected
234:             * @param show True if an prompt box should be displayed , false otherwise
235:             */
236:            public void setShowPromptBox(boolean show) {
237:                this ._show_prompt_box = show;
238:            }
239:
240:            /**
241:             * @param show True if an prompt box should be displayed , false otherwise
242:             */
243:            public boolean getShowPromptBox() {
244:                if ((this .getPromptBoxText() == null)
245:                        && (this .getPromptBoxTitle() == null)) {
246:                    return false;
247:                }
248:                return this ._show_prompt_box;
249:            }
250:
251:            /**
252:             * Sets the behaviour when an invalid value is entered
253:             * @param show True if an error box should be displayed , false otherwise
254:             */
255:            public void setShowErrorBox(boolean show) {
256:                this ._show_error_box = show;
257:            }
258:
259:            /**
260:             * @return True if an error box should be displayed , false otherwise
261:             */
262:            public boolean getShowErrorBox() {
263:                if ((this .getErrorBoxText() == null)
264:                        && (this .getErrorBoxTitle() == null)) {
265:                    return false;
266:                }
267:                return this ._show_error_box;
268:            }
269:
270:            /**
271:             * Sets the operator involved in the formula whic governs this object
272:             * Example : if you wants that a cell to accept only values between 1 and 5 , which
273:             * mathematically means 1 <= value <= 5 , then the operator should be OPERATOR_BETWEEN
274:             * @param operator A constant for operator
275:             * @see OPERATOR_BETWEEN, OPERATOR_NOT_BETWEEN, OPERATOR_EQUAL, OPERATOR_NOT_EQUAL
276:             * OPERATOR_GREATER_THAN, OPERATOR_LESS_THAN, OPERATOR_GREATER_OR_EQUAL,
277:             * OPERATOR_LESS_OR_EQUAL
278:             */
279:            public void setOperator(int operator) {
280:                this ._operator = operator;
281:            }
282:
283:            /**
284:             * Retrieves the operator used for this object's formula
285:             * @return
286:             * @see OPERATOR_BETWEEN, OPERATOR_NOT_BETWEEN, OPERATOR_EQUAL, OPERATOR_NOT_EQUAL
287:             * OPERATOR_GREATER_THAN, OPERATOR_LESS_THAN, OPERATOR_GREATER_OR_EQUAL,
288:             * OPERATOR_LESS_OR_EQUAL
289:             */
290:            public int getOperator() {
291:                return this ._operator;
292:            }
293:
294:            /**
295:             * Sets the title and text for the prompt box . Prompt box is displayed when the user
296:             * selects a cell which belongs to this validation object . In order for a prompt box
297:             * to be displayed you should also use method setShowPromptBox( boolean show )
298:             * @param title The prompt box's title
299:             * @param text The prompt box's text
300:             * @see setShowPromptBox( boolean show )
301:             */
302:            public void createPromptBox(String title, String text) {
303:                this ._prompt_title = title;
304:                this ._prompt_text = text;
305:                this .setShowPromptBox(true);
306:            }
307:
308:            /**
309:             * Returns the prompt box's title
310:             * @return Prompt box's title or null
311:             */
312:            public String getPromptBoxTitle() {
313:                return this ._prompt_title;
314:            }
315:
316:            /**
317:             * Returns the prompt box's text
318:             * @return Prompt box's text or null
319:             */
320:            public String getPromptBoxText() {
321:                return this ._prompt_text;
322:            }
323:
324:            /**
325:             * Sets the title and text for the error box . Error box is displayed when the user
326:             * enters an invalid value int o a cell which belongs to this validation object .
327:             * In order for an error box to be displayed you should also use method
328:             * setShowErrorBox( boolean show )
329:             * @param title The error box's title
330:             * @param text The error box's text
331:             * @see setShowErrorBox( boolean show )
332:             */
333:            public void createErrorBox(String title, String text) {
334:                this ._error_title = title;
335:                this ._error_text = text;
336:                this .setShowErrorBox(true);
337:            }
338:
339:            /**
340:             * Returns the error box's title
341:             * @return Error box's title or null
342:             */
343:            public String getErrorBoxTitle() {
344:                return this ._error_title;
345:            }
346:
347:            /**
348:             * Returns the error box's text
349:             * @return Error box's text or null
350:             */
351:            public String getErrorBoxText() {
352:                return this ._error_text;
353:            }
354:
355:            /**
356:             * Sets the first formula for this object .
357:             * A formula is divided into three parts : first formula , operator and second formula .
358:             * In other words , a formula contains a left oprand , an operator and a right operand.
359:             * This is the general rule . An example is 1<= value <= 5 . In this case ,
360:             * the left operand ( or the first formula ) is the number 1 . The operator is
361:             * OPERATOR_BETWEEN and the right operand ( or the second formula ) is 5 .
362:             * @param formula
363:             */
364:            public void setFirstFormula(String formula) {
365:                this ._string_first_formula = formula;
366:            }
367:
368:            /**
369:             * Returns the first formula
370:             * @return
371:             */
372:            public String getFirstFormula() {
373:                return this ._string_first_formula;
374:            }
375:
376:            /**
377:             * Sets the first formula for this object .
378:             * A formula is divided into three parts : first formula , operator and second formula .
379:             * In other words , a formula contains a left oprand , an operator and a right operand.
380:             * This is the general rule . An example is 1<= value <=5 . In this case ,
381:             * the left operand ( or the first formula ) is the number 1 . The operator is
382:             * OPERATOR_BETWEEN and the right operand ( or the second formula ) is 5 .
383:             * But there are cases when a second formula isn't needed :
384:             * You want somethink like : all values less than 5 . In this case , there's only a first
385:             * formula ( in our case 5 ) and the operator OPERATOR_LESS_THAN
386:             * @param formula
387:             */
388:            public void setSecondFormula(String formula) {
389:                this ._string_sec_formula = formula;
390:            }
391:
392:            /**
393:             * Returns the second formula
394:             * @return
395:             */
396:            public String getSecondFormula() {
397:                return this ._string_sec_formula;
398:            }
399:
400:            public void setFirstRow(short first_row) {
401:                this ._first_row = first_row;
402:            }
403:
404:            public void setFirstColumn(short first_column) {
405:                this ._first_col = first_column;
406:            }
407:
408:            public void setLastRow(short last_row) {
409:                this ._last_row = last_row;
410:            }
411:
412:            public void setLastColumn(short last_column) {
413:                this ._last_col = last_column;
414:            }
415:
416:            public short getFirstRow() {
417:                return this ._first_row;
418:            }
419:
420:            public short getFirstColumn() {
421:                return this ._first_col;
422:            }
423:
424:            public short getLastRow() {
425:                return this ._last_row;
426:            }
427:
428:            public short getLastColumn() {
429:                return this._last_col;
430:            }
431:
432:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.