Package com.adobe.xfa.form
Class FormModel.Validate
- java.lang.Object
-
- com.adobe.xfa.form.FormModel.Validate
-
- Enclosing class:
- FormModel
public static class FormModel.Validate extends java.lang.Object
A base class that an implementation can derive from to interact with the form validation process. Before performing each validation test, the validation framework calls back to a Validate instance to determine whether that kind of validation test is enabled. Each time a validation failure occurs, the validation framework calls back to a Validate instance to record the failure.This default implementation has all kinds of validations enabled by default. It takes no action on validation failures, except to increment the number of failures.
-
-
Constructor Summary
Constructors Constructor Description Validate()
Initializes a newly createdValidate
object so that all kinds validation tests are enabled.Validate(boolean bScriptTestEnabled, boolean bNullTestEnabled, boolean bFormatTestEnabled, boolean bBarcodeTestEnabled)
Initializes a newly createdValidate
object so that specified validation tests are enabled.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FormModel.Validate
clone()
Creates a copy of thisValidate
.int
getFailCount()
Returns the number of validation failures since the fail count was last reset.boolean
isBarcodeTestEnabled()
Determines if barcode validation tests are enabled.boolean
isFormatTestEnabled()
Determines if format validation tests are enabled.boolean
isNullTestEnabled()
Determines if null validation tests are enabled.boolean
isScriptTestEnabled()
Determines if script validation tests are enabled.boolean
onValidateBarcodeTestFailed(FormField field, java.lang.String sValidationMessage)
Is called by the validation framework when a barcode validation test fails.void
onValidateEnd()
Is called when a validation pass ends.boolean
onValidateFormatTestFailed(FormField field, java.lang.String sValidationMessage, BooleanHolder bDisableValidate)
Is called by the validation framework when a format validation test fails.boolean
onValidateNullTestFailed(ProtoableNode node, java.lang.String sValidationMessage, BooleanHolder bDisableValidate)
Is called by the validation framework when a null validation test fails.boolean
onValidateScriptFailed(ProtoableNode node, java.lang.String sScript, java.lang.String sLanguage, java.lang.String sValidationMessage, BooleanHolder bDisableValidate)
Is called by the validation framework when a script validation test fails.void
onValidateStart()
Is called when a validation pass is started.void
resetFailCount()
Sets the number of validation failures to zero.void
setBarcodeTestEnabled(boolean bEnabled)
Sets whether barcode validation tests are to be enabled.void
setFormatTestEnabled(boolean bEnabled)
Sets whether format validation tests are to be enabled.void
setNullTestEnabled(boolean bEnabled)
Sets whether null validation tests are to be enabled.void
setScriptTestEnabled(boolean bEnabled)
Sets whether script validation tests are to be enabled.boolean
validateBarcode(Element element, java.lang.String sBarcodeType, java.lang.String sValue)
Validates a barcode.
-
-
-
Constructor Detail
-
Validate
public Validate()
Initializes a newly createdValidate
object so that all kinds validation tests are enabled.
-
Validate
public Validate(boolean bScriptTestEnabled, boolean bNullTestEnabled, boolean bFormatTestEnabled, boolean bBarcodeTestEnabled)
Initializes a newly createdValidate
object so that specified validation tests are enabled.- Parameters:
bScriptTestEnabled
- determines whether script validations are enabledbNullTestEnabled
- determines whether null validations are enabledbFormatTestEnabled
- determines whether format validations are enabledbBarcodeTestEnabled
- determines whether barcode validations are enabled
-
-
Method Detail
-
onValidateStart
public void onValidateStart()
Is called when a validation pass is started.
-
onValidateEnd
public void onValidateEnd()
Is called when a validation pass ends.
-
clone
public FormModel.Validate clone()
Creates a copy of thisValidate
. The set of tests enabled is copied, and the number of failures is set to zero.
-
isBarcodeTestEnabled
public boolean isBarcodeTestEnabled()
Determines if barcode validation tests are enabled.- Returns:
true
if barcode validation tests are enabled; otherwisefalse
-
setBarcodeTestEnabled
public void setBarcodeTestEnabled(boolean bEnabled)
Sets whether barcode validation tests are to be enabled.- Parameters:
bEnabled
-true
if barcode tests are to be performed.
-
isFormatTestEnabled
public boolean isFormatTestEnabled()
Determines if format validation tests are enabled.- Returns:
true
if format validation tests are enabled; otherwisefalse
-
setFormatTestEnabled
public void setFormatTestEnabled(boolean bEnabled)
Sets whether format validation tests are to be enabled.- Parameters:
bEnabled
-true
if format tests are to be performed.
-
isNullTestEnabled
public boolean isNullTestEnabled()
Determines if null validation tests are enabled.- Returns:
true
if null validation tests are enabled; otherwisefalse
-
setNullTestEnabled
public void setNullTestEnabled(boolean bEnabled)
Sets whether null validation tests are to be enabled.- Parameters:
bEnabled
-true
if null tests are to be performed.
-
isScriptTestEnabled
public boolean isScriptTestEnabled()
Determines if script validation tests are enabled.- Returns:
true
if script validation tests are enabled; otherwisefalse
-
setScriptTestEnabled
public void setScriptTestEnabled(boolean bEnabled)
Sets whether script validation tests are to be enabled.- Parameters:
bEnabled
-true
if script tests are to be performed.
-
onValidateBarcodeTestFailed
public boolean onValidateBarcodeTestFailed(FormField field, java.lang.String sValidationMessage)
Is called by the validation framework when a barcode validation test fails. This base implementation increments the number of failures and returnstrue
.- Parameters:
field
- the field containing the barcode testsValidationMessage
- the validation error message- Returns:
true
if validation should continue
-
onValidateFormatTestFailed
public boolean onValidateFormatTestFailed(FormField field, java.lang.String sValidationMessage, BooleanHolder bDisableValidate)
Is called by the validation framework when a format validation test fails. This base implementation increments the number of failures and returnstrue
.- Parameters:
field
- the field containing the format testsValidationMessage
- the validation error messagebDisableValidate
- indicates whether future validations for this field should be disabled- Returns:
true
if validation should continue
-
onValidateNullTestFailed
public boolean onValidateNullTestFailed(ProtoableNode node, java.lang.String sValidationMessage, BooleanHolder bDisableValidate)
Is called by the validation framework when a null validation test fails. This base implementation increments the number of failures and returnstrue
.- Parameters:
node
- the node containing the null testsValidationMessage
- the validation error messagebDisableValidate
- indicates whether future validations for this ProtoableNode should be disabled- Returns:
true
if validation should continue
-
onValidateScriptFailed
public boolean onValidateScriptFailed(ProtoableNode node, java.lang.String sScript, java.lang.String sLanguage, java.lang.String sValidationMessage, BooleanHolder bDisableValidate)
Is called by the validation framework when a script validation test fails. This base implementation increments the number of failures and returnstrue
.- Parameters:
node
- the node containing the script testsScript
- the text of the validation script that failedsLanguage
- the language of the scriptsValidationMessage
- the validation error messagebDisableValidate
- indicates whether future validations for this ProtoableNode should be disabled- Returns:
true
if validation should continue
-
getFailCount
public int getFailCount()
Returns the number of validation failures since the fail count was last reset.- Returns:
- the number of validation failures
-
resetFailCount
public void resetFailCount()
Sets the number of validation failures to zero. The validation framework calls this method before it starts each validation pass initiated by:- a call to an execValidate method
- an execute or submit action of an event, or
- an excit event of a FormSubform or FormExclGroup.
FormModel.recalculate(boolean, FormModel.Validate, boolean)
is called.
-
validateBarcode
public boolean validateBarcode(Element element, java.lang.String sBarcodeType, java.lang.String sValue)
Validates a barcode. The default implementation always returnstrue
.- Parameters:
element
- the barcode form Element.sBarcodeType
- a String that identifies the barcode patternsValue
- the barcode value- Returns:
true
if the barcode is valid
-
-