com.wm.app.tn.profile
Class Validator

java.lang.Object
  extended by com.wm.app.tn.profile.Validator

public class Validator
extends java.lang.Object

Profile standard field validation class. It has two public methods, one takes a vector of FieldGroup that is any combination of standard fields, the other takes one Profile. Output is a String array, each element stands for one error found. Null output means no error found.


Constructor Summary
Validator()
           
 
Method Summary
static java.lang.String[] appendString(java.lang.String[] sList, java.lang.String s)
           
static java.lang.String[] appendStringList(java.lang.String[] oldS, java.lang.String[] newS)
           
static java.lang.String[] validateAddress(Address addr, java.lang.String[] existErrors, java.lang.String who, java.lang.String idx)
          Validate a Corporate Address or a Contact Address.
static java.lang.String[] validateContact(Contact contact, java.lang.String[] existErrors)
          Validate a Corporate Contact.
static java.lang.String[] validateCorporation(Corporation corp, java.lang.String[] existErrors)
          Validate a Corporation.
static java.lang.String[] validateDestination(Destination dest, java.lang.String[] existErrors, boolean isPreferred)
          Validate a Destination (Delivery Method).
static java.lang.String[] validateDestination(Destination dest, java.lang.String[] existErrors, java.lang.String nativeProtocol, boolean isPreferred)
          Validate a Destination (Delivery Method).
static java.lang.String[] validateExtendedFields(java.util.Vector vExtFlds)
          Validates extended profile fields.
static java.lang.String[] validateID(ID id, java.lang.String[] existErrors)
          Validate an ID.
static java.lang.String[] validateStandardFields(java.util.Vector vFldGrp)
          Validates standard profile fields.
static java.lang.String[] validateStandardProfile(Profile profile)
          Validates a partner profile with standard fields only.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Validator

public Validator()
Method Detail

validateStandardFields

public static java.lang.String[] validateStandardFields(java.util.Vector vFldGrp)
Validates standard profile fields. It ensures all required standard fields have non null and non empty values.

Parameters:
vFldGrp - a vector of FieldGroup objects. Can be any combination of Address, Contact, Corporation, Destination, and ID.
Returns:
a String array of errors. Null returned if valid.

validateStandardProfile

public static java.lang.String[] validateStandardProfile(Profile profile)
Validates a partner profile with standard fields only. In addition to validate all required fields exist, it ensures the partner profile supplies Corporation data and required external ID. If a preferred delivery method is selected, it validates all required values supplied for that method.

Parameters:
profile - a partner profile.
Returns:
a String array of errors. If valid, null is returned.

validateAddress

public static java.lang.String[] validateAddress(Address addr,
                                                 java.lang.String[] existErrors,
                                                 java.lang.String who,
                                                 java.lang.String idx)
Validate a Corporate Address or a Contact Address. Ensure any required Address field in ProfileField table of datatype String is not null and not empty.

Parameters:
addr - an Address object to be validated
existErrors - a String array of errors found before entering current address validation
who - a String representation of the Address addr owner, e.g. FedEx (Delivery Dept), or FedEx (Delivery Dept) Contact (Smith, John), use empty string if not applicable
idx - 1-based integer string for indication of Address array element for calling from validateCorporation(), use empty string if not applicable
Returns:
a string array of errors found, which is a concatination of existErrors and new errors found in addr validation

validateContact

public static java.lang.String[] validateContact(Contact contact,
                                                 java.lang.String[] existErrors)
Validate a Corporate Contact. Ensure any required Contact field in ProfileField table of datatype String is not null and not empty, and any Contact Address that is not empty is valid.

Parameters:
contact - a Contact object to be validated
existErrors - a String array of errors found before entering current contact validation
Returns:
a string array of errors found, which is a concatination of existErrors and new errors found in contact validation
See Also:
validateAddress(Address,String[],String,String)

validateCorporation

public static java.lang.String[] validateCorporation(Corporation corp,
                                                     java.lang.String[] existErrors)
Validate a Corporation. Ensure any required Corporation field in ProfileField table of datatype String is not null and not empty, and any Corporation Address that is not empty is valid.

Parameters:
corp - a Corporation object to be validated
existErrors - a String array of errors found before entering current corp validation
Returns:
a string array of errors found, which is a concatination of existErrors and new errors found in corp validation
See Also:
validateAddress(Address,String[],String,String)

validateDestination

public static java.lang.String[] validateDestination(Destination dest,
                                                     java.lang.String[] existErrors,
                                                     boolean isPreferred)
Validate a Destination (Delivery Method). Ensure any required Destination field in ProfileField table of datatype String is not null and not empty. This method internally calls validateDestination(Destination,String[], nativeProtocol, boolean). This method is retained for backward compatibility

Parameters:
dest - a Destination object to be validated
existErrors - a String array of errors found before entering current corp validation
isPreferred - true for preferred protocol. Enforce validation of preferred protocol, i.e. ensure preferred protocol is not an empty Destination object
Returns:
a string array of errors found, which is a concatination of existErrors and new errors found in dest validation

validateDestination

public static java.lang.String[] validateDestination(Destination dest,
                                                     java.lang.String[] existErrors,
                                                     java.lang.String nativeProtocol,
                                                     boolean isPreferred)
Validate a Destination (Delivery Method). Ensure any required Destination field in ProfileField table of datatype String is not null and not empty.

Parameters:
dest - a Destination object to be validated
existErrors - a String array of errors found before entering current corp validation
nativeProtocol - If the destination is a named delivery method, this argument will represent the underlying protocol (like http, etc)
isPreferred - true for preferred protocol. Enforce validation of preferred protocol, i.e. ensure preferred protocol is not an empty Destination object
Returns:
a string array of errors found, which is a concatination of existErrors and new errors found in dest validation

validateID

public static java.lang.String[] validateID(ID id,
                                            java.lang.String[] existErrors)
Validate an ID. Ensure any required ID field in ProfileField table of datatype String is not null and not empty. New in version 6.0: required external ID can not have white space.

Parameters:
id - an ID object to be validated
existErrors - a String array of errors found before entering current corp validation
Returns:
a string array of errors found, which is a concatination of existErrors and new errors found in id validation

appendStringList

public static java.lang.String[] appendStringList(java.lang.String[] oldS,
                                                  java.lang.String[] newS)

appendString

public static java.lang.String[] appendString(java.lang.String[] sList,
                                              java.lang.String s)

validateExtendedFields

public static java.lang.String[] validateExtendedFields(java.util.Vector vExtFlds)
Validates extended profile fields.

Parameters:
vExtFlds - vector of extended fields
Returns:
a String array of errors. Null returned if valid.