org.apache.poi.hssf.util
Class HSSFDataValidation

java.lang.Object
  extended by org.apache.poi.hssf.util.HSSFDataValidation

public class HSSFDataValidation
extends java.lang.Object

Title: HSSFDataValidation

Description: Utilty class for creating data validation cells

Copyright: Copyright (c) 2004

Company:

Version:
2.0-pre
Author:
Dragos Buleandra (dragos.buleandra@trade2b.ro)

Field Summary
static int DATA_TYPE_ANY
          Any type
static int DATA_TYPE_DATE
          Date type
static int DATA_TYPE_DECIMAL
          Decimal type
static int DATA_TYPE_FORMULA
          Formula ( custom ) type
static int DATA_TYPE_INTEGER
          Integer type
static int DATA_TYPE_LIST
          List type ( combo box type )
static int DATA_TYPE_TEXT_LENGTH
          String length type
static int DATA_TYPE_TIME
          Time type
static int ERROR_STYLE_INFO
          INFO style like
static int ERROR_STYLE_STOP
          STOP style like
static int ERROR_STYLE_WARNING
          WARNING style like
static int OPERATOR_BETWEEN
          Condition operator
static int OPERATOR_EQUAL
           
static int OPERATOR_GREATER_OR_EQUAL
           
static int OPERATOR_GREATER_THAN
           
static int OPERATOR_LESS_OR_EQUAL
           
static int OPERATOR_LESS_THAN
           
static int OPERATOR_NOT_BETWEEN
           
static int OPERATOR_NOT_EQUAL
           
 
Constructor Summary
HSSFDataValidation()
          Empty constructor
HSSFDataValidation(short first_row, short first_col, short last_row, short last_col)
          Constructor wich initializes the cell range on wich this object will be applied
 
Method Summary
 void createErrorBox(java.lang.String title, java.lang.String text)
          Sets the title and text for the error box .
 void createPromptBox(java.lang.String title, java.lang.String text)
          Sets the title and text for the prompt box .
 int getDataValidationType()
          The data type of this object
 boolean getEmptyCellAllowed()
          Retrieve the settings for empty cells allowed
 java.lang.String getErrorBoxText()
          Returns the error box's text
 java.lang.String getErrorBoxTitle()
          Returns the error box's title
 int getErrorStyle()
          returns the error style of errror box
 boolean getExplicitListFormula()
          Returns the settings for explicit formula .
 short getFirstColumn()
           
 java.lang.String getFirstFormula()
          Returns the first formula
 short getFirstRow()
           
 short getLastColumn()
           
 short getLastRow()
           
 int getOperator()
          Retrieves the operator used for this object's formula
 java.lang.String getPromptBoxText()
          Returns the prompt box's text
 java.lang.String getPromptBoxTitle()
          Returns the prompt box's title
 java.lang.String getSecondFormula()
          Returns the second formula
 boolean getShowErrorBox()
           
 boolean getShowPromptBox()
           
 boolean getSurppressDropDownArrow()
          Useful only list validation objects .
 void setDataValidationType(int data_type)
          Set the type of this object
 void setEmptyCellAllowed(boolean allowed)
          Sets if this object allows empty as a valid value
 void setErrorStyle(int error_style)
          Sets the error style for error box
 void setExplicitListFormula(boolean explicit)
          If this object has an explicit formula .
 void setFirstColumn(short first_column)
           
 void setFirstFormula(java.lang.String formula)
          Sets the first formula for this object .
 void setFirstRow(short first_row)
           
 void setLastColumn(short last_column)
           
 void setLastRow(short last_row)
           
 void setOperator(int operator)
          Sets the operator involved in the formula whic governs this object Example : if you wants that a cell to accept only values between 1 and 5 , which mathematically means 1 <= value <= 5 , then the operator should be OPERATOR_BETWEEN
 void setSecondFormula(java.lang.String formula)
          Sets the first formula for this object .
 void setShowErrorBox(boolean show)
          Sets the behaviour when an invalid value is entered
 void setShowPromptBox(boolean show)
          Sets the behaviour when a cell which belongs to this object is selected
 void setSurppressDropDownArrow(boolean surppres)
          Useful for list validation objects .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_TYPE_ANY

public static final int DATA_TYPE_ANY
Any type

See Also:
Constant Field Values

DATA_TYPE_INTEGER

public static final int DATA_TYPE_INTEGER
Integer type

See Also:
Constant Field Values

DATA_TYPE_DECIMAL

public static final int DATA_TYPE_DECIMAL
Decimal type

See Also:
Constant Field Values

DATA_TYPE_LIST

public static final int DATA_TYPE_LIST
List type ( combo box type )

See Also:
Constant Field Values

DATA_TYPE_DATE

public static final int DATA_TYPE_DATE
Date type

See Also:
Constant Field Values

DATA_TYPE_TIME

public static final int DATA_TYPE_TIME
Time type

See Also:
Constant Field Values

DATA_TYPE_TEXT_LENGTH

public static final int DATA_TYPE_TEXT_LENGTH
String length type

See Also:
Constant Field Values

DATA_TYPE_FORMULA

public static final int DATA_TYPE_FORMULA
Formula ( custom ) type

See Also:
Constant Field Values

ERROR_STYLE_STOP

public static final int ERROR_STYLE_STOP
STOP style like

See Also:
Constant Field Values

ERROR_STYLE_WARNING

public static final int ERROR_STYLE_WARNING
WARNING style like

See Also:
Constant Field Values

ERROR_STYLE_INFO

public static final int ERROR_STYLE_INFO
INFO style like

See Also:
Constant Field Values

OPERATOR_BETWEEN

public static final int OPERATOR_BETWEEN
Condition operator

See Also:
Constant Field Values

OPERATOR_NOT_BETWEEN

public static final int OPERATOR_NOT_BETWEEN
See Also:
Constant Field Values

OPERATOR_EQUAL

public static final int OPERATOR_EQUAL
See Also:
Constant Field Values

OPERATOR_NOT_EQUAL

public static final int OPERATOR_NOT_EQUAL
See Also:
Constant Field Values

OPERATOR_GREATER_THAN

public static final int OPERATOR_GREATER_THAN
See Also:
Constant Field Values

OPERATOR_LESS_THAN

public static final int OPERATOR_LESS_THAN
See Also:
Constant Field Values

OPERATOR_GREATER_OR_EQUAL

public static final int OPERATOR_GREATER_OR_EQUAL
See Also:
Constant Field Values

OPERATOR_LESS_OR_EQUAL

public static final int OPERATOR_LESS_OR_EQUAL
See Also:
Constant Field Values
Constructor Detail

HSSFDataValidation

public HSSFDataValidation()
Empty constructor


HSSFDataValidation

public HSSFDataValidation(short first_row,
                          short first_col,
                          short last_row,
                          short last_col)
Constructor wich initializes the cell range on wich this object will be applied

Parameters:
first_row - First row
first_col - First column
last_row - Last row
last_col - Last column
Method Detail

setDataValidationType

public void setDataValidationType(int data_type)
Set the type of this object

Parameters:
data_type - The type
See Also:
DATA_TYPE_ANY, DATA_TYPE_INTEGER, DATA_TYPE_DECIMNAL, DATA_TYPE_LIST, DATA_TYPE_DATE, DATA_TYPE_TIME, DATA_TYPE_TEXT_LENTGH, DATA_TYPE_FORMULA

getDataValidationType

public int getDataValidationType()
The data type of this object

Returns:
The type
See Also:
DATA_TYPE_ANY, DATA_TYPE_INTEGER, DATA_TYPE_DECIMNAL, DATA_TYPE_LIST, DATA_TYPE_DATE, DATA_TYPE_TIME, DATA_TYPE_TEXT_LENTGH, DATA_TYPE_FORMULA

setErrorStyle

public void setErrorStyle(int error_style)
Sets the error style for error box

Parameters:
error_style - Error style constant
See Also:
ERROR_STYLE_STOP, ERROR_STYLE_WARNING, ERROR_STYLE_INFO

getErrorStyle

public int getErrorStyle()
returns the error style of errror box

Returns:
the style constant
See Also:
ERROR_STYLE_STOP, ERROR_STYLE_WARNING, ERROR_STYLE_INFO

setExplicitListFormula

public void setExplicitListFormula(boolean explicit)
If this object has an explicit formula . This is useful only for list data validation object

Parameters:
explicit - True if use an explicit formula

getExplicitListFormula

public boolean getExplicitListFormula()
Returns the settings for explicit formula . This is useful only for list data validation objects. This method always returns false if the object isn't a list validation object

Returns:
See Also:
setDataValidationType( int data_type )

setEmptyCellAllowed

public void setEmptyCellAllowed(boolean allowed)
Sets if this object allows empty as a valid value

Parameters:
allowed - True if this object should treats empty as valid value , false otherwise

getEmptyCellAllowed

public boolean getEmptyCellAllowed()
Retrieve the settings for empty cells allowed

Returns:
True if this object should treats empty as valid value , false otherwise

setSurppressDropDownArrow

public void setSurppressDropDownArrow(boolean surppres)
Useful for list validation objects .

Parameters:
surppres - True if a list should display the values into a drop down list , false otherwise . In other words , if a list should display the arrow sign on its right side

getSurppressDropDownArrow

public boolean getSurppressDropDownArrow()
Useful only list validation objects . This method always returns false if the object isn't a list validation object

Returns:
True if a list should display the values into a drop down list , false otherwise .
See Also:
setDataValidationType( int data_type )

setShowPromptBox

public void setShowPromptBox(boolean show)
Sets the behaviour when a cell which belongs to this object is selected

Parameters:
show - True if an prompt box should be displayed , false otherwise

getShowPromptBox

public boolean getShowPromptBox()
Parameters:
show - True if an prompt box should be displayed , false otherwise

setShowErrorBox

public void setShowErrorBox(boolean show)
Sets the behaviour when an invalid value is entered

Parameters:
show - True if an error box should be displayed , false otherwise

getShowErrorBox

public boolean getShowErrorBox()
Returns:
True if an error box should be displayed , false otherwise

setOperator

public void setOperator(int operator)
Sets the operator involved in the formula whic governs this object Example : if you wants that a cell to accept only values between 1 and 5 , which mathematically means 1 <= value <= 5 , then the operator should be OPERATOR_BETWEEN

Parameters:
operator - A constant for operator
See Also:
OPERATOR_BETWEEN, OPERATOR_NOT_BETWEEN, OPERATOR_EQUAL, OPERATOR_NOT_EQUAL OPERATOR_GREATER_THAN, OPERATOR_LESS_THAN, OPERATOR_GREATER_OR_EQUAL, OPERATOR_LESS_OR_EQUAL

getOperator

public int getOperator()
Retrieves the operator used for this object's formula

Returns:
See Also:
OPERATOR_BETWEEN, OPERATOR_NOT_BETWEEN, OPERATOR_EQUAL, OPERATOR_NOT_EQUAL OPERATOR_GREATER_THAN, OPERATOR_LESS_THAN, OPERATOR_GREATER_OR_EQUAL, OPERATOR_LESS_OR_EQUAL

createPromptBox

public void createPromptBox(java.lang.String title,
                            java.lang.String text)
Sets the title and text for the prompt box . Prompt box is displayed when the user selects a cell which belongs to this validation object . In order for a prompt box to be displayed you should also use method setShowPromptBox( boolean show )

Parameters:
title - The prompt box's title
text - The prompt box's text
See Also:
setShowPromptBox( boolean show )

getPromptBoxTitle

public java.lang.String getPromptBoxTitle()
Returns the prompt box's title

Returns:
Prompt box's title or null

getPromptBoxText

public java.lang.String getPromptBoxText()
Returns the prompt box's text

Returns:
Prompt box's text or null

createErrorBox

public void createErrorBox(java.lang.String title,
                           java.lang.String text)
Sets the title and text for the error box . Error box is displayed when the user enters an invalid value int o a cell which belongs to this validation object . In order for an error box to be displayed you should also use method setShowErrorBox( boolean show )

Parameters:
title - The error box's title
text - The error box's text
See Also:
setShowErrorBox( boolean show )

getErrorBoxTitle

public java.lang.String getErrorBoxTitle()
Returns the error box's title

Returns:
Error box's title or null

getErrorBoxText

public java.lang.String getErrorBoxText()
Returns the error box's text

Returns:
Error box's text or null

setFirstFormula

public void setFirstFormula(java.lang.String formula)
Sets the first formula for this object . A formula is divided into three parts : first formula , operator and second formula . In other words , a formula contains a left oprand , an operator and a right operand. This is the general rule . An example is 1<= value <= 5 . In this case , the left operand ( or the first formula ) is the number 1 . The operator is OPERATOR_BETWEEN and the right operand ( or the second formula ) is 5 .

Parameters:
formula -

getFirstFormula

public java.lang.String getFirstFormula()
Returns the first formula

Returns:

setSecondFormula

public void setSecondFormula(java.lang.String formula)
Sets the first formula for this object . A formula is divided into three parts : first formula , operator and second formula . In other words , a formula contains a left oprand , an operator and a right operand. This is the general rule . An example is 1<= value <=5 . In this case , the left operand ( or the first formula ) is the number 1 . The operator is OPERATOR_BETWEEN and the right operand ( or the second formula ) is 5 . But there are cases when a second formula isn't needed : You want somethink like : all values less than 5 . In this case , there's only a first formula ( in our case 5 ) and the operator OPERATOR_LESS_THAN

Parameters:
formula -

getSecondFormula

public java.lang.String getSecondFormula()
Returns the second formula

Returns:

setFirstRow

public void setFirstRow(short first_row)

setFirstColumn

public void setFirstColumn(short first_column)

setLastRow

public void setLastRow(short last_row)

setLastColumn

public void setLastColumn(short last_column)

getFirstRow

public short getFirstRow()

getFirstColumn

public short getFirstColumn()

getLastRow

public short getLastRow()

getLastColumn

public short getLastColumn()


Copyright 2008 The Apache Software Foundation or its licensors, as applicable.