biz.c24.io.api.data.swift
Class SwiftQualifierValidator

java.lang.Object
  extended by biz.c24.io.api.data.DefaultValidationRule
      extended by biz.c24.io.api.data.swift.SwiftQualifierValidator
All Implemented Interfaces:
ModelComponent, ValidationRule, Validator, Serializable

public class SwiftQualifierValidator
extends DefaultValidationRule

Validator to check the presence and repetitivness of SWIFT qualifiers in generic fields. This validation is based on the arrays of qualifier values with their associated repetitive and usages restrictions. The repetitive value will be true / false depending on whether the qualifier can be repeated. The usage value will be one of QualifierUsageEnum.MANDATORY, QualifierUsageEnum.OPTIONAL, QualifierUsageEnum.OR depending on whether the qualifier is optional, mandatory or in a mutually exclusive group respectivley.

See Also:
Serialized Form

Constructor Summary
SwiftQualifierValidator()
          Creates a new instance.
SwiftQualifierValidator(String elementName, String[] qualifierArr, char[][] optionArr, boolean[] repetitiveArr, QualifierUsageEnum[] usageArr)
          Creates a new instance with specified qualifiers and restrictions.
 
Method Summary
 String getElementName()
          Returns the name of the element to which this validator applies.
 char[] getOptions(int index)
          Returns a copy of the array of options allowed for the qualifier at index.
 String getQualifier(int index)
          Returns the qualifier value at index.
 int getQualifierCount()
          Returns the number of unique qualifier values allowed.
 QualifierUsageEnum getUsage(int index)
          Returns the usage restriction for the qualifier at index.
 boolean isRepetitive(int index)
          Returns whether the qualifier at index can repeat.
 boolean validate(Object object, DataComponent component, ComplexDataObject context, ValidationManager manager)
          Validate the given object.
 
Methods inherited from class biz.c24.io.api.data.DefaultValidationRule
addDependentPredicateCode, getAnnotation, getContextForPredicateChecking, getDependentPredicateCode, getDependentPredicateCodeCount, getErrorCode, getName, getPredicateCode, getSeverity, removeDependentPredicateCode, setAnnotation, setErrorCode, setName, setPredicateCode, setSeverity, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SwiftQualifierValidator

public SwiftQualifierValidator()
Creates a new instance.


SwiftQualifierValidator

public SwiftQualifierValidator(String elementName,
                               String[] qualifierArr,
                               char[][] optionArr,
                               boolean[] repetitiveArr,
                               QualifierUsageEnum[] usageArr)
Creates a new instance with specified qualifiers and restrictions.

Parameters:
elementName - The name of the generic SWIFT field.
optionArr - The array of option letters.
qualifierArr - The array of qualifiers.
repetitiveArr - The array of repetitive restrictions.
usageArr - The array of usage restrictions.
Method Detail

getElementName

public String getElementName()
Returns the name of the element to which this validator applies.

Returns:
The element name.

getQualifierCount

public int getQualifierCount()
Returns the number of unique qualifier values allowed.

Returns:
The count.

getQualifier

public String getQualifier(int index)
Returns the qualifier value at index.

Parameters:
index - The index.
Returns:
The qualifier value.
Throws:
ArrayIndexOutOfBoundsException - If index is greater than or equal to getQualifierCount()

getOptions

public char[] getOptions(int index)
Returns a copy of the array of options allowed for the qualifier at index.

This methods preserves the immutability of this class by returning a cloned array. Care should therefore be taken to use the cached result of one invocation where possible.

Parameters:
index - The index to be returned.
Returns:
A cloned array.
Throws:
ArrayIndexOutOfBoundsException - If index is greater than or equal to getQualifierCount()

isRepetitive

public boolean isRepetitive(int index)
Returns whether the qualifier at index can repeat.

Parameters:
index - The index to be returned.
Returns:
The value.
Throws:
ArrayIndexOutOfBoundsException - If index is greater than or equal to getQualifierCount()

getUsage

public QualifierUsageEnum getUsage(int index)
Returns the usage restriction for the qualifier at index.

Parameters:
index - The index to be returned.
Returns:
The value.
Throws:
ArrayIndexOutOfBoundsException - If index is greater than or equal to getQualifierCount()

validate

public boolean validate(Object object,
                        DataComponent component,
                        ComplexDataObject context,
                        ValidationManager manager)
                 throws ValidationException
Description copied from interface: Validator
Validate the given object.

Specified by:
validate in interface Validator
Overrides:
validate in class DefaultValidationRule
Parameters:
object - The object to be validated - commonly a String, Integer, Double, Date etc.
component - The Element or Attribute inside context which defines object.
context - The parent of object - could be null.
manager - The validation manager which is performing this validation.
Returns:
Whether the object is valid if the validation manager is not operating in exception mode.
Throws:
ValidationException - If the object is not valid and the validation maanger is operating in exception mode.


C24 Technologies © 2002-2012: All Rights Reserved.