| |

Ruddi validators

Introduction

Ruddi validators allow validating any Ruddi data structure against either the UDDI 3.0, 2.0 or 1.0 specification. For example, a BusinessEntity with a name of 150 characters long will be detected as "too long" if the library is configured for validation against the UDDI 1.0 specification but will be considered valid if the library is configured for validation against the 2.0 specification.

Ruddi validators provide major advantages compared to XML schema-based validation. Ruddi validators can indeed throw an exception either when the first validation problem is encountered or all at once when all the validation checkings have been performed. More importantly, Ruddi validators throw exceptions with messages that have a real meaning in a UDDI context. XML schema-based validation would only throw messages that have meaning in an XML parsing context.

Working with validators

The name of a validator class for a given Ruddi data structure corresponds to the name of the Ruddi data structure followed by "Validator". For example, the AddressValidator class validates the Address Ruddi data structure. In order to obtain a validator appropriate to the validation of a given Ruddi data structure, a Ruddi developer must first instantiate a ValidatorFactory (located in the "inspireit.uddi.util.validators" package), passing to its constructor the UDDI version of reference. A validator instance can then be obtained by calling the appropriate createXXXValidator() method, where XXX is the name of the Ruddi data structure to validate. For example, the createAddressValidator() method creates a validator suitable to the validation of an Address Ruddi data structure.

The ValidatorFactory class comes with two types of methods: parameter less methods and two parameters methods. Two parameters methods take as a first parameter the Ruddi data structure to validate and as the second parameter a boolean indicating the validation strategy. The validation strategy can be to either throw an exception from the first validation problem, or after all validation checkings have been performed.

The parameterless ValidatorFactory methods are typically used to create validators used to validate potential sub-elements of a Ruddi data structure. For example, to validate a UseType element that could be used in the context of an Address definition. ValidatorFactory methods taking the Ruddi data structure and a boolean as parameters are used to validate existing Ruddi data structures.

 


 

| |

(c) INSPIRE IT, 2003 | Send us your feedback: developers@ruddi.biz