Create an indexed collection containing two instances of a data field using the default constructor.
IndexedCollection ic = new IndexedCollection(); ic.setName("anyName"); DataField df1 = new DataField(); DataField df2 = new DataField(); df1.setName("field1"); df1.setDescription("This is an example"); df2.setName("field1"); df2.setDescription("This is an example"); ic.addElement(df1); ic.addElement(df2);
The result of this code is like having the following definition in the XML Data file:
<iColl id="anyName" size="2"> <field id="field1" description="This is an example"/>; </iColl>
and instantiating it with:
IndexedCollection ic = (IndexedCollection)DataElement.readObject("anyName");
Example 6
Instantiate a dynamic keyed collection defined with no elements in the data file and assign a value to two new elements.
Note As the keyed collection does not contain the elements to be set, this code first creates the element named field1 of type DataField, and then sets its value to "Hello" and creates an element named field2 of type KeyedCollection.
Example 7
Instantiate a keyed collection with a parameter defined with the <param> subtag in the data file, assign a value to one of its elements, and get the value of the parameter.