Creating an imported type for a Java class
- On the Variables tab, click the Import button. The Import popup window appears.
- In the Imported Types listbox, select the entry <new imported type>.
- Type the Class name for the type, such as java.util.Hashtable. You must type the fully qualified class name, including the package name if any.
- Type a Short Name, such as Hashtable. If you do not specify a short name then the Macro Editor uses the fully qualified class name as the short name. If you do specify a short name then you can use either the short name or the fully qualified class name when you refer to the imported type.
- Click OK.
- In the Variables listbox, click the <new variable> entry at the end. The Macro Editor displays the default initial values in the usual way, including a name (such as $a1$), a type (string), and an initial value (blank).
- In the Name input field, type the name that you want, such as $ht$.
- In the Type listbox, select the imported type, such as Hashtable (if you specified a short name when you imported the type) or java.util.Hashtable (if you accepted the default short name, which is the same as the fully qualified class name).
- In the Initial Value field, you can either leave the field blank (which results in an initial value of null) or specify a method that returns an instance of the class, such as $new Hashtable()$ (using the short name) or $new java.util.Hashtable()$ (using the fully qualified class name).
Going back to the Import popup window, the Imported Types listbox allows you to create new types and to edit or delete the types that you have already created. To create a new type, click the <new imported type> entry at the end of the list. To edit a type, select the type in the Imported Types listbox and modify the values in the Class and Short Name input fields. To remove a type, select the type and click Remove.
When you specify a short name, you can use any name, with certain restrictions (see Variable names and type names).
<import>
<type class="java.util.Hashtable" name="Hashtable" />
</import>
<vars>
<create name=$ht$ type="Hashtable" value="$new Hashtable(40)$" />
</vars>
If you are using the Code Editor, you must put all imported types (<type> elements) inside the <import> element. The <import> element itself must appear inside the <HAScript> element (see <HAScript> element) and before the <vars> element.