Previous Topic: Export ObjectNext Topic: System Level Properties


View Example

The easiest way to understand view objects is to look at an example. Later sections in this chapter describe how particular mappings occur.

The following example shows how generators map a given import view in the model to a view object:

ADDR_SERVER

IMPORTS:
Entity View in address
line1
line2
Group View inGV (2)
Entity View ingroup address
  line1
  line2

From the given import view, five EJB classes are generated. The classes and their properties are shown in the following table:

Class

Attributes

AddrServerImport

  • Command
  • NextLocation
  • ClientId
  • ClientPassword
  • Dialect
  • ExitState
  • InEVAddress—Gets AddrServer.InAddress object
  • IngvGV—Gets AddrServer.Ingv object

AddrServer.InAddress

  • Line1Fld
  • Line2Fld

AddrServer.Ingv

  • Capacity (Read-only constant)
  • Length
  • Rows—Gets a AddrServer.IngvRow object
  • this[]—Implicit indexer same as Rows

AddrServer.IngvRow

  • IngroupEVAddress—Gets AddrServer.IngroupEVAddress object

AddrServer.IngroupAddress

  • Line1Fld
  • Line2Fld

The number of classes increases in proportion with the number of entity views, work sets, and group views.

To finish the sample, it is beneficial to look at how a programmer gets and sets the various pieces of data in the views. The following code sample is written in Java.

Instantiate the Import View object:

AddrServerImport importView = new AddrServerImport();

Set the command system level data:

importView.Command = "SEND";

Access the InEVAddress line2 attribute:

String value = importView.InEVAddress.Line2Fld;

Get the maximum capacity of the IngvGV group view:

for (int i = 0; i < importView.IngvGV.Capacity; i++)

Set the current IngvGV number of rows:

importView.IngvGV.Length = 2;

Set the line1 attribute of the IngroupEVAddress entity view:

importView.Ingv[2].IngroupEVAddress.Line1Fld = "ABC";

Reset the InAddress Entity View back to defaults:

importView.InAddress.Reset();