Creating indexed properties
You can also create indexed properties. Indexed properties are usually implemented as arrays or vectors and enable you to set and get values using an index. Indexed getter and setter methods have a parameter which specifies the index of the element to be read and written.
To create an indexed property in a class source:
- Find the class in the Explorer, expand its node, and right-click on
Bean Patterns
.- In the contextual menu, choose New | Indexed Property. The New Indexed Property Pattern dialog box will appear, which will enable you to customize the code to be generated for the property.
- Proceed according to steps 3 through 6 above in the instructions for creating a simple (non-indexed) property.
- Check the items in the Options section appropriate for the property. These four options are analogous to the options for a simple property.
In addition, the indexed properties may have getter and setter methods which enable reading and writing all elements (the whole array). The checkboxes in the Non-Index Options panel enable you to add a getter with or without a
return
statement and a setter with or without aset
statement.- Click OK.
Contents | Prev | Next | Index |