|
C:\uddi\inspireit\uddi\examples\ValidationExample1.java
|
1 package inspireit.uddi.examples;
2
3 import inspireit.uddi.*;
4 import inspireit.uddi.base.*;
5 import inspireit.uddi.util.validators.*;
6
7 /**
8 * Validation example #1.
9 *
10 * @author Bertrand Fontaine, <a href="http://www.inspireit.biz" target="INSPIREIT">INSPIRE IT</a>
11 */
12 public class ValidationExample1 {
13
14 public static void main(String args[]) {
15 // instantiate a TModel validator suitable to UDDI V1
16 ValidatorFactory factory = new ValidatorFactory(UDDIConstants.UDDI_V1);
17 // uncomment the following line to use UDDI V2 validation instead of the default V1
18 // factory = new ValidationFactory(UDDIConstants.UDDI_V2);
19
20 TModelValidator validator = factory.createTModelValidator();
21
22 // create a validName
23 Name nameOK = new Name("SampleTModel");
24
25 try {
26 validator.validateName(nameOK);
27 System.out.println("[" + nameOK + "] is a valid TModel name.");
28 } catch(TModelException tme) {
29 System.out.println("[" + nameOK + "] is NOT a valid TModel name.");
30 tme.printStackTrace();
31 }
32
33 char toolong[] = new char[129];
34 Name nameTooLong = new Name(new String(toolong));
35
36 try {
37 validator.validateName(nameTooLong);
38 System.out.println("[" + nameTooLong + "] is a valid TModel name.");
39 } catch(TModelException tme) {
40 System.out.println("[" + nameTooLong + "] is NOT a valid TModel name.");
41 tme.printStackTrace();
42 }
43
44 return;
45 }
46 }
47