public class DVConstraint extends java.lang.Object implements DataValidationConstraint
DataValidationConstraint.OperatorType, DataValidationConstraint.ValidationType
Modifier and Type | Method and Description |
---|---|
static DVConstraint |
createCustomFormulaConstraint(java.lang.String formula) |
static DVConstraint |
createDateConstraint(int comparisonOperator,
java.lang.String expr1,
java.lang.String expr2,
java.lang.String dateFormat)
Creates a date based data validation constraint.
|
static DVConstraint |
createExplicitListConstraint(java.lang.String[] explicitListValues) |
static DVConstraint |
createFormulaListConstraint(java.lang.String listFormula) |
static DVConstraint |
createNumericConstraint(int validationType,
int comparisonOperator,
java.lang.String expr1,
java.lang.String expr2)
Creates a number based data validation constraint.
|
static DVConstraint |
createTimeConstraint(int comparisonOperator,
java.lang.String expr1,
java.lang.String expr2)
Creates a time based data validation constraint.
|
java.lang.String[] |
getExplicitListValues()
If validation type is
DataValidationConstraint.ValidationType.LIST
and formula1 was comma-separated literal values rather than a range or named range,
returns list of literal values. |
java.lang.String |
getFormula1() |
java.lang.String |
getFormula2() |
int |
getOperator() |
int |
getValidationType() |
java.lang.Double |
getValue1() |
java.lang.Double |
getValue2() |
boolean |
isExplicitList()
Convenience method
|
boolean |
isListValidationType()
Convenience method
|
void |
setExplicitListValues(java.lang.String[] explicitListValues) |
void |
setFormula1(java.lang.String formula1)
Sets a formula for expression 1.
|
void |
setFormula2(java.lang.String formula2)
Sets a formula for expression 2.
|
void |
setOperator(int operator)
Sets the comparison operator for this constraint
|
void |
setValue1(double value1)
Sets a numeric value for expression 1.
|
void |
setValue2(double value2)
Sets a numeric value for expression 2.
|
public static DVConstraint createNumericConstraint(int validationType, int comparisonOperator, java.lang.String expr1, java.lang.String expr2)
validationType
- one of DataValidationConstraint.ValidationType.ANY
,
DataValidationConstraint.ValidationType.DECIMAL
,
DataValidationConstraint.ValidationType.INTEGER
,
DataValidationConstraint.ValidationType.TEXT_LENGTH
comparisonOperator
- any constant from DataValidationConstraint.OperatorType
enumexpr1
- date formula (when first char is '=') or formatted number valueexpr2
- date formula (when first char is '=') or formatted number valuepublic static DVConstraint createFormulaListConstraint(java.lang.String listFormula)
public static DVConstraint createExplicitListConstraint(java.lang.String[] explicitListValues)
public static DVConstraint createTimeConstraint(int comparisonOperator, java.lang.String expr1, java.lang.String expr2)
comparisonOperator
- constant from DataValidationConstraint.OperatorType
enumexpr1
- date formula (when first char is '=') or formatted time valueexpr2
- date formula (when first char is '=') or formatted time valuepublic static DVConstraint createDateConstraint(int comparisonOperator, java.lang.String expr1, java.lang.String expr2, java.lang.String dateFormat)
comparisonOperator
- constant from DataValidationConstraint.OperatorType
enumexpr1
- date formula (when first char is '=') or formatted date valueexpr2
- date formula (when first char is '=') or formatted date valuedateFormat
- ignored if both expr1 and expr2 are formulas. Default value is "YYYY/MM/DD"
otherwise any other valid argument for SimpleDateFormat can be usedpublic static DVConstraint createCustomFormulaConstraint(java.lang.String formula)
public int getValidationType()
getValidationType
in interface DataValidationConstraint
DataValidationConstraint.ValidationType
public boolean isListValidationType()
true
if this constraint is a 'list' validationpublic boolean isExplicitList()
true
if this constraint is a 'list' validation with explicit valuespublic int getOperator()
getOperator
in interface DataValidationConstraint
DataValidationConstraint.OperatorType
public void setOperator(int operator)
DataValidationConstraint
setOperator
in interface DataValidationConstraint
DataValidationConstraint.OperatorType
public java.lang.String[] getExplicitListValues()
DataValidationConstraint
DataValidationConstraint.ValidationType.LIST
and formula1
was comma-separated literal values rather than a range or named range,
returns list of literal values.
Otherwise returns null
.getExplicitListValues
in interface DataValidationConstraint
public void setExplicitListValues(java.lang.String[] explicitListValues)
setExplicitListValues
in interface DataValidationConstraint
public java.lang.String getFormula1()
getFormula1
in interface DataValidationConstraint
null
public void setFormula1(java.lang.String formula1)
DataValidationConstraint
setFormula1
in interface DataValidationConstraint
public java.lang.String getFormula2()
getFormula2
in interface DataValidationConstraint
null
public void setFormula2(java.lang.String formula2)
DataValidationConstraint
setFormula2
in interface DataValidationConstraint
public java.lang.Double getValue1()
null
public void setValue1(double value1)
public java.lang.Double getValue2()
null
public void setValue2(double value2)
Copyright 2020 The Apache Software Foundation or its licensors, as applicable.