Ruddi collections are used in many other lessons. After having completed this lesson, re-read the previous lessons in order to review potential coding style alternatives.
The UDDI specification already defines a set of collections. Typically, some UDDI notions are represented as XML-based collections, while others are represented as regular lists. Ruddi defines a collection per UDDI notion it represents and automatically serializes it in either an UDDI collection or a list.
The following code snippets uses BusinessServices as an example. However, the principles illustrated here apply to all Ruddi collections.
We can define a collection of business services using a BusinessServices Ruddi collection:
BusinessServices businessServices = new BusinessServices();
To add a BusinessService , use the add(BusinessService) method:
BusinessService businessService = ... // the business service to add
businessServices.add(businessService);
To remove a BusinessService , use the remove(BusinessService) method:
businessServices.remove(businessService);
To turn the BusinessServices collection to an array, use the toArray() method:
BusinessService _businessServices[] = businessServices.toArray();
To get a BusinessService iterator, use the iterator() method:
BusinessServiceIterator iterator = businessServices.iterator();
The content of a BusinessServices collection can be browsed using an iterator the following way:
BusinessService businessService = iterator.next();
To get the size of a collection, use the size() method:
|
|
(c) INSPIRE IT, 2003 | Send us your feedback: developers@ruddi.biz