This topic discusses the use and definition of constants and variables in Java CAPS Projects and Environments, and covers the following subtopics:
If you have any questions or problems, see the Java CAPS web site at http://goldstar.stc.com/support.
Project variables function as placeholders, having values that are determined when you create a specific Deployment Profile. Project variables can be literals or Environmental constants, as described in Defining Environmental Constants.
As an example, the following figure shows a Project variable defined to represent a password of a database user in a target Environment. A system manager assigns an actual value to this variable in the Deployment Profile editor. The value of the assigned Project variable (an Environmental constant) is then used to connect to the database in the target Environment.
You can add a variable to a Project by selecting the New > Variable or Constant option from the Project context menu in the NetBeans IDE, which displays the following dialog box.
Property |
Description/Usage |
---|---|
Name |
Your name for the Project variable. |
Category |
You may assign a category name, if desired. |
Description |
Your description for the variable. |
Is a Constant |
Does not apply to variables; leave unchecked. |
Value Type |
Does not apply to variables. |
Value |
Does not apply to variables. |
Constants and variables are automatically added to a Variables and Constants object group within the Project, as shown in the following figure. Selecting an entry in the upper panel displays it in the lower panel, where you can modify it. By clicking OK you overwrite the previous definition with the modified version.
Icon |
Name |
Function |
---|---|---|
![]() |
Add a New Constant or Variable |
Adds a new variable to the list. |
![]() |
Delete a Highlighted Constant or Variable |
Deletes the selected variable from the list. |
Project constants are name-value pairs that are visible across the Project. Using a constant allows you to define the value once, and then refer to it from the various Project configurations, rather than having to redefine the value everywhere it is needed. For example, the following figure shows a standard currency defined to be used globally throughout the system.
You can add a constant to a Project by selecting the New > Variable or Constant option from the Project context menu in the NetBeans IDE, which displays the following dialog box.
Property |
Option |
Description/Usage |
---|---|---|
Name |
Your name for the Project constant. |
|
Category |
You may assign a category name, if desired. |
|
Description |
Your description for the constant. |
|
Is a Constant |
Select to enable the constant properties fields. |
|
Value Type |
String |
Allows the string value to be displayed explicitly. |
Password |
Encrypts the value, displaying asterisks (*) in the field. |
|
Value |
The value for the constant. |
Constants and variables are automatically added to a Variables and Constants object group within the Project, as shown in the following figure. Selecting an entry in the upper panel displays it in the lower panel, where you can modify it. By clicking OK you overwrite the previous definition with the modified version.
Icon |
Name |
Function |
---|---|---|
![]() |
Add a New Constant or Variable |
Adds a new constant to the list. |
![]() |
Delete a Highlighted Constant or Variable |
Deletes the selected constant from the list. |
Environmental constants are name-value pairs that are visible across the Environment. Using a constant allows you to define the value once, and then refer to it from the various Project configurations, rather than having to redefine the value everywhere it is needed. Selecting the New > Constant option from the Environment context menu, which displays the Create Environmental Constant dialog box shown in the following figure.
Property |
Option |
Description/Usage |
---|---|---|
Name |
Your name for the Environmental constant. |
|
Category |
You may assign a category name, if desired. |
|
Description |
Your description for the constant. |
|
Is a Constant |
Automatically selected, not modifiable. |
|
Value Type |
String |
Allows the string value to be displayed explicitly. |
Password |
Encrypts the value, displaying asterisks (*) in the field. |
|
Value |
The value for the constant. |
When you create an Environmental constant, you assign a permanent value to it which cannot be overridden.
Constants are automatically added to a Constants object group within the Environment, as shown in the following figure. All constants defined for the specific Environment are listed in the Constants section of the panel, along with their various properties. Additional Environmental Constants can be defined using the lower part of the panel.
Icon |
Name |
Function |
---|---|---|
![]() |
Add a New Constant |
Adds a new constant to the list. |
![]() |
Delete a Highlighted Constant |
Deletes the selected constant from the list. |
Refer to the Java CAPS 6 Release Notes regarding this feature.