Class ISOFieldValidator
java.lang.Object
org.jpos.iso.ISOFieldValidator
- All Implemented Interfaces:
Configurable, ISOValidator
- Direct Known Subclasses:
ISOMsgFieldValidator, IVA_ALPHANUM, IVA_NUM
Validator for ISOField components.
Title: jPOS
Description: Java Framework for Financial Systems
Copyright: Copyright (c) 2000 jPOS.org. All rights reserved.
Company: www.jPOS.org
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag used to indicate if validat process break on first error or keep an error vectorprotected ConfigurationThe validator configuration.protected Stringbrief field descriptionprotected intfield idprotected intfield length boundsprotected intfield length bounds -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ISOFieldValidator(boolean breakOnError) Create a validator instance specifying breaking if any error during validation process id found.ISOFieldValidator(boolean breakOnError, int minLen, int maxLen, String Description) Full constructor with all options.ISOFieldValidator(boolean breakOnError, int maxLen, String Description) Constructs a validator with error-break flag, max length and description.ISOFieldValidator(boolean breakOnError, String Description) Constructs a validator with break-on-error flag and description.ISOFieldValidator(int minLen, int maxLen, String Description) Constructs a validator with min/max length and description.ISOFieldValidator(int maxLen, String Description) Constructs a validator with max length and description.ISOFieldValidator(String Description) Constructs a validator with the given description. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether break-on-error is set.Returns the field description.intReturns the field ID.getRejCode(int ErrType) Get the reject code for an error type.voidsetBreakOnError(boolean breakOnErr) Sets whether to break on first error.voidDefault config params are: min-len Minimun length, max-len Max length, break-on-error break condition.voidsetDescription(String description) Sets the field description.voidsetFieldId(int f) Sets the field ID.voidsetMaxLength(int maxLen) Sets the maximum field length.voidsetMinLength(int minLen) Sets the minimum field length.Validate a field component.
-
Field Details
-
description
brief field description -
fieldId
field id -
minLen
field length bounds -
maxLen
field length bounds -
breakOnError
Flag used to indicate if validat process break on first error or keep an error vector -
cfg
The validator configuration.
-
-
Constructor Details
-
ISOFieldValidator
public ISOFieldValidator()Default constructor. -
ISOFieldValidator
Constructs a validator with the given description.- Parameters:
Description- the field description
-
ISOFieldValidator
Constructs a validator with max length and description.- Parameters:
maxLen- field maximum lengthDescription- field description
-
ISOFieldValidator
Constructs a validator with min/max length and description.- Parameters:
minLen- minimum field lengthmaxLen- maximum field lengthDescription- field description
-
ISOFieldValidator
Full constructor with all options.- Parameters:
breakOnError- if true, stop validation on first errorminLen- minimum field lengthmaxLen- maximum field lengthDescription- field description
-
ISOFieldValidator
Constructs a validator with error-break flag, max length and description.- Parameters:
breakOnError- if true, stop validation on first errormaxLen- maximum field lengthDescription- field description
-
ISOFieldValidator
Constructs a validator with break-on-error flag and description.- Parameters:
breakOnError- if true, stop on first errorDescription- field description
-
ISOFieldValidator
Create a validator instance specifying breaking if any error during validation process id found.- Parameters:
breakOnError- break condition
-
-
Method Details
-
setConfiguration
Default config params are: min-len Minimun length, max-len Max length, break-on-error break condition.- Specified by:
setConfigurationin interfaceConfigurable- Parameters:
cfg- configuration instance- Throws:
ConfigurationException- if configuration is invalid
-
setMaxLength
Sets the maximum field length.- Parameters:
maxLen- maximum length
-
setMinLength
Sets the minimum field length.- Parameters:
minLen- minimum length
-
setBreakOnError
Sets whether to break on first error.- Parameters:
breakOnErr- if true, stop on first error
-
breakOnError
Returns whether break-on-error is set.- Returns:
- true if break-on-error is enabled
-
getDescription
-
setDescription
Sets the field description.- Parameters:
description- the description
-
setFieldId
-
getFieldId
-
getRejCode
Get the reject code for an error type. At this level is empty. It must be redefined by childs if it is necessary return an error code for specific errors. ISOVError.ERR_INVALID_LENGTH and ISOVErro.ERR_INVALID_VALUE are the defaults.- Parameters:
ErrType- Key for error type.- Returns:
- the related error code. At this level return null.
-
validate
Validate a field component. Default for fields only consider field length validations.- Specified by:
validatein interfaceISOValidator- Parameters:
c- ISOField component- Returns:
- an ISOComponent result of validation process. If there area any validation error, then an ISOV component replace original c and it's returned in case of break-on-error condition is false. If break-on-error is false, then an ISOVException containing the ISOV component is raised.
- Throws:
ISOException- if there are some errors during validation. It contains an ISOV component inside referencing the errors.
-